diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 8db2d6ac8..07aa54b50 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -203,11 +203,8 @@ void OSystem::saveConfig() logMessage("Saving config options ...", 2); mySettings->save(configFile()); - if(myPropSet) - { + if(myPropSet && myPropSet->save(myPropertiesFile)) logMessage("Saving properties set ...", 2); - myPropSet->save(myPropertiesFile); - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/PropsSet.cxx b/src/emucore/PropsSet.cxx index 1479c9b5b..0ab255043 100644 --- a/src/emucore/PropsSet.cxx +++ b/src/emucore/PropsSet.cxx @@ -42,6 +42,11 @@ void PropertiesSet::load(const string& filename) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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); if(!out) return false; diff --git a/src/emucore/PropsSet.hxx b/src/emucore/PropsSet.hxx index 224d2bfc8..4d5f2ee37 100644 --- a/src/emucore/PropsSet.hxx +++ b/src/emucore/PropsSet.hxx @@ -58,8 +58,10 @@ class PropertiesSet @param filename Full pathname of output file to use - @return True on success, false on failure - Failure occurs if file couldn't be opened for writing + @return True on success, false on failure or save not needed + 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;