summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2014-04-01 21:12:00 -0700
committerMichael Pavone <pavone@retrodev.com>2014-04-01 21:12:00 -0700
commit4468c6074eccd86951fb02d6126b3f4408f1c53e (patch)
treeb9175fee206b874ea8a4333cbe05384df8499bf0 /util.c
parentc51f057715587f133abe9bfb32d6d453a7af698b (diff)
Make Windows port a little less half-assed
Diffstat (limited to 'util.c')
-rw-r--r--util.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/util.c b/util.c
index 7fee9db..45eb9b8 100644
--- a/util.c
+++ b/util.c
@@ -75,7 +75,41 @@ void set_exe_str(char * str)
exe_str = str;
}
-#ifndef _WIN32
+#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;
@@ -139,4 +173,5 @@ fallback:
}
return exe_dir;
}
+
#endif