1
0
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:
Darkvater
2006-08-04 23:45:20 +00:00
parent 4de30befae
commit b5e3718ac4
4 changed files with 36 additions and 84 deletions

28
os2.c
View File

@@ -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, '\\');