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>
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#include <com/sun/star/ucb/XContentAccess.hpp>
|
#include <com/sun/star/ucb/XContentAccess.hpp>
|
||||||
#include <com/sun/star/ucb/CommandAbortedException.hpp>
|
#include <com/sun/star/ucb/CommandAbortedException.hpp>
|
||||||
#include <comphelper/processfactory.hxx>
|
#include <comphelper/processfactory.hxx>
|
||||||
|
#include <comphelper/sequence.hxx>
|
||||||
#include <sal/log.hxx>
|
#include <sal/log.hxx>
|
||||||
#include <unotools/localfilehelper.hxx>
|
#include <unotools/localfilehelper.hxx>
|
||||||
#include <rtl/ustring.hxx>
|
#include <rtl/ustring.hxx>
|
||||||
@@ -36,11 +37,9 @@ using namespace ::com::sun::star::ucb;
|
|||||||
namespace utl
|
namespace utl
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef ::std::vector< OUString* > StringList_Impl;
|
|
||||||
|
|
||||||
css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUString& rFolder, bool bFolder )
|
css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUString& rFolder, bool bFolder )
|
||||||
{
|
{
|
||||||
StringList_Impl* pFiles = nullptr;
|
std::vector< OUString > vFiles;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
::ucbhelper::Content aCnt(
|
::ucbhelper::Content aCnt(
|
||||||
@@ -63,16 +62,11 @@ css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUStri
|
|||||||
|
|
||||||
if ( xResultSet.is() )
|
if ( xResultSet.is() )
|
||||||
{
|
{
|
||||||
pFiles = new StringList_Impl;
|
|
||||||
Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
|
Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while ( xResultSet->next() )
|
while ( xResultSet->next() )
|
||||||
{
|
vFiles.push_back( xContentAccess->queryContentIdentifierString() );
|
||||||
OUString aId = xContentAccess->queryContentIdentifierString();
|
|
||||||
OUString* pFile = new OUString( aId );
|
|
||||||
pFiles->push_back( pFile );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch( css::ucb::CommandAbortedException& )
|
catch( css::ucb::CommandAbortedException& )
|
||||||
{
|
{
|
||||||
@@ -86,22 +80,7 @@ css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUStri
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pFiles )
|
return comphelper::containerToSequence(vFiles);
|
||||||
{
|
|
||||||
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 > ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeTree(OUString const & url) {
|
void removeTree(OUString const & url) {
|
||||||
|
Reference in New Issue
Block a user