Kaydet (Commit) ecdd9d1a authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: fdo#65501 ensure configured backup dir exists before using it

the ucb stuff is the most god awful painful api ever

Change-Id: I491d2cb9b7d5d37723b32f0a26a22a09c16bc02e
üst ee5c49c9
...@@ -2123,6 +2123,25 @@ void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalCont ...@@ -2123,6 +2123,25 @@ void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalCont
aTransactTemp.EnableKillingFile( true ); aTransactTemp.EnableKillingFile( true );
} }
bool ensureFolder(
uno::Reference< uno::XComponentContext > xCtx,
uno::Reference< ucb::XCommandEnvironment > xEnv,
const OUString& rFolder, ucbhelper::Content & result)
{
INetURLObject aURL( rFolder );
OUString aTitle = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
aURL.removeSegment();
::ucbhelper::Content aParent;
if ( ::ucbhelper::Content::create( aURL.GetMainURL( INetURLObject::NO_DECODE ),
xEnv, xCtx, aParent ) )
{
return ::utl::UCBContentHelper::MakeFolder(aParent, aTitle, result);
}
return false;
}
//------------------------------------------------------------------ //------------------------------------------------------------------
void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent ) void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent )
{ {
...@@ -2136,9 +2155,13 @@ void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalCont ...@@ -2136,9 +2155,13 @@ void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalCont
sal_Int32 nPrefixLen = aFileName.lastIndexOf( '.' ); sal_Int32 nPrefixLen = aFileName.lastIndexOf( '.' );
String aPrefix = ( nPrefixLen == -1 ) ? aFileName : aFileName.copy( 0, nPrefixLen ); String aPrefix = ( nPrefixLen == -1 ) ? aFileName : aFileName.copy( 0, nPrefixLen );
String aExtension = ( nPrefixLen == -1 ) ? String() : String(aFileName.copy( nPrefixLen )); String aExtension = ( nPrefixLen == -1 ) ? String() : String(aFileName.copy( nPrefixLen ));
String aBakDir = SvtPathOptions().GetBackupPath(); String aBakDir = SvtPathOptions().GetBackupPath();
DoInternalBackup_Impl( aOriginalContent, aPrefix, aExtension, aBakDir ); // create content for the parent folder ( = backup folder )
::ucbhelper::Content aContent;
Reference < ::com::sun::star::ucb::XCommandEnvironment > xEnv;
if( ensureFolder(comphelper::getProcessComponentContext(), xEnv, aBakDir, aContent) )
DoInternalBackup_Impl( aOriginalContent, aPrefix, aExtension, aBakDir );
if ( pImp->m_aBackupURL.isEmpty() ) if ( pImp->m_aBackupURL.isEmpty() )
{ {
...@@ -2177,7 +2200,7 @@ void SfxMedium::DoBackup_Impl() ...@@ -2177,7 +2200,7 @@ void SfxMedium::DoBackup_Impl()
// create content for the parent folder ( = backup folder ) // create content for the parent folder ( = backup folder )
::ucbhelper::Content aContent; ::ucbhelper::Content aContent;
Reference < ::com::sun::star::ucb::XCommandEnvironment > xEnv; Reference < ::com::sun::star::ucb::XCommandEnvironment > xEnv;
if( ::ucbhelper::Content::create( aBakDir, xEnv, comphelper::getProcessComponentContext(), aContent ) ) if( ensureFolder(comphelper::getProcessComponentContext(), xEnv, aBakDir, aContent) )
{ {
// save as ".bak" file // save as ".bak" file
INetURLObject aDest( aBakDir ); INetURLObject aDest( aBakDir );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment