Rev 18 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 18 | Rev 20 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | // Based on https://gist.github.com/jvranish/4441299 |
1 | // Based on https://gist.github.com/jvranish/4441299 |
2 | 2 | ||
3 | #if defined(__linux__) || defined(__FreeBSD__) // Pierre-Marie Baty -- added compile guard |
3 | #if defined(__linux__) || defined(__FreeBSD__) // Pierre-Marie Baty -- added compile guard |
4 | 4 | ||
5 | #define _GNU_SOURCE |
5 | #define _GNU_SOURCE |
6 | #include "harness/config.h" |
- | |
7 | #include "harness/os.h" |
6 | #include "harness/os.h" |
8 | #include <assert.h> |
7 | #include <assert.h> |
9 | #include <ctype.h> |
8 | #include <ctype.h> |
10 | #include <dirent.h> |
9 | #include <dirent.h> |
11 | #include <err.h> |
10 | #include <err.h> |
Line 179... | Line 178... | ||
179 | } |
178 | } |
180 | 179 | ||
181 | void resolve_full_path(char* path, const char* argv0) { |
180 | void resolve_full_path(char* path, const char* argv0) { |
182 | if (argv0[0] == '/') { // run with absolute path |
181 | if (argv0[0] == '/') { // run with absolute path |
183 | strcpy(path, argv0); |
182 | strcpy(path, argv0); |
184 | } else { // run with relative path |
183 | } else { // run with relative path |
185 | if (NULL == getcwd(path, PATH_MAX)) { |
184 | if (NULL == getcwd(path, PATH_MAX)) { |
186 | perror("getcwd error"); |
185 | perror("getcwd error"); |
187 | return; |
186 | return; |
188 | } |
187 | } |
189 | strcat(path, "/"); |
188 | strcat(path, "/"); |
Line 260... | Line 259... | ||
260 | f = fopen(pDirName, mode); |
259 | f = fopen(pDirName, mode); |
261 | break; |
260 | break; |
262 | } |
261 | } |
263 | } |
262 | } |
264 | closedir(pDir); |
263 | closedir(pDir); |
265 | if (harness_game_config.verbose) { |
- | |
266 |
|
264 | if (f == NULL) { |
267 |
|
265 | fprintf(stderr, "Failed to open \"%s\" (%s)\n", pathname, strerror(errno)); |
268 | } |
- | |
269 | } |
266 | } |
270 | return f; |
267 | return f; |
271 | } |
268 | } |
272 | 269 | ||
273 | size_t OS_ConsoleReadPassword(char* pBuffer, size_t pBufferLen) { |
270 | size_t OS_ConsoleReadPassword(char* pBuffer, size_t pBufferLen) { |