diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2020-01-20 15:52:42 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2020-01-21 10:26:53 +0100 |
commit | 6c3ab93dfcdec3f9232fa95c6f80978725db4b73 (patch) | |
tree | ea888e73c5601d1633bcce9a136225bd567eb6de /basic | |
parent | 4a25fb867f7cc0a0fc21c4079c84fadec6647ad1 (diff) |
Use deleteDirRecursively from comphelper
Change-Id: I4ad1226e5b08fc3abbf94440ea435fc9109005b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87081
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/runtime/methods.cxx | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 8d2ecb974d45..048fa1a8bb64 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -43,6 +43,7 @@ #include <i18nlangtag/lang.h> #include <rtl/string.hxx> #include <sal/log.hxx> +#include <comphelper/DirectoryHelper.hxx> #include <runtime.hxx> #include <sbunoobj.hxx> @@ -638,8 +639,6 @@ void SbRtl_MkDir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite) } -// In OSL only empty directories can be deleted -// so we have to delete all files recursively static void implRemoveDirRecursive( const OUString& aDirPath ) { DirectoryItem aItem; @@ -664,40 +663,9 @@ static void implRemoveDirRecursive( const OUString& aDirPath ) StarBASIC::Error( ERRCODE_BASIC_PATH_NOT_FOUND ); return; } - - for( ;; ) - { - DirectoryItem aItem2; - nRet = aDir.getNextItem( aItem2 ); - if( nRet != FileBase::E_None ) - { - break; - } - // Handle flags - FileStatus aFileStatus2( osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL ); - nRet = aItem2.getFileStatus( aFileStatus2 ); - if( nRet != FileBase::E_None ) - { - SAL_WARN("basic", "getFileStatus failed"); - continue; - } - OUString aPath = aFileStatus2.getFileURL(); - - // Directory? - FileStatus::Type aType2 = aFileStatus2.getFileType(); - bool bFolder2 = isFolder( aType2 ); - if( bFolder2 ) - { - implRemoveDirRecursive( aPath ); - } - else - { - File::remove( aPath ); - } - } aDir.close(); - Directory::remove( aDirPath ); + comphelper::DirectoryHelper::deleteDirRecursively(aDirPath); } |