diff options
-rw-r--r-- | framework/source/services/autorecovery.cxx | 2 | ||||
-rw-r--r-- | unotools/source/ucbhelper/tempfile.cxx | 23 |
2 files changed, 13 insertions, 12 deletions
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 78129e97f7ba..4d5ff87b843b 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -3475,7 +3475,7 @@ void AutoRecovery::implts_generateNewTempURL(const OUString& sBack OUString sName(sUniqueName.makeStringAndClear()); OUString sExtension(rInfo.Extension); OUString sPath(sBackupPath); - ::utl::TempFile aTempFile(sName, true, &sExtension, &sPath); + ::utl::TempFile aTempFile(sName, true, &sExtension, &sPath, true); rInfo.NewTempURL = aTempFile.GetURL(); } diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx index bce71120f4f9..937fc4455337 100644 --- a/unotools/source/ucbhelper/tempfile.cxx +++ b/unotools/source/ucbhelper/tempfile.cxx @@ -110,7 +110,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; @@ -131,7 +131,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; } } @@ -246,18 +246,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; @@ -471,7 +472,7 @@ OUString TempFile::SetTempNameBaseDirectory( const OUString &rBaseName ) OUString TempFile::GetTempNameBaseDirectory() { - return ConstructTempDir_Impl(nullptr); + return ConstructTempDir_Impl(nullptr, false); } } |