diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-02-17 12:17:38 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-02-17 12:17:38 +0000 |
commit | 2891c8419a8e678c34617df7243ef7858126b5b7 (patch) | |
tree | cdfed088b9befdfad29d1da01453e0afae774e83 /desktop/source/app | |
parent | ad362be350230864787dbb817d85b6ce4c0e58d6 (diff) |
don't attempt to iterate through contents of a dir that doesn't exist
Diffstat (limited to 'desktop/source/app')
-rw-r--r-- | desktop/source/app/app.cxx | 95 |
1 files changed, 49 insertions, 46 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 923ff20fd4c6..dfb9879d4e4a 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 ); - - // Special treatment for "lastsychronized" file. Must not be - // copied from the bundled folder! - if ( IsDoc && aFileName.equalsAscii( pLastSyncFileName )) - bFilter = true; - } + 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; + } - if( newDstUnqPath.lastIndexOf( sal_Unicode('/') ) != newDstUnqPath.getLength()-1 ) - newDstUnqPath += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); + if( newDstUnqPath.lastIndexOf( sal_Unicode('/') ) != newDstUnqPath.getLength()-1 ) + newDstUnqPath += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); - newDstUnqPath += tit; + newDstUnqPath += tit; - if (( newSrcUnqPath != dstUnqPath ) && !bFilter ) - err = copy_bundled_recursive( newSrcUnqPath,newDstUnqPath, newTypeToCopy ); - } + if (( newSrcUnqPath != dstUnqPath ) && !bFilter ) + err = copy_bundled_recursive( newSrcUnqPath,newDstUnqPath, newTypeToCopy ); + } - if( err == osl::FileBase::E_None && next != osl::FileBase::E_NOENT ) - err = next; + if( err == osl::FileBase::E_None && next != osl::FileBase::E_NOENT ) + err = next; + + aDir.close(); + } } - aDir.close(); } return err; |