Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
macOS: Implemented macOS specific paths and variable name fixes
[xestiacalendar/.git] / source / common / dirs.cpp
1 // dirs.cpp - Directory subroutines.
2 //
3 // (c) 2012-2017 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar. Originally from Xestia Address Book.
6 //
7 // Xestia Calendar 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.
10 //
11 // Xestia Calendar 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.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include <wx/wx.h>
21 wxString GetUserDir()
22 {
23     
24         // Get the user directory.
25     
26         wxString userDir;
27     
28 #if defined(__HAIKU__)
29         
30 #elif defined(__WIN32__)
31     
32         userDir.Clear();
33         userDir.Append(wxString::FromUTF8(getenv("APPDATA")));
34         userDir.Append(wxT("\\Xestia\\Calendar\\"));
35     
36 #elif defined(__APPLE__)
37     
38         userDir.Clear();
39         userDir.Append(wxString::FromUTF8(getenv("HOME")));
40         userDir.Append(wxT("/Library/Preferences/Xestia/Calendar/"));
41     
42 #else
43     
44         userDir.Clear();
45         userDir.Append(wxString::FromUTF8(getenv("HOME")));
46         userDir.Append(wxT("/.xestiacal/"));
47     
48 #endif
49     
50         return userDir;
51     
52 }
54 wxString GetUserPrefDir()
55 {
56     
57         // Get the user preferences directory.
58     
59         wxString userPrefDir;
60     
61 #if defined(__HAIKU__)
62         
63 #elif defined(__WIN32__)
64     
65         userPrefDir.Clear();
66         userPrefDir.Append(wxString::FromUTF8(getenv("APPDATA")));
67         userPrefDir.Append(wxT("\\Xestia\\Calendar\\preferences\\"));
68     
69 #elif defined(__APPLE__)
70     
71         userPrefDir.Clear();
72         userPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
73         userPrefDir.Append(wxT("/Library/Preferences/Xestia/Calendar/preferences/"));
74     
75 #else
76     
77         userPrefDir.Clear();
78         userPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
79         userPrefDir.Append(wxT("/.xestiacal/preferences/"));
80     
81 #endif
82     
83         return userPrefDir;
84     
85 }
87 wxString GetAccountDir(wxString accName, bool serverCert)
88 {
89     
90         // Get the account directory.
91     
92         wxString accountDir;
93     
94 #if defined(__HAIKU__)
95     
96 #elif defined(__WIN32__)
97     
98         accountDir.Clear();
99         accountDir.Append(wxString::FromUTF8(getenv("APPDATA")));
100         accountDir.Append(wxT("\\Xestia\\Calendar\\accounts\\"));
101         accountDir.Append(accName);
102         accountDir.Append(wxT("\\"));
103     
104         if (serverCert == TRUE){
105                 accountDir.Append(wxT("server.crt"));
106         }
107     
108 #elif defined(__APPLE__)
109     
110         accountDir.Clear();
111         accountDir.Append(wxString::FromUTF8(getenv("HOME")));
112         accountDir.Append(wxT("/Library/Preferences/Xestia/Calendar/accounts/"));
113         accountDir.Append(accName);
114         accountDir.Append(wxT("/"));
115     
116         if (serverCert == TRUE){
117                 accountDir.Append(wxT("server.crt"));
118         }
119     
120 #else
121     
122         accountDir.Clear();
123         accountDir.Append(wxString::FromUTF8(getenv("HOME")));
124         accountDir.Append(wxT("/.xestiacal/accounts/"));
125         accountDir.Append(accName);
126         accountDir.Append(wxT("/"));
127     
128         if (serverCert == TRUE){
129                 accountDir.Append(wxT("server.crt"));
130         }
131     
132 #endif
133     
134         return accountDir;
135     
138 std::string GetAccountDir(std::string accName, bool serverCert)
140     
141         // Get the account directory.
142     
143         std::string accountDir;
144     
145 #if defined(__HAIKU__)
146     
147 #elif defined(__WIN32__)
148     
149         accountDir.clear();
150         accountDir.append(getenv("APPDATA"));
151         accountDir.append("\\Xestia\\Calendar\\accounts\\");
152         accountDir.append(accName);
153         accountDir.append("\\");
154     
155         if (serverCert == true){
156                 accountDir.append("server.crt");
157         }
158     
159 #elif defined(__APPLE__)
160     
161         accountDir.clear();
162         accountDir.append(getenv("HOME"));
163         accountDir.append("/Library/Preferences/Xestia/Calendar/accounts/");
164         accountDir.append(accName);
165         accountDir.append("/");
166     
167         if (serverCert == true){
168                 accountDir.append("server.crt");
169         }
170     
171 #else
172     
173         accountDir.clear();
174         accountDir.append(getenv("HOME"));
175         accountDir.append("/.xestiacal/accounts/");
176         accountDir.append(accName);
177         accountDir.append("/");
178     
179         if (serverCert == true){
180                 accountDir.append("server.crt");
181         }
183 #endif
184     
185         return accountDir;
186     
189 wxString GetAccountsFile()
191     
192         // Get the accounts preferences file.
193     
194         wxString accountsFile;
195     
196 #if defined(__HAIKU__)
197     
198 #elif defined(__WIN32__)
199     
200         accountsFile.Clear();
201         accountsFile.Append(wxString::FromUTF8(getenv("APPDATA")));
202         accountsFile.Append(wxT("\\Xestia\\Calendar\\preferences\\accounts"));
203     
204 #elif defined(__APPLE__)
205     
206         accountsFile.Clear();
207         accountsFile.Append(wxString::FromUTF8(getenv("HOME")));
208         accountsFile.Append(wxT("/Library/Preferences/Xestia/Calendar/preferences/accounts"));
209     
210 #else
211     
212         accountsFile.Clear();
213         accountsFile.Append(wxString::FromUTF8(getenv("HOME")));
214         accountsFile.Append(wxT("/.xestiacal/preferences/accounts"));
215     
216 #endif
217     
218         return accountsFile;
219     
222 wxString GetSettingsFile()
224     
225         // Get the preferences general settings file.
226     
227         wxString settingsFile;
228     
229 #if defined(__HAIKU__)
230     
231 #elif defined(__WIN32__)
232     
233         settingsFile.Clear();
234         settingsFile.Append(wxString::FromUTF8(getenv("APPDATA")));
235         settingsFile.Append(wxT("\\Xestia\\Calendar\\preferences\\settings"));
236     
237 #elif defined(__APPLE__)
238     
239         settingsFile.Clear();
240         settingsFile.Append(wxString::FromUTF8(getenv("HOME")));
241         settingsFile.Append(wxT("/Library/Preferences/Xestia/Calendar/preferences/settings"));
242     
243 #else
244     
245         settingsFile.Clear();
246         settingsFile.Append(wxString::FromUTF8(getenv("HOME")));
247         settingsFile.Append(wxT("/.xestiacal/preferences/settings"));
248     
249 #endif
250     
251         return settingsFile;
252     
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy