diff options
-rw-r--r-- | os2.c | 28 | ||||
-rw-r--r-- | strings.c | 36 | ||||
-rw-r--r-- | unix.c | 28 | ||||
-rw-r--r-- | win32.c | 28 |
4 files changed, 36 insertions, 84 deletions
@@ -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, '\\'); @@ -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) { @@ -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) { @@ -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; |