diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-06 10:30:48 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-06 11:59:20 +0200 |
commit | 6a76b4c9c52ab9f4cd67fa9bf9468258f375dce2 (patch) | |
tree | 4a6f952fb9d1864985867ac1b6d9691e49006cfb /unotools | |
parent | 7191d6371002a881f541a9c352d2356b7b9935d0 (diff) |
simplify LocalFileHelper::GetFolderContents
Change-Id: Iaab871f0ec87fadb54fe0a2cb3b92052de9434b8
Reviewed-on: https://gerrit.libreoffice.org/39621
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/ucbhelper/localfilehelper.cxx | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/unotools/source/ucbhelper/localfilehelper.cxx b/unotools/source/ucbhelper/localfilehelper.cxx index 45668518c19e..4b0a69336a33 100644 --- a/unotools/source/ucbhelper/localfilehelper.cxx +++ b/unotools/source/ucbhelper/localfilehelper.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/ucb/XContentAccess.hpp> #include <com/sun/star/ucb/CommandAbortedException.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/sequence.hxx> #include <sal/log.hxx> #include <unotools/localfilehelper.hxx> #include <rtl/ustring.hxx> @@ -36,11 +37,9 @@ using namespace ::com::sun::star::ucb; namespace utl { -typedef ::std::vector< OUString* > StringList_Impl; - css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUString& rFolder, bool bFolder ) { - StringList_Impl* pFiles = nullptr; + std::vector< OUString > vFiles; try { ::ucbhelper::Content aCnt( @@ -63,16 +62,11 @@ css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUStri if ( xResultSet.is() ) { - pFiles = new StringList_Impl; Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); try { while ( xResultSet->next() ) - { - OUString aId = xContentAccess->queryContentIdentifierString(); - OUString* pFile = new OUString( aId ); - pFiles->push_back( pFile ); - } + vFiles.push_back( xContentAccess->queryContentIdentifierString() ); } catch( css::ucb::CommandAbortedException& ) { @@ -86,22 +80,7 @@ css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUStri { } - if ( pFiles ) - { - size_t nCount = pFiles->size(); - Sequence < OUString > aRet( nCount ); - OUString* pRet = aRet.getArray(); - for ( size_t i = 0; i < nCount; ++i ) - { - OUString* pFile = (*pFiles)[ i ]; - pRet[i] = *( pFile ); - delete pFile; - } - delete pFiles; - return aRet; - } - else - return Sequence < OUString > (); + return comphelper::containerToSequence(vFiles); } void removeTree(OUString const & url) { |