mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-28 00:49:11 +00:00
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
This commit is contained in:
28
os2.c
28
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, '\\');
|
||||
|
Reference in New Issue
Block a user