From bdfd890aa835d6601003541bce722c607e90cc6b Mon Sep 17 00:00:00 2001 From: Sean Qureshi Date: Sun, 18 Aug 2013 03:41:30 -0700 Subject: [PATCH] Added mac support to the standardized data file, cleaned up a bit --- other/CMakeLists.txt | 9 +++++++-- testing/toxic/main.c | 16 +++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/other/CMakeLists.txt b/other/CMakeLists.txt index 068f83db..22867773 100644 --- a/other/CMakeLists.txt +++ b/other/CMakeLists.txt @@ -9,8 +9,13 @@ if(WIN32) file(INSTALL DHTservers DESTINATION %appdata%/.tox) else() set(HOME "$ENV{HOME}") - file(MAKE_DIRECTORY ${HOME}/.tox) - file(INSTALL DHTservers DESTINATION ${HOME}/.tox) + if(APPLE) + file(MAKE_DIRECTORY ${HOME}Library/Application Support/.tox) + file(INSTALL DHTservers DESTINATION ${HOME}Library/Application Support/.tox) + else() + file(MAKE_DIRECTORY ${HOME}/.tox) + file(INSTALL DHTservers DESTINATION ${HOME}/.tox) + endif() endif() if(LINUX) diff --git a/testing/toxic/main.c b/testing/toxic/main.c index 52e810d6..2ce2dbf5 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c @@ -74,10 +74,10 @@ static Messenger *init_tox() m_callback_action(m, on_action, NULL); #ifdef __linux__ setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy")); -#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +#elif win32 setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux")); #else - setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); + setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This implies users of other Unixes are hipsters #endif return m; } @@ -92,8 +92,10 @@ int init_connection(void) if (DHT_isconnected()) return 0; -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +#if win32 FILE *fp = fopen("%appdata%/.tox/DHTservers", "r"); +#elif MAC_OSX + FILE *fp = fopen("~/Library/Application Support/.tox/DHTservers", "r"); #else FILE *fp = fopen("~/.tox/DHTservers", "r"); #endif @@ -291,26 +293,22 @@ int main(int argc, char *argv[]) if (config_err) { #if WIN32 DATA_FILE = strdup("%appdata/.tox/data"); - #else - #if MAC_OSX + #elif MAC_OSX DATA_FILE = strdup("~Library/Application Support/data"); #else DATA_FILE = strdup("~/.tox/data"); #endif - #endif } else { DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); strcpy(DATA_FILE, user_config_dir); strcat(DATA_FILE, CONFIGDIR); #if WIN32 DATA_FILE = strdup("%appdata/.tox/data"); - #else - #if MAC_OSX + #elif MAC_OSX DATA_FILE = strdup("~Library/Application Support/data"); #else DATA_FILE = strdup("~/.tox/data"); #endif - #endif } }