diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-05-28 23:05:32 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-05-28 23:05:32 -0700 |
commit | d597043be9f8d1c22ac6a2365e5cbb9f82e7ea46 (patch) | |
tree | 131c7ea0f3ec03882bb8183a734f04c757918180 /util.c | |
parent | 391656eca9eb35b7e3937b2af1316460d5639306 (diff) | |
parent | 66aedc9c1a87c8811be4dba263dbcd7ec026cc70 (diff) |
Merge
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -75,6 +75,41 @@ void set_exe_str(char * str) exe_str = str; } +#ifdef _WIN32 +#include "Shlobj.h" +#include "Windows.h" + +char * get_home_dir() +{ + static char path[MAX_PATH]; + SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, path); + return path; +} + +char * get_exe_dir() +{ + static char path[MAX_PATH]; + HMODULE module = GetModuleHandleA(NULL); + GetModuleFileNameA(module, path, MAX_PATH); + + int pathsize = strlen(path); + for(char * cur = path + pathsize - 1; cur != path; cur--) + { + if (*cur == '\\') { + *cur = 0; + break; + } + } + return path; +} + +#else + +char * get_home_dir() +{ + return getenv("HOME"); +} + char * readlink_alloc(char * path) { char * linktext = NULL; @@ -138,3 +173,5 @@ fallback: } return exe_dir; } + +#endif |