mirror of https://github.com/stella-emu/stella.git
Don't create an empty 'stella.pro' file when possible.
- Not a big deal, but several people are complaining when 'ghost' files are created - If file doesn't already exist and there is nothing to add, simply don't create one - Alternatively, we should delete the file if it's zero-sized, but that requires changes to FSNode.
This commit is contained in:
parent
501e75ccb7
commit
61828ac695
|
@ -203,11 +203,8 @@ void OSystem::saveConfig()
|
||||||
logMessage("Saving config options ...", 2);
|
logMessage("Saving config options ...", 2);
|
||||||
mySettings->save(configFile());
|
mySettings->save(configFile());
|
||||||
|
|
||||||
if(myPropSet)
|
if(myPropSet && myPropSet->save(myPropertiesFile))
|
||||||
{
|
|
||||||
logMessage("Saving properties set ...", 2);
|
logMessage("Saving properties set ...", 2);
|
||||||
myPropSet->save(myPropertiesFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -42,6 +42,11 @@ void PropertiesSet::load(const string& filename)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool PropertiesSet::save(const string& filename) const
|
bool PropertiesSet::save(const string& filename) const
|
||||||
{
|
{
|
||||||
|
// Only save properties when it won't create an empty file
|
||||||
|
FilesystemNode props(filename);
|
||||||
|
if(!props.exists() && myExternalProps.size() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
ofstream out(filename);
|
ofstream out(filename);
|
||||||
if(!out)
|
if(!out)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -58,8 +58,10 @@ class PropertiesSet
|
||||||
|
|
||||||
@param filename Full pathname of output file to use
|
@param filename Full pathname of output file to use
|
||||||
|
|
||||||
@return True on success, false on failure
|
@return True on success, false on failure or save not needed
|
||||||
Failure occurs if file couldn't be opened for writing
|
Failure occurs if file couldn't be opened for writing,
|
||||||
|
or if the file doesn't exist and a zero-byte file
|
||||||
|
would be created
|
||||||
*/
|
*/
|
||||||
bool save(const string& filename) const;
|
bool save(const string& filename) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue