Mercurial > repos > blastem
comparison util.c @ 747:85c98a222fea
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 28 May 2015 23:05:32 -0700 |
parents | fc68992cf18d |
children | 206c449eaa81 |
comparison
equal
deleted
inserted
replaced
740:25c9e9d39997 | 747:85c98a222fea |
---|---|
73 void set_exe_str(char * str) | 73 void set_exe_str(char * str) |
74 { | 74 { |
75 exe_str = str; | 75 exe_str = str; |
76 } | 76 } |
77 | 77 |
78 #ifdef _WIN32 | |
79 #include "Shlobj.h" | |
80 #include "Windows.h" | |
81 | |
82 char * get_home_dir() | |
83 { | |
84 static char path[MAX_PATH]; | |
85 SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, path); | |
86 return path; | |
87 } | |
88 | |
89 char * get_exe_dir() | |
90 { | |
91 static char path[MAX_PATH]; | |
92 HMODULE module = GetModuleHandleA(NULL); | |
93 GetModuleFileNameA(module, path, MAX_PATH); | |
94 | |
95 int pathsize = strlen(path); | |
96 for(char * cur = path + pathsize - 1; cur != path; cur--) | |
97 { | |
98 if (*cur == '\\') { | |
99 *cur = 0; | |
100 break; | |
101 } | |
102 } | |
103 return path; | |
104 } | |
105 | |
106 #else | |
107 | |
108 char * get_home_dir() | |
109 { | |
110 return getenv("HOME"); | |
111 } | |
112 | |
78 char * readlink_alloc(char * path) | 113 char * readlink_alloc(char * path) |
79 { | 114 { |
80 char * linktext = NULL; | 115 char * linktext = NULL; |
81 ssize_t linksize = 512; | 116 ssize_t linksize = 512; |
82 ssize_t cursize = 0; | 117 ssize_t cursize = 0; |
136 exe_dir = linktext; | 171 exe_dir = linktext; |
137 } | 172 } |
138 } | 173 } |
139 return exe_dir; | 174 return exe_dir; |
140 } | 175 } |
176 | |
177 #endif |