[host] search the applications local directory for the config

This commit is contained in:
Geoffrey McRae
2020-05-30 12:31:26 +10:00
parent fcbdf7ba4f
commit 67dec216d2
5 changed files with 51 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
struct app
{
const char * executable;
char * dataPath;
};
struct app app = { 0 };
@@ -37,7 +38,13 @@ struct app app = { 0 };
int main(int argc, char * argv[])
{
app.executable = argv[0];
struct passwd * pw = getpwuid(getuid());
alloc_sprintf(&app.dataPath, "%s/", pw->pw_dir);
int result = app_main(argc, argv);
free(app.dataPath);
return result;
}
@@ -56,4 +63,9 @@ bool app_init()
const char * os_getExecutable()
{
return app.executable;
}
}
const char * os_getDataPath()
{
return app.dataPath;
}

View File

@@ -303,6 +303,24 @@ const char * os_getExecutable()
return app.executable;
}
const char * os_getDataPath()
{
static char path[MAX_PATH] = { 0 };
if (!path[0])
{
if (!GetModuleFileName(NULL, path, MAX_PATH))
return NULL;
char *p = strrchr(path, '\\');
if (!p)
return NULL;
++p;
*p = '\0';
}
return path;
}
HWND os_getMessageWnd()
{
return app.messageWnd;