mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-29 07:53:01 +00:00
find exe path
This commit is contained in:
parent
e3e9d2bbe6
commit
36cb12acb8
1 changed files with 25 additions and 2 deletions
27
src/main.cpp
27
src/main.cpp
|
@ -116,7 +116,8 @@ char localeDir[4096];
|
|||
|
||||
const char* localeDirs[]={
|
||||
"locale",
|
||||
"../po/locale",
|
||||
".." DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "locale",
|
||||
".." DIR_SEPARATOR_STR "po" DIR_SEPARATOR_STR "locale",
|
||||
#ifdef LOCALE_DIR
|
||||
LOCALE_DIR,
|
||||
#endif
|
||||
|
@ -124,6 +125,15 @@ const char* localeDirs[]={
|
|||
};
|
||||
#endif
|
||||
|
||||
bool getExePath(char* argv0, char* exePath, size_t maxSize) {
|
||||
if (argv0==NULL) return false;
|
||||
if (realpath(argv0,exePath)==NULL) return false;
|
||||
char* lastChar=strrchr(exePath,DIR_SEPARATOR);
|
||||
if (lastChar==NULL) return false;
|
||||
*lastChar=0;
|
||||
return true;
|
||||
}
|
||||
|
||||
TAParamResult pHelp(String) {
|
||||
printf("usage: furnace [params] [filename]\n"
|
||||
"you may specify the following parameters:\n");
|
||||
|
@ -566,9 +576,22 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
#endif
|
||||
|
||||
char exePath[4096];
|
||||
#ifdef ANDROID
|
||||
memset(exePath,0,4096);
|
||||
#else
|
||||
if (!getExePath(argv[0],exePath,4096)) memset(exePath,0,4096);
|
||||
#endif
|
||||
|
||||
bool textDomainBound=false;
|
||||
for (int i=0; localeDirs[i]; i++) {
|
||||
strncpy(localeDir,localeDirs[i],4095);
|
||||
if (exePath[0]!=0 && localeDirs[i][0]!=DIR_SEPARATOR) {
|
||||
strncpy(localeDir,exePath,4095);
|
||||
strncat(localeDir,DIR_SEPARATOR_STR,4095);
|
||||
strncat(localeDir,localeDirs[i],4095);
|
||||
} else {
|
||||
strncpy(localeDir,localeDirs[i],4095);
|
||||
}
|
||||
logV("bind text domain: %s",localeDir);
|
||||
if (!dirExists(localeDir)) continue;
|
||||
if ((localeRet=TA_BINDTEXTDOMAIN("furnace",localeDir))==NULL) {
|
||||
|
|
Loading…
Reference in a new issue