// dirs.cpp - Directory subroutines.
//
// (c) 2012-2015 Xestia Software Development.
//
// This file is part of Xestia Address Book.
//
// Xestia Address Book 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 Address Book 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 Address Book. 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\\Address Book\\"));
#elif defined(__APPLE__)
UserDir.Clear();
UserDir.Append(wxString::FromUTF8(getenv("HOME")));
UserDir.Append(wxT("/Library/Preferences/Xestia/Address Book/"));
#else
UserDir.Clear();
UserDir.Append(wxString::FromUTF8(getenv("HOME")));
UserDir.Append(wxT("/.xestiaab/"));
#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\\Address Book\\preferences\\"));
#elif defined(__APPLE__)
UserPrefDir.Clear();
UserPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
UserPrefDir.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences/"));
#else
UserPrefDir.Clear();
UserPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
UserPrefDir.Append(wxT("/.xestiaab/preferences/"));
#endif
return UserPrefDir;
}
wxString GetRecoveryDB()
{
// Get recovery database.
wxString RecoveryDBFile;
#if defined(__HAIKU__)
#elif defined(__WIN32__)
RecoveryDBFile.Clear();
RecoveryDBFile.Append(wxString::FromUTF8(getenv("APPDATA")));
RecoveryDBFile.Append(wxT("\\Xestia\\Address Book\\recovery.db"));
#elif defined(__APPLE__)
RecoveryDBFile.Clear();
RecoveryDBFile.Append(wxString::FromUTF8(getenv("HOME")));
RecoveryDBFile.Append(wxT("/Library/Preferences/Xestia/Address Book/recovery.db"));
#else
RecoveryDBFile.Clear();
RecoveryDBFile.Append(wxString::FromUTF8(getenv("HOME")));
RecoveryDBFile.Append(wxT("/.xestiaab/.recovery.db"));
#endif
return RecoveryDBFile;
}
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\\Address Book\\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/Address Book/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("/.xestiaab/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\\Address Book\\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/Address Book/accounts/");
AccountDir.append(AccName);
AccountDir.append("/");
if (ServerCert == true){
AccountDir.append("server.crt");
}
#else
AccountDir.clear();
AccountDir.append(getenv("HOME"));
AccountDir.append("/.xestiaab/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\\Address Book\\preferences\\accounts"));
#elif defined(__APPLE__)
AccountsFile.Clear();
AccountsFile.Append(wxString::FromUTF8(getenv("HOME")));
AccountsFile.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences/accounts"));
#else
AccountsFile.Clear();
AccountsFile.Append(wxString::FromUTF8(getenv("HOME")));
AccountsFile.Append(wxT("/.xestiaab/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\\Address Book\\preferences\\settings"));
#elif defined(__APPLE__)
SettingsFile.Clear();
SettingsFile.Append(wxString::FromUTF8(getenv("HOME")));
SettingsFile.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences/settings"));
#else
SettingsFile.Clear();
SettingsFile.Append(wxString::FromUTF8(getenv("HOME")));
SettingsFile.Append(wxT("/.xestiaab/preferences/settings"));
#endif
return SettingsFile;
}