summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--os2.c28
-rw-r--r--strings.c36
-rw-r--r--unix.c28
-rw-r--r--win32.c28
4 files changed, 36 insertions, 84 deletions
diff --git a/os2.c b/os2.c
index ffb034d1f..581f9c755 100644
--- a/os2.c
+++ b/os2.c
@@ -424,34 +424,6 @@ bool FileExists(const char *filename)
return access(filename, 0) == 0;
}
-static int LanguageCompareFunc(const void *a, const void *b)
-{
- return strcmp(*(const char* const *)a, *(const char* const *)b);
-}
-
-int GetLanguageList(char **languages, int max)
-{
- DIR *dir;
- struct dirent *dirent;
- int num = 0;
-
- dir = opendir(_path.lang_dir);
- if (dir != NULL) {
- while ((dirent = readdir(dir)) != NULL) {
- char *t = strrchr(dirent->d_name, '.');
-
- if (t != NULL && strcmp(t, ".lng") == 0) {
- languages[num++] = strdup(dirent->d_name);
- if (num == max) break;
- }
- }
- closedir(dir);
- }
-
- qsort(languages, num, sizeof(char*), LanguageCompareFunc);
- return num;
-}
-
static void ChangeWorkingDirectory(char *exe)
{
char *s = strrchr(exe, '\\');
diff --git a/strings.c b/strings.c
index 2e976f4ad..a0434e74b 100644
--- a/strings.c
+++ b/strings.c
@@ -20,6 +20,14 @@
#include "table/landscape_const.h"
#include "music.h"
+#ifdef WIN32
+/* for opendir/readdir/closedir */
+# include "fios.h"
+#else
+# include <sys/types.h>
+# include <dirent.h>
+#endif /* WIN32 */
+
char _userstring[128];
static char *StationGetSpecialString(char *buff, int x);
@@ -1168,6 +1176,34 @@ const char *GetCurrentLocale(const char *param)
return getenv("LANG");
}
+static int CDECL LanguageCompareFunc(const void *a, const void *b)
+{
+ return strcmp(*(const char* const *)a, *(const char* const *)b);
+}
+
+static int GetLanguageList(char **languages, int max)
+{
+ DIR *dir;
+ struct dirent *dirent;
+ int num = 0;
+
+ dir = opendir(_path.lang_dir);
+ if (dir != NULL) {
+ while ((dirent = readdir(dir)) != NULL) {
+ char *t = strrchr(dirent->d_name, '.');
+
+ if (t != NULL && strcmp(t, ".lng") == 0) {
+ languages[num++] = strdup(dirent->d_name);
+ if (num == max) break;
+ }
+ }
+ closedir(dir);
+ }
+
+ qsort(languages, num, sizeof(char*), LanguageCompareFunc);
+ return num;
+}
+
// make a list of the available language packs. put the data in _dynlang struct.
void InitializeLanguagePacks(void)
{
diff --git a/unix.c b/unix.c
index 7ab3fc21e..a72fcec57 100644
--- a/unix.c
+++ b/unix.c
@@ -414,34 +414,6 @@ bool FileExists(const char *filename)
return access(filename, 0) == 0;
}
-static int LanguageCompareFunc(const void *a, const void *b)
-{
- return strcmp(*(const char* const *)a, *(const char* const *)b);
-}
-
-int GetLanguageList(char **languages, int max)
-{
- DIR *dir;
- struct dirent *dirent;
- int num = 0;
-
- dir = opendir(_path.lang_dir);
- if (dir != NULL) {
- while ((dirent = readdir(dir)) != NULL) {
- char *t = strrchr(dirent->d_name, '.');
-
- if (t != NULL && strcmp(t, ".lng") == 0) {
- languages[num++] = strdup(dirent->d_name);
- if (num == max) break;
- }
- }
- closedir(dir);
- }
-
- qsort(languages, num, sizeof(char*), LanguageCompareFunc);
- return num;
-}
-
#if defined(__BEOS__) || defined(__linux__)
static void ChangeWorkingDirectory(char *exe)
{
diff --git a/win32.c b/win32.c
index a7dacb668..6f2c76921 100644
--- a/win32.c
+++ b/win32.c
@@ -1097,34 +1097,6 @@ bool FileExists(const char *filename)
return true;
}
-static int CDECL LanguageCompareFunc(const void *a, const void *b)
-{
- return strcmp(*(const char* const *)a, *(const char* const *)b);
-}
-
-int GetLanguageList(char **languages, int max)
-{
- HANDLE hand;
- int num = 0;
- char filedir[MAX_PATH];
- WIN32_FIND_DATA fd;
- sprintf(filedir, "%s*.lng", _path.lang_dir);
-
- hand = FindFirstFile(filedir, &fd);
- if (hand != INVALID_HANDLE_VALUE) {
- do {
- if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- languages[num++] = strdup(fd.cFileName);
- if (num == max) break;
- }
- } while (FindNextFile(hand, &fd));
- FindClose(hand);
- }
-
- qsort(languages, num, sizeof(char*), LanguageCompareFunc);
- return num;
-}
-
static int ParseCommandLine(char *line, char **argv, int max_argc)
{
int n = 0;