Rev 14 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 14 | Rev 18 | ||
---|---|---|---|
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" |
|
6 | #include "harness/os.h" |
7 | #include "harness/os.h" |
7 | #include <assert.h> |
8 | #include <assert.h> |
8 | #include <ctype.h> |
9 | #include <ctype.h> |
9 | #include <dirent.h> |
10 | #include <dirent.h> |
10 | #include <err.h> |
11 | #include <err.h> |
Line 178... | Line 179... | ||
178 | } |
179 | } |
179 | 180 | ||
180 | void resolve_full_path(char* path, const char* argv0) { |
181 | void resolve_full_path(char* path, const char* argv0) { |
181 | if (argv0[0] == '/') { // run with absolute path |
182 | if (argv0[0] == '/') { // run with absolute path |
182 | strcpy(path, argv0); |
183 | strcpy(path, argv0); |
183 | } else { |
184 | } else { // run with relative path |
184 | if (NULL == getcwd(path, PATH_MAX)) { |
185 | if (NULL == getcwd(path, PATH_MAX)) { |
185 | perror("getcwd error"); |
186 | perror("getcwd error"); |
186 | return; |
187 | return; |
187 | } |
188 | } |
188 | strcat(path, "/"); |
189 | strcat(path, "/"); |
Line 259... | Line 260... | ||
259 | f = fopen(pDirName, mode); |
260 | f = fopen(pDirName, mode); |
260 | break; |
261 | break; |
261 | } |
262 | } |
262 | } |
263 | } |
263 | closedir(pDir); |
264 | closedir(pDir); |
- | 265 | if (harness_game_config.verbose) { |
|
264 | if (f == NULL) { |
266 | if (f == NULL) { |
265 | fprintf(stderr, "Failed to open \"%s\" (%s)\n", pathname, strerror(errno)); |
267 | fprintf(stderr, "Failed to open \"%s\" (%s)\n", pathname, strerror(errno)); |
- | 268 | } |
|
266 | } |
269 | } |
267 | return f; |
270 | return f; |
268 | } |
271 | } |
269 | 272 | ||
270 | size_t OS_ConsoleReadPassword(char* pBuffer, size_t pBufferLen) { |
273 | size_t OS_ConsoleReadPassword(char* pBuffer, size_t pBufferLen) { |