[Libreoffice-commits] .: desktop/source
Caolán McNamara
caolan at kemper.freedesktop.org
Thu Feb 17 05:27:28 PST 2011
desktop/source/app/app.cxx | 93 +++++++++++++++++++++++----------------------
1 file changed, 48 insertions(+), 45 deletions(-)
New commits:
commit 7fe1bf4aa00ab65fa05e0f318f9e52a28569bf8b
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Feb 17 12:17:38 2011 +0000
don't attempt to iterate through contents of a dir that doesn't exist
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 87d7c00..c601923 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -572,64 +572,67 @@ throw()
}
else if( TypeToCopy == +1 ) // Folder
{
- osl::Directory aDir( srcUnqPath );
- aDir.open();
-
err = osl::Directory::create( dstUnqPath );
osl::FileBase::RC next = err;
- if( err == osl::FileBase::E_None ||
- err == osl::FileBase::E_EXIST )
+ if( err == osl::FileBase::E_None || err == osl::FileBase::E_EXIST )
{
err = osl::FileBase::E_None;
- sal_Int32 n_Mask = FileStatusMask_FileURL | FileStatusMask_FileName | FileStatusMask_Type;
-
- osl::DirectoryItem aDirItem;
- while( err == osl::FileBase::E_None && ( next = aDir.getNextItem( aDirItem ) ) == osl::FileBase::E_None )
+ osl::Directory aDir( srcUnqPath );
+ if (aDir.open() == osl::FileBase::E_None)
{
- sal_Bool IsDoc = false;
- sal_Bool bFilter = false;
- osl::FileStatus aFileStatus( n_Mask );
- aDirItem.getFileStatus( aFileStatus );
- if( aFileStatus.isValid( FileStatusMask_Type ) )
- IsDoc = aFileStatus.getFileType() == osl::FileStatus::Regular;
-
- // Getting the information for the next recursive copy
- sal_Int32 newTypeToCopy = IsDoc ? -1 : +1;
-
- rtl::OUString newSrcUnqPath;
- if( aFileStatus.isValid( FileStatusMask_FileURL ) )
- newSrcUnqPath = aFileStatus.getFileURL();
-
- rtl::OUString newDstUnqPath = dstUnqPath;
- rtl::OUString tit;
- if( aFileStatus.isValid( FileStatusMask_FileName ) )
+ sal_Int32 n_Mask = FileStatusMask_FileURL |
+ FileStatusMask_FileName |
+ FileStatusMask_Type;
+
+ osl::DirectoryItem aDirItem;
+ while( err == osl::FileBase::E_None && ( next = aDir.getNextItem( aDirItem ) ) == osl::FileBase::E_None )
{
- ::rtl::OUString aFileName = aFileStatus.getFileName();
- tit = rtl::Uri::encode( aFileName,
- rtl_UriCharClassPchar,
- rtl_UriEncodeIgnoreEscapes,
- RTL_TEXTENCODING_UTF8 );
+ sal_Bool IsDoc = false;
+ sal_Bool bFilter = false;
+ osl::FileStatus aFileStatus( n_Mask );
+ aDirItem.getFileStatus( aFileStatus );
+ if( aFileStatus.isValid( FileStatusMask_Type ) )
+ IsDoc = aFileStatus.getFileType() == osl::FileStatus::Regular;
+
+ // Getting the information for the next recursive copy
+ sal_Int32 newTypeToCopy = IsDoc ? -1 : +1;
+
+ rtl::OUString newSrcUnqPath;
+ if( aFileStatus.isValid( FileStatusMask_FileURL ) )
+ newSrcUnqPath = aFileStatus.getFileURL();
+
+ rtl::OUString newDstUnqPath = dstUnqPath;
+ rtl::OUString tit;
+ if( aFileStatus.isValid( FileStatusMask_FileName ) )
+ {
+ ::rtl::OUString aFileName = aFileStatus.getFileName();
+ tit = rtl::Uri::encode( aFileName,
+ rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8 );
+
+ // Special treatment for "lastsychronized" file. Must not be
+ // copied from the bundled folder!
+ if ( IsDoc && aFileName.equalsAscii( pLastSyncFileName ))
+ bFilter = true;
+ }
- // Special treatment for "lastsychronized" file. Must not be
- // copied from the bundled folder!
- if ( IsDoc && aFileName.equalsAscii( pLastSyncFileName ))
- bFilter = true;
+ if( newDstUnqPath.lastIndexOf( sal_Unicode('/') ) != newDstUnqPath.getLength()-1 )
+ newDstUnqPath += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+
+ newDstUnqPath += tit;
+
+ if (( newSrcUnqPath != dstUnqPath ) && !bFilter )
+ err = copy_bundled_recursive( newSrcUnqPath,newDstUnqPath, newTypeToCopy );
}
-
- if( newDstUnqPath.lastIndexOf( sal_Unicode('/') ) != newDstUnqPath.getLength()-1 )
- newDstUnqPath += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
- newDstUnqPath += tit;
+ if( err == osl::FileBase::E_None && next != osl::FileBase::E_NOENT )
+ err = next;
- if (( newSrcUnqPath != dstUnqPath ) && !bFilter )
- err = copy_bundled_recursive( newSrcUnqPath,newDstUnqPath, newTypeToCopy );
+ aDir.close();
}
-
- if( err == osl::FileBase::E_None && next != osl::FileBase::E_NOENT )
- err = next;
}
- aDir.close();
}
return err;
More information about the Libreoffice-commits
mailing list