summaryrefslogtreecommitdiff
path: root/include/comphelper/backupfilehelper.hxx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2016-09-23 18:21:54 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2016-10-11 13:56:22 +0200
commit7db23b6346ff601449e8017fd585e9fbc295ed34 (patch)
tree696b232a1a372d13bbaf605586a9c9f4637744d2 /include/comphelper/backupfilehelper.hxx
parent9fa4eff9be5e440099517a522a83e20debaf2955 (diff)
profilesafe: Collect copies in single *.pack file
Enhanced helper classes for BackupFileHelper to allow writing a stack of rescued last valid configuration files to a single file package. Added configuration values for enabling this and defining the number of entries, added max entry limitation. Using FileSize and CRC32 now to dectect if config file did change. To make this work I added sorting to writing the configuration so that with no change the same configuration file is written. Use std::vector for better mem performance for sorting, defined static const for buffer size of manipulation, prepare inflate/deflate usages. Fixes to setPos, warnings Change-Id: Ib286e2a3f25b0085a1e3ae4f50c9ff1ff3a5dcf5
Diffstat (limited to 'include/comphelper/backupfilehelper.hxx')
-rw-r--r--include/comphelper/backupfilehelper.hxx38
1 files changed, 23 insertions, 15 deletions
diff --git a/include/comphelper/backupfilehelper.hxx b/include/comphelper/backupfilehelper.hxx
index f407d2b8815c..2c6cc25ded23 100644
--- a/include/comphelper/backupfilehelper.hxx
+++ b/include/comphelper/backupfilehelper.hxx
@@ -15,6 +15,7 @@
#include <comphelper/comphelperdllapi.h>
#include <rtl/ustring.hxx>
#include <osl/file.hxx>
+#include <memory>
namespace comphelper
{
@@ -45,12 +46,11 @@ namespace comphelper
{
private:
// internal data
- const OUString& mrBaseURL;
- sal_uInt16 mnNumBackups;
- OUString maBase;
- OUString maExt;
- osl::File maBaseFile;
- bool mbBaseFileIsOpen;
+ const OUString& mrBaseURL;
+ sal_uInt16 mnNumBackups;
+ OUString maBase;
+ OUString maName;
+ OUString maExt;
// internal flag if _exit() was called already - a hint to evtl.
// not create copies of potentially not well-defined data. This
@@ -67,6 +67,10 @@ namespace comphelper
public:
/** Constructor to handle Backups of the given file
*
+ * @param rxContext
+ * ComponentContext to use internally; needs to be handed
+ * over due to usages after DeInit() and thus no access
+ * anymore using comphelper::getProcessComponentContext()
* @param rBaseURL
* URL to an existing file that needs to be backed up
*
@@ -77,12 +81,21 @@ namespace comphelper
* It is used in tryPush() and tryPop() calls to cleanup/
* reduce the number of existing backups
*/
- BackupFileHelper(const OUString& rBaseURL, sal_uInt16 nNumBackups = 5);
+ BackupFileHelper(
+ const OUString& rBaseURL,
+ sal_uInt16 nNumBackups = 5);
- // allow to set flag when app had to call _exit()
+ // allow to set static global flag when app had to call _exit()
static void setExitWasCalled();
static bool getExitWasCalled();
+ // static helper to read config values - these are derived from
+ // soffice.ini due to cui not being available in all cases. The
+ // boolean SecureUserConfig is returned.
+ // Default for SecureUserConfig is false
+ // Default for SecureUserConfigNumCopies is 0 (zero)
+ static bool getSecureUserConfig(sal_uInt16& rnSecureUserConfigNumCopies);
+
/** tries to create a new backup, if there is none yet, or if the
* last differs from the base file. It will then put a new verion
* on the 'stack' of copies and evtl. delete the oldest backup.
@@ -113,14 +126,9 @@ namespace comphelper
private:
// internal helper methods
- rtl::OUString getName(sal_uInt16 n);
- bool firstExists();
- void pop();
- void push();
- bool isDifferentOrNew();
- bool equalsBase(osl::File& rLastFile);
bool splitBaseURL();
- bool baseFileOpen();
+ bool baseFileExists();
+ rtl::OUString getName();
};
}