summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-05-28 23:05:32 -0700
committerMichael Pavone <pavone@retrodev.com>2015-05-28 23:05:32 -0700
commitd597043be9f8d1c22ac6a2365e5cbb9f82e7ea46 (patch)
tree131c7ea0f3ec03882bb8183a734f04c757918180 /util.c
parent391656eca9eb35b7e3937b2af1316460d5639306 (diff)
parent66aedc9c1a87c8811be4dba263dbcd7ec026cc70 (diff)
Merge
Diffstat (limited to 'util.c')
-rw-r--r--util.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/util.c b/util.c
index 5367cd5..fc95011 100644
--- a/util.c
+++ b/util.c
@@ -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