1 // dirs.cpp - Directory subroutines.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
24 // Get the user directory.
28 #if defined(__HAIKU__)
30 #elif defined(__WIN32__)
33 UserDir.Append(wxString::FromUTF8(getenv("APPDATA")));
34 UserDir.Append(wxT("\\Xestia\\Address Book\\"));
36 #elif defined(__APPLE__)
39 UserDir.Append(wxString::FromUTF8(getenv("HOME")));
40 UserDir.Append(wxT("/Library/Preferences/Xestia/Address Book/"));
45 UserDir.Append(wxString::FromUTF8(getenv("HOME")));
46 UserDir.Append(wxT("/.xestiaab/"));
54 wxString GetUserPrefDir()
57 // Get the user preferences directory.
61 #if defined(__HAIKU__)
63 #elif defined(__WIN32__)
66 UserPrefDir.Append(wxString::FromUTF8(getenv("APPDATA")));
67 UserPrefDir.Append(wxT("\\Xestia\\Address Book\\preferences\\"));
69 #elif defined(__APPLE__)
72 UserPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
73 UserPrefDir.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences/"));
78 UserPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
79 UserPrefDir.Append(wxT("/.xestiaab/preferences/"));
87 wxString GetRecoveryDB()
90 // Get recovery database.
92 wxString RecoveryDBFile;
94 #if defined(__HAIKU__)
96 #elif defined(__WIN32__)
98 RecoveryDBFile.Clear();
99 RecoveryDBFile.Append(wxString::FromUTF8(getenv("APPDATA")));
100 RecoveryDBFile.Append(wxT("\\Xestia\\Address Book\\recovery.db"));
102 #elif defined(__APPLE__)
104 RecoveryDBFile.Clear();
105 RecoveryDBFile.Append(wxString::FromUTF8(getenv("HOME")));
106 RecoveryDBFile.Append(wxT("/Library/Preferences/Xestia/Address Book/recovery.db"));
110 RecoveryDBFile.Clear();
111 RecoveryDBFile.Append(wxString::FromUTF8(getenv("HOME")));
112 RecoveryDBFile.Append(wxT("/.xestiaab/.recovery.db"));
116 return RecoveryDBFile;
120 wxString GetAccountDir(wxString AccName, bool ServerCert)
123 // Get the account directory.
127 #if defined(__HAIKU__)
129 #elif defined(__WIN32__)
132 AccountDir.Append(wxString::FromUTF8(getenv("APPDATA")));
133 AccountDir.Append(wxT("\\Xestia\\Address Book\\accounts\\"));
134 AccountDir.Append(AccName);
135 AccountDir.Append(wxT("\\"));
137 if (ServerCert == TRUE){
138 AccountDir.Append(wxT("server.crt"));
141 #elif defined(__APPLE__)
144 AccountDir.Append(wxString::FromUTF8(getenv("HOME")));
145 AccountDir.Append(wxT("/Library/Preferences/Xestia/Address Book/accounts/"));
146 AccountDir.Append(AccName);
147 AccountDir.Append(wxT("/"));
149 if (ServerCert == TRUE){
150 AccountDir.Append(wxT("server.crt"));
156 AccountDir.Append(wxString::FromUTF8(getenv("HOME")));
157 AccountDir.Append(wxT("/.xestiaab/accounts/"));
158 AccountDir.Append(AccName);
159 AccountDir.Append(wxT("/"));
161 if (ServerCert == TRUE){
162 AccountDir.Append(wxT("server.crt"));
171 wxString GetAccountsFile()
174 // Get the accounts preferences file.
176 wxString AccountsFile;
178 #if defined(__HAIKU__)
180 #elif defined(__WIN32__)
182 AccountsFile.Clear();
183 AccountsFile.Append(wxString::FromUTF8(getenv("APPDATA")));
184 AccountsFile.Append(wxT("\\Xestia\\Address Book\\preferences\\accounts"));
186 #elif defined(__APPLE__)
188 AccountsFile.Clear();
189 AccountsFile.Append(wxString::FromUTF8(getenv("HOME")));
190 AccountsFile.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences/accounts"));
194 AccountsFile.Clear();
195 AccountsFile.Append(wxString::FromUTF8(getenv("HOME")));
196 AccountsFile.Append(wxT("/.xestiaab/preferences/accounts"));
204 wxString GetSettingsFile()
207 // Get the preferences general settings file.
209 wxString SettingsFile;
211 #if defined(__HAIKU__)
213 #elif defined(__WIN32__)
215 SettingsFile.Clear();
216 SettingsFile.Append(wxString::FromUTF8(getenv("APPDATA")));
217 SettingsFile.Append(wxT("\\Xestia\\Address Book\\preferences\\settings"));
219 #elif defined(__APPLE__)
221 SettingsFile.Clear();
222 SettingsFile.Append(wxString::FromUTF8(getenv("HOME")));
223 SettingsFile.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences/settings"));
227 SettingsFile.Clear();
228 SettingsFile.Append(wxString::FromUTF8(getenv("HOME")));
229 SettingsFile.Append(wxT("/.xestiaab/preferences/settings"));