don't save powder.pref in a .plist file on OS X
untested, but it didn't make sense how we were doing it anyway. Also, it was spelled wrong
This commit is contained in:
parent
a6f49adae2
commit
82dc5e1f71
@ -367,34 +367,6 @@ static void CustomApplicationMain (int argc, char **argv)
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
char * readUserPreferences()
|
|
||||||
{
|
|
||||||
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
|
||||||
|
|
||||||
NSString *prefDataNSString = [prefs stringForKey:@"powder.pref"];
|
|
||||||
const char *prefData = [prefDataNSString UTF8String];
|
|
||||||
if(prefData == NULL)
|
|
||||||
prefData = "";
|
|
||||||
|
|
||||||
char *prefDataCopy = calloc([prefDataNSString length]+1, 1);
|
|
||||||
SDL_strlcpy(prefDataCopy, prefData, [prefDataNSString length]+1);
|
|
||||||
|
|
||||||
[prefDataNSString release];
|
|
||||||
|
|
||||||
return prefDataCopy;
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeUserPreferences(const char * prefData)
|
|
||||||
{
|
|
||||||
NSString *prefDataNSString = [NSString stringWithUTF8String:prefData];
|
|
||||||
|
|
||||||
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
|
||||||
[prefs setObject:prefDataNSString forKey:@"powder.pref"];
|
|
||||||
[prefs synchronize];
|
|
||||||
|
|
||||||
[prefDataNSString release];
|
|
||||||
}
|
|
||||||
|
|
||||||
//doesn't work on OS X 10.5 or below
|
//doesn't work on OS X 10.5 or below
|
||||||
char * readClipboard()
|
char * readClipboard()
|
||||||
{
|
{
|
||||||
|
@ -60,10 +60,6 @@ extern "C"
|
|||||||
#else
|
#else
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef MACOSX
|
|
||||||
char * readUserPreferences();
|
|
||||||
void writeUserPreferences(const char * prefData);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -88,15 +84,9 @@ Client::Client():
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Read config
|
//Read config
|
||||||
#ifdef MACOSX
|
|
||||||
char * prefData = readUserPreferences();
|
|
||||||
std::stringstream configFile(prefData);
|
|
||||||
free(prefData);
|
|
||||||
#else
|
|
||||||
std::ifstream configFile;
|
std::ifstream configFile;
|
||||||
configFile.open("powder.pref", std::ios::binary);
|
configFile.open("powder.pref", std::ios::binary);
|
||||||
#endif
|
if (configFile)
|
||||||
if(configFile)
|
|
||||||
{
|
{
|
||||||
int fsize = configFile.tellg();
|
int fsize = configFile.tellg();
|
||||||
configFile.seekg(0, std::ios::end);
|
configFile.seekg(0, std::ios::end);
|
||||||
@ -126,9 +116,7 @@ Client::Client():
|
|||||||
std::cerr << "Error: Could not read data from prefs: " << e.what() << std::endl;
|
std::cerr << "Error: Could not read data from prefs: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef MACOSX
|
|
||||||
configFile.close();
|
configFile.close();
|
||||||
#endif
|
|
||||||
firstRun = false;
|
firstRun = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -930,12 +918,8 @@ void Client::RemoveListener(ClientListener * listener)
|
|||||||
|
|
||||||
void Client::WritePrefs()
|
void Client::WritePrefs()
|
||||||
{
|
{
|
||||||
#ifdef MACOSX
|
|
||||||
std::stringstream configFile;
|
|
||||||
#else
|
|
||||||
std::ofstream configFile;
|
std::ofstream configFile;
|
||||||
configFile.open("powder.pref", std::ios::trunc);
|
configFile.open("powder.pref", std::ios::trunc);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (configFile)
|
if (configFile)
|
||||||
{
|
{
|
||||||
@ -958,15 +942,7 @@ void Client::WritePrefs()
|
|||||||
}
|
}
|
||||||
json::Writer::Write(configDocument, configFile);
|
json::Writer::Write(configDocument, configFile);
|
||||||
|
|
||||||
#ifdef MACOSX
|
|
||||||
std::string prefString = configFile.str();
|
|
||||||
|
|
||||||
char prefData[prefString.length()+1];
|
|
||||||
std::strcpy(prefData, prefString.c_str());
|
|
||||||
writeUserPreferences(prefData);
|
|
||||||
#else
|
|
||||||
configFile.close();
|
configFile.close();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user