summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-04-17 09:03:12 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-04-17 12:10:52 +0200
commit8cb04bde0aeea1bd0f324ecf989af015356da285 (patch)
tree17815e2738e5d3e9cdfb9287f265bbf8a4d2418f /unotools
parent034e9eee277d5123258fedc1861edf49c99159ef (diff)
Fix autorecovery using wrong directory
Autorecovery should save in the user profile in the "backup" directory. However, when that directory did not exist, the temp directory was used instead. Fix this, and create the requested directory if it did not exist. Change-Id: Ie298855a740932bc6e6c9f62d4b4bf1b52b80c58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92402 Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/ucbhelper/tempfile.cxx23
1 files changed, 12 insertions, 11 deletions
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx
index f6d66bdc33b6..d6580755c9c9 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -111,7 +111,7 @@ static bool ensuredir( const OUString& rUnqPath )
return bSuccess;
}
-static OUString ConstructTempDir_Impl( const OUString* pParent )
+static OUString ConstructTempDir_Impl( const OUString* pParent, bool bCreateParentDirs )
{
OUString aName;
@@ -132,7 +132,7 @@ static OUString ConstructTempDir_Impl( const OUString* pParent )
if ( aRet[i-1] == '/' )
i--;
- if ( DirectoryItem::get( aRet.copy(0, i), aItem ) == FileBase::E_None )
+ if ( DirectoryItem::get( aRet.copy(0, i), aItem ) == FileBase::E_None || bCreateParentDirs )
aName = aRet;
}
}
@@ -251,18 +251,19 @@ static OUString lcl_createName(
const OUString* pParent, bool bDirectory, bool bKeep, bool bLock,
bool bCreateParentDirs )
{
- OUString aName = ConstructTempDir_Impl( pParent );
+ OUString aName = ConstructTempDir_Impl( pParent, bCreateParentDirs );
if ( bCreateParentDirs )
{
sal_Int32 nOffset = rLeadingChars.lastIndexOf("/");
+ OUString aDirName;
if (-1 != nOffset)
- {
- OUString aDirName = aName + rLeadingChars.copy( 0, nOffset );
- TempDirCreatedObserver observer;
- FileBase::RC err = Directory::createPath( aDirName, &observer );
- if ( err != FileBase::E_None && err != FileBase::E_EXIST )
- return OUString();
- }
+ aDirName = aName + rLeadingChars.copy( 0, nOffset );
+ else
+ aDirName = aName;
+ TempDirCreatedObserver observer;
+ FileBase::RC err = Directory::createPath( aDirName, &observer );
+ if ( err != FileBase::E_None && err != FileBase::E_EXIST )
+ return OUString();
}
aName += rLeadingChars;
@@ -475,7 +476,7 @@ OUString TempFile::SetTempNameBaseDirectory( const OUString &rBaseName )
OUString TempFile::GetTempNameBaseDirectory()
{
- return ConstructTempDir_Impl(nullptr);
+ return ConstructTempDir_Impl(nullptr, false);
}
}