Mercurial > repos > blastem
diff util.c @ 747:85c98a222fea
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 28 May 2015 23:05:32 -0700 |
parents | fc68992cf18d |
children | 206c449eaa81 |
line wrap: on
line diff
--- a/util.c Thu May 28 00:11:15 2015 -0700 +++ b/util.c Thu May 28 23:05:32 2015 -0700 @@ -75,6 +75,41 @@ 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 @@ } return exe_dir; } + +#endif