16 |
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
17 |
*/ |
*/ |
18 |
#include "enigma.hh" |
#include "enigma.hh" |
19 |
|
#ifdef __MINGW32__ |
20 |
|
#include <windows.h> |
21 |
|
#include <shlobj.h> |
22 |
|
#endif |
23 |
#include "lua.hh" |
#include "lua.hh" |
24 |
#include "options.hh" |
#include "options.hh" |
25 |
#include "system.hh" |
#include "system.hh" |
134 |
return enigma::FindDataFile ("enigma_conf.lua"); |
return enigma::FindDataFile ("enigma_conf.lua"); |
135 |
} |
} |
136 |
|
|
137 |
|
#ifdef __MINGW32__ |
138 |
|
|
139 |
|
static string |
140 |
|
Windows_ConfigurationFileName() |
141 |
|
{ |
142 |
|
TCHAR szPath[MAX_PATH]; |
143 |
|
if ( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_APPDATA, |
144 |
|
NULL, 0, szPath))) |
145 |
|
{ |
146 |
|
return string(szPath) + "/enigmarc.lua"; |
147 |
|
} |
148 |
|
|
149 |
|
// Fallback to MyDocuments |
150 |
|
if ( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_PERSONAL, |
151 |
|
NULL, 0, szPath))) |
152 |
|
{ |
153 |
|
return string(szPath) + "/enigmarc.lua"; |
154 |
|
} |
155 |
|
|
156 |
|
return Personal_ConfigurationFileName(); |
157 |
|
} |
158 |
|
|
159 |
|
#endif |
160 |
|
|
161 |
|
|
162 |
bool |
bool |
163 |
options::Save () |
options::Save () |
164 |
{ |
{ |
165 |
|
#ifdef __MINGW32__ |
166 |
|
string fname = Windows_ConfigurationFileName(); |
167 |
|
#else |
168 |
string fname = Personal_ConfigurationFileName(); |
string fname = Personal_ConfigurationFileName(); |
169 |
|
#endif |
170 |
FILE *fp = fopen(fname.c_str(), "wt"); |
FILE *fp = fopen(fname.c_str(), "wt"); |
171 |
|
|
172 |
if (fp) { |
if (fp) { |
220 |
fname = Personal_ConfigurationFileName(); |
fname = Personal_ConfigurationFileName(); |
221 |
error |= load_from_file (fname.c_str()); |
error |= load_from_file (fname.c_str()); |
222 |
|
|
223 |
|
#ifdef __MINGW32__ |
224 |
|
fname = Windows_ConfigurationFileName(); |
225 |
|
error |= load_from_file (fname.c_str()); |
226 |
|
#endif |
227 |
|
|
228 |
return error; |
return error; |
229 |
} |
} |
230 |
|
|