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:
jacob1 2016-01-24 15:44:13 -05:00
parent a6f49adae2
commit 82dc5e1f71
2 changed files with 1 additions and 53 deletions

View File

@ -367,34 +367,6 @@ static void CustomApplicationMain (int argc, char **argv)
@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
char * readClipboard()
{

View File

@ -60,10 +60,6 @@ extern "C"
#else
#include <dirent.h>
#endif
#ifdef MACOSX
char * readUserPreferences();
void writeUserPreferences(const char * prefData);
#endif
}
@ -88,15 +84,9 @@ Client::Client():
}
//Read config
#ifdef MACOSX
char * prefData = readUserPreferences();
std::stringstream configFile(prefData);
free(prefData);
#else
std::ifstream configFile;
configFile.open("powder.pref", std::ios::binary);
#endif
if(configFile)
if (configFile)
{
int fsize = configFile.tellg();
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;
}
}
#ifndef MACOSX
configFile.close();
#endif
firstRun = false;
}
else
@ -930,12 +918,8 @@ void Client::RemoveListener(ClientListener * listener)
void Client::WritePrefs()
{
#ifdef MACOSX
std::stringstream configFile;
#else
std::ofstream configFile;
configFile.open("powder.pref", std::ios::trunc);
#endif
if (configFile)
{
@ -958,15 +942,7 @@ void Client::WritePrefs()
}
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();
#endif
}
}