From c51f057715587f133abe9bfb32d6d453a7af698b Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Tue, 1 Apr 2014 19:43:58 -0700 Subject: Initial work on Windows port --- util.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'util.c') diff --git a/util.c b/util.c index 2bc3109..7fee9db 100644 --- a/util.c +++ b/util.c @@ -75,6 +75,7 @@ void set_exe_str(char * str) exe_str = str; } +#ifndef _WIN32 char * readlink_alloc(char * path) { char * linktext = NULL; @@ -138,3 +139,4 @@ fallback: } return exe_dir; } +#endif -- cgit v1.2.3 From 4468c6074eccd86951fb02d6126b3f4408f1c53e Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Tue, 1 Apr 2014 21:12:00 -0700 Subject: Make Windows port a little less half-assed --- util.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'util.c') 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 -- cgit v1.2.3