From d42783465b3aca2dacdfd2a4c51eb0ea25a0e7ab Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 21 Sep 2013 16:17:15 +0100 Subject: [PATCH] Added a doNotSave option to PropertiesFile --- .../app_properties/juce_PropertiesFile.cpp | 4 +++- .../juce_data_structures/app_properties/juce_PropertiesFile.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp index 018bb585c3..a30c6e4d98 100644 --- a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp +++ b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp @@ -37,6 +37,7 @@ namespace PropertyFileConstants PropertiesFile::Options::Options() : commonToAllUsers (false), ignoreCaseOfKeyNames (false), + doNotSave (false), millisecondsBeforeSaving (3000), storageFormat (PropertiesFile::storeAsXML), processLock (nullptr) @@ -163,7 +164,8 @@ bool PropertiesFile::save() stopTimer(); - if (file == File::nonexistent + if (options.doNotSave + || file == File::nonexistent || file.isDirectory() || ! file.getParentDirectory().createDirectory()) return false; diff --git a/modules/juce_data_structures/app_properties/juce_PropertiesFile.h b/modules/juce_data_structures/app_properties/juce_PropertiesFile.h index 08f42e7f4f..0e82b13bf1 100644 --- a/modules/juce_data_structures/app_properties/juce_PropertiesFile.h +++ b/modules/juce_data_structures/app_properties/juce_PropertiesFile.h @@ -106,6 +106,9 @@ public: */ bool ignoreCaseOfKeyNames; + /** If set to true, this prevents the file from being written to disk. */ + bool doNotSave; + /** If this is zero or greater, then after a value is changed, the object will wait for this amount of time and then save the file. If this zero, the file will be written to disk immediately on being changed (which might be slow, as it'll re-write