From 6879c04393658f382ecd441947831c3a08e0830d Mon Sep 17 00:00:00 2001 From: subtly Date: Mon, 18 May 2015 16:54:32 +0200 Subject: [PATCH 1/2] Update paths so macos is consistent with linux and windows isn't using wchar. --- io_posix.c | 13 +++++++++++++ io_win32.c | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/io_posix.c b/io_posix.c index 7f03d5482..1fe82973f 100644 --- a/io_posix.c +++ b/io_posix.c @@ -26,6 +26,10 @@ #include #include #include +#if defined(__APPLE__) +#include +#include +#endif FILE* ethash_fopen(char const* file_name, char const* mode) { @@ -89,6 +93,15 @@ 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 defined(__APPLE__) + if (!home_dir || strlen(home_dir) == 0) + { + struct passwd* pwd = getpwuid(getuid()); + if (pwd) + home_dir = pwd->pw_dir; + } +#endif + size_t len = strlen(home_dir); if (!ethash_strncat(strbuf, buffsize, home_dir, len)) { return false; diff --git a/io_win32.c b/io_win32.c index 2e6c8deb8..34f1aaa77 100644 --- a/io_win32.c +++ b/io_win32.c @@ -87,9 +87,9 @@ bool ethash_file_size(FILE* f, size_t* ret_size) bool ethash_get_default_dirname(char* strbuf, size_t buffsize) { - static const char dir_suffix[] = "Appdata\\Ethash\\"; + static const char dir_suffix[] = "Ethash\\"; strbuf[0] = '\0'; - if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, (WCHAR*)strbuf))) { + if (!SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, (CHAR*)strbuf))) { return false; } if (!ethash_strncat(strbuf, buffsize, "\\", 1)) { From 9fcbacc95cea036fc27f53596d49b8bae35b3f48 Mon Sep 17 00:00:00 2001 From: subtly Date: Mon, 18 May 2015 17:35:34 +0200 Subject: [PATCH 2/2] remove apple check, as getpwuid is *nx-safe --- io_posix.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/io_posix.c b/io_posix.c index 1fe82973f..c9a17d845 100644 --- a/io_posix.c +++ b/io_posix.c @@ -26,10 +26,8 @@ #include #include #include -#if defined(__APPLE__) #include #include -#endif FILE* ethash_fopen(char const* file_name, char const* mode) { @@ -93,14 +91,12 @@ 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 defined(__APPLE__) if (!home_dir || strlen(home_dir) == 0) { struct passwd* pwd = getpwuid(getuid()); if (pwd) home_dir = pwd->pw_dir; } -#endif size_t len = strlen(home_dir); if (!ethash_strncat(strbuf, buffsize, home_dir, len)) {