summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2016-09-29 18:00:35 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2016-10-11 13:56:22 +0200
commit35ec8253ad80b0381e73a8f00fd3deb2309f5fe4 (patch)
treee69a445e1d911b305cf90a386540b8e5e638e241 /comphelper
parent2da3bb5c36fd8bf635ea3ac1a3db8eb1ea91a04c (diff)
profilesafe: Add values for SecureUserConfigfeature/profilesafemode
Added default values for SecureUserConfig values to soffice.ini/rc which enable the mechanism, enable by default and set a maximum of three backups file in packed form. Added more handy flag for easy decision to add compressed/uncompressed. Change-Id: I5a624c09fec4e4278314e13fc5f693ac085d5e61
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/backupfilehelper.cxx26
1 files changed, 11 insertions, 15 deletions
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index e02a8550644e..527030693bad 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -103,7 +103,7 @@ namespace
{
sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
sal_uInt64 nBytesTransfer(0);
- sal_uInt64 nSize(getFullFileSize());
+ sal_uInt64 nSize(getPackFileSize());
// set offset in source file - when this is zero, a new file is to be added
if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
@@ -140,7 +140,7 @@ namespace
sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
sal_uInt64 nBytesTransfer(0);
- sal_uInt64 nSize(getFullFileSize());
+ sal_uInt64 nSize(getPackFileSize());
std::unique_ptr< z_stream > zstream(new z_stream);
memset(zstream.get(), 0, sizeof(*zstream));
@@ -294,21 +294,22 @@ namespace
public:
+ // create new, uncompressed entry
PackedFileEntry(
sal_uInt32 nFullFileSize,
- sal_uInt32 nOffset,
sal_uInt32 nCrc32,
FileSharedPtr& rFile,
bool bDoCompress)
: mnFullFileSize(nFullFileSize),
mnPackFileSize(nFullFileSize),
- mnOffset(nOffset),
+ mnOffset(0),
mnCrc32(nCrc32),
maFile(rFile),
mbDoCompress(bDoCompress)
{
}
+ // create entry to be loaded as header (read_header)
PackedFileEntry()
: mnFullFileSize(0),
mnPackFileSize(0),
@@ -669,7 +670,7 @@ namespace
return bRetval;
}
- bool tryPush(FileSharedPtr& rFileCandidate)
+ bool tryPush(FileSharedPtr& rFileCandidate, bool bCompress)
{
sal_uInt64 nFileSize(0);
@@ -724,19 +725,14 @@ namespace
nCrc32 = createCrc32(rFileCandidate, 0);
}
- // create a file entry for a new file. Offset is set to 0 to mark
- // the entry as new file entry
- // the compress flag decides if entries should be compressed when
- // they get written to the target package
- static bool bUseCompression(true);
-
+ // create a file entry for a new file. Offset is set automatically
+ // to 0 to mark the entry as new file entry
maPackedFileEntryVector.push_back(
PackedFileEntry(
static_cast< sal_uInt32 >(nFileSize),
- 0,
nCrc32,
rFileCandidate,
- bUseCompression));
+ bCompress));
mbChanged = true;
}
@@ -837,14 +833,14 @@ namespace comphelper
return OUString(maBase + "/." + maName + ".pack");
}
- bool BackupFileHelper::tryPush()
+ bool BackupFileHelper::tryPush(bool bCompress)
{
if (splitBaseURL() && baseFileExists())
{
PackedFile aPackedFile(getName());
FileSharedPtr aBaseFile(new osl::File(mrBaseURL));
- if (aPackedFile.tryPush(aBaseFile))
+ if (aPackedFile.tryPush(aBaseFile, bCompress))
{
// reduce to allowed number and flush
aPackedFile.tryReduceToNumBackups(mnNumBackups);