// dirs.cpp - Directory subroutines. // // (c) 2012-2017 Xestia Software Development. // // This file is part of Xestia Calendar. Originally from Xestia Address Book. // // Xestia Calendar is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by the // Free Software Foundation, version 3 of the license. // // Xestia Calendar is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with Xestia Calendar. If not, see #include wxString GetUserDir() { // Get the user directory. wxString userDir; #if defined(__HAIKU__) #elif defined(__WIN32__) userDir.Clear(); userDir.Append(wxString::FromUTF8(getenv("APPDATA"))); userDir.Append(wxT("\\Xestia\\Calendar\\")); #elif defined(__APPLE__) userDir.Clear(); userDir.Append(wxString::FromUTF8(getenv("HOME"))); userDir.Append(wxT("/Library/Preferences/Xestia/Calendar/")); #else userDir.Clear(); userDir.Append(wxString::FromUTF8(getenv("HOME"))); userDir.Append(wxT("/.xestiacal/")); #endif return userDir; } wxString GetUserPrefDir() { // Get the user preferences directory. wxString userPrefDir; #if defined(__HAIKU__) #elif defined(__WIN32__) userPrefDir.Clear(); userPrefDir.Append(wxString::FromUTF8(getenv("APPDATA"))); userPrefDir.Append(wxT("\\Xestia\\Calendar\\preferences\\")); #elif defined(__APPLE__) userPrefDir.Clear(); userPrefDir.Append(wxString::FromUTF8(getenv("HOME"))); userPrefDir.Append(wxT("/Library/Preferences/Xestia/Calendar/preferences/")); #else userPrefDir.Clear(); userPrefDir.Append(wxString::FromUTF8(getenv("HOME"))); userPrefDir.Append(wxT("/.xestiacal/preferences/")); #endif return userPrefDir; } wxString GetAccountDir(wxString accName, bool serverCert) { // Get the account directory. wxString accountDir; #if defined(__HAIKU__) #elif defined(__WIN32__) accountDir.Clear(); accountDir.Append(wxString::FromUTF8(getenv("APPDATA"))); accountDir.Append(wxT("\\Xestia\\Calendar\\accounts\\")); accountDir.Append(accName); accountDir.Append(wxT("\\")); if (serverCert == TRUE){ accountDir.Append(wxT("server.crt")); } #elif defined(__APPLE__) accountDir.Clear(); accountDir.Append(wxString::FromUTF8(getenv("HOME"))); accountDir.Append(wxT("/Library/Preferences/Xestia/Calendar/accounts/")); accountDir.Append(accName); accountDir.Append(wxT("/")); if (serverCert == TRUE){ accountDir.Append(wxT("server.crt")); } #else accountDir.Clear(); accountDir.Append(wxString::FromUTF8(getenv("HOME"))); accountDir.Append(wxT("/.xestiacal/accounts/")); accountDir.Append(accName); accountDir.Append(wxT("/")); if (serverCert == TRUE){ accountDir.Append(wxT("server.crt")); } #endif return accountDir; } std::string GetAccountDir(std::string accName, bool serverCert) { // Get the account directory. std::string accountDir; #if defined(__HAIKU__) #elif defined(__WIN32__) accountDir.clear(); accountDir.append(getenv("APPDATA")); accountDir.append("\\Xestia\\Calendar\\accounts\\"); accountDir.append(accName); accountDir.append("\\"); if (serverCert == true){ accountDir.append("server.crt"); } #elif defined(__APPLE__) accountDir.clear(); accountDir.append(getenv("HOME")); accountDir.append("/Library/Preferences/Xestia/Calendar/accounts/"); accountDir.append(accName); accountDir.append("/"); if (serverCert == true){ accountDir.append("server.crt"); } #else accountDir.clear(); accountDir.append(getenv("HOME")); accountDir.append("/.xestiacal/accounts/"); accountDir.append(accName); accountDir.append("/"); if (serverCert == true){ accountDir.append("server.crt"); } #endif return accountDir; } wxString GetAccountsFile() { // Get the accounts preferences file. wxString accountsFile; #if defined(__HAIKU__) #elif defined(__WIN32__) accountsFile.Clear(); accountsFile.Append(wxString::FromUTF8(getenv("APPDATA"))); accountsFile.Append(wxT("\\Xestia\\Calendar\\preferences\\accounts")); #elif defined(__APPLE__) accountsFile.Clear(); accountsFile.Append(wxString::FromUTF8(getenv("HOME"))); accountsFile.Append(wxT("/Library/Preferences/Xestia/Calendar/preferences/accounts")); #else accountsFile.Clear(); accountsFile.Append(wxString::FromUTF8(getenv("HOME"))); accountsFile.Append(wxT("/.xestiacal/preferences/accounts")); #endif return accountsFile; } wxString GetSettingsFile() { // Get the preferences general settings file. wxString settingsFile; #if defined(__HAIKU__) #elif defined(__WIN32__) settingsFile.Clear(); settingsFile.Append(wxString::FromUTF8(getenv("APPDATA"))); settingsFile.Append(wxT("\\Xestia\\Calendar\\preferences\\settings")); #elif defined(__APPLE__) settingsFile.Clear(); settingsFile.Append(wxString::FromUTF8(getenv("HOME"))); settingsFile.Append(wxT("/Library/Preferences/Xestia/Calendar/preferences/settings")); #else settingsFile.Clear(); settingsFile.Append(wxString::FromUTF8(getenv("HOME"))); settingsFile.Append(wxT("/.xestiacal/preferences/settings")); #endif return settingsFile; }