diff options
Diffstat (limited to 'Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_posix.c')
-rw-r--r-- | Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_posix.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_posix.c b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_posix.c index 7f03d5482..c9a17d845 100644 --- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_posix.c +++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_posix.c @@ -26,6 +26,8 @@ #include <libgen.h> #include <stdio.h> #include <unistd.h> +#include <stdlib.h> +#include <pwd.h> FILE* ethash_fopen(char const* file_name, char const* mode) { @@ -89,6 +91,13 @@ bool ethash_get_default_dirname(char* strbuf, size_t buffsize) static const char dir_suffix[] = ".ethash/"; strbuf[0] = '\0'; char* home_dir = getenv("HOME"); + if (!home_dir || strlen(home_dir) == 0) + { + struct passwd* pwd = getpwuid(getuid()); + if (pwd) + home_dir = pwd->pw_dir; + } + size_t len = strlen(home_dir); if (!ethash_strncat(strbuf, buffsize, home_dir, len)) { return false; |