use same detection flow of data-dir on all platforms

This commit is contained in:
Dominik Geyer 2008-10-01 18:23:49 +00:00
parent 965f5d590d
commit eb983a6446

View file

@ -416,14 +416,6 @@ void engine_hostlookup(HOSTLOOKUP *lookup, const char *hostname)
int engine_chdir_datadir(char *argv0) int engine_chdir_datadir(char *argv0)
{ {
#if defined(CONF_FAMILY_UNIX)
static const char *sdirs[] = {
"/usr/share/teeworlds",
"/usr/local/share/teeworlds"
};
static const int sdirs_count = sizeof(sdirs) / sizeof(sdirs[0]);
#endif
int found = 0; int found = 0;
char data_dir[1024*2]; char data_dir[1024*2];
@ -445,7 +437,6 @@ int engine_chdir_datadir(char *argv0)
} }
} }
#if defined(CONF_FAMILY_UNIX)
/* 2) use data-dir in PWD if present */ /* 2) use data-dir in PWD if present */
if (!found && fs_is_dir("data")) if (!found && fs_is_dir("data"))
{ {
@ -478,9 +469,16 @@ int engine_chdir_datadir(char *argv0)
} }
} }
#if defined(CONF_FAMILY_UNIX)
/* 5) check for all default locations */ /* 5) check for all default locations */
if (!found) if (!found)
{ {
const char *sdirs[] = {
"/usr/share/teeworlds",
"/usr/local/share/teeworlds"
};
const int sdirs_count = sizeof(sdirs) / sizeof(sdirs[0]);
int i; int i;
for (i = 0; i < sdirs_count; i++) for (i = 0; i < sdirs_count; i++)
{ {
@ -492,15 +490,9 @@ int engine_chdir_datadir(char *argv0)
} }
} }
} }
#elif defined(CONF_FAMILY_WINDOWS)
/* FIXME: any alternative directories to search? %PROGRAM_FILES%/.../ */
if (!found && fs_is_dir("data"))
{
strcpy(data_dir, "data");
found = 1;
}
#endif #endif
/* data-dir exists */
if (found) if (found)
{ {
dbg_msg("engine/datadir", "using '%s'", data_dir); dbg_msg("engine/datadir", "using '%s'", data_dir);