Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added existing common code from Xestia Address Book
[xestiacalendar/.git] / source / common / dirs.cpp
1 // dirs.cpp - Directory subroutines.
2 //
3 // (c) 2012-2015 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