2001-01-16 14:28:25 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 08:51:39 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-01-16 14:28:25 +00:00
|
|
|
*
|
2005-09-09 08:51:39 +00:00
|
|
|
* $RCSfile: ucbhelper.cxx,v $
|
2001-01-16 14:28:25 +00:00
|
|
|
*
|
2005-09-09 08:51:39 +00:00
|
|
|
* $Revision: 1.19 $
|
2001-01-16 14:28:25 +00:00
|
|
|
*
|
2005-09-09 08:51:39 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2005-09-09 09:51:39 $
|
2001-01-16 14:28:25 +00:00
|
|
|
*
|
2005-09-09 08:51:39 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2001-01-16 14:28:25 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 08:51:39 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2001-01-16 14:28:25 +00:00
|
|
|
*
|
2005-09-09 08:51:39 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2001-01-16 14:28:25 +00:00
|
|
|
*
|
2005-09-09 08:51:39 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2001-01-16 14:28:25 +00:00
|
|
|
*
|
2005-09-09 08:51:39 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2001-01-16 14:28:25 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include "unotools/ucbhelper.hxx"
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XResultSet.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XRow.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_COMMANDABORTEDEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/ucb/CommandAbortedException.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_ILLEGALIDENTIFIEREXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/ucb/IllegalIdentifierException.hpp>
|
|
|
|
#endif
|
2002-12-09 15:29:09 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_NAMECLASHEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/ucb/NameClashException.hpp>
|
|
|
|
#endif
|
2001-01-16 14:28:25 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_NAMECLASH_HPP_
|
|
|
|
#include <com/sun/star/ucb/NameClash.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_NUMBEREDSORTINGINFO_HPP_
|
|
|
|
#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_TRANSFERINFO_HPP_
|
|
|
|
#include <com/sun/star/ucb/TransferInfo.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_XANYCOMPAREFACTORY_HPP_
|
|
|
|
#include <com/sun/star/ucb/XAnyCompareFactory.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_XCOMMANDINFO_HPP_
|
|
|
|
#include <com/sun/star/ucb/XCommandInfo.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_HPP_
|
|
|
|
#include <com/sun/star/ucb/XContentAccess.hpp>
|
|
|
|
#endif
|
2001-06-07 06:40:08 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_CONTENTINFOATTRIBUTE_HPP_
|
|
|
|
#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_XCONTENTCREATOR_HPP_
|
|
|
|
#include <com/sun/star/ucb/XContentCreator.hpp>
|
|
|
|
#endif
|
2001-01-16 14:28:25 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_XDYNAMICRESULTSET_HPP_
|
|
|
|
#include <com/sun/star/ucb/XDynamicResultSet.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UCB_XSORTEDDYNAMICRESULTSETFACTORY_HPP_
|
|
|
|
#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
|
|
|
|
#include <com/sun/star/util/DateTime.hpp>
|
|
|
|
#endif
|
2001-06-07 06:40:08 +00:00
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
|
|
|
|
#include <com/sun/star/container/XChild.hpp>
|
|
|
|
#endif
|
2001-11-27 10:03:52 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIODEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/ucb/InteractiveIOException.hpp>
|
|
|
|
#endif
|
2001-12-11 14:01:22 +00:00
|
|
|
#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
|
|
|
|
#include <com/sun/star/task/XInteractionHandler.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX
|
|
|
|
#include <ucbhelper/commandenvironment.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _UCBHELPER_CONTENT_HXX
|
|
|
|
#include <ucbhelper/content.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _OSL_FILE_HXX_
|
|
|
|
#include <osl/file.hxx>
|
|
|
|
#endif
|
2001-01-16 14:28:25 +00:00
|
|
|
|
|
|
|
#include <tools/wldcrd.hxx>
|
|
|
|
#include <tools/ref.hxx>
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#include <tools/datetime.hxx>
|
|
|
|
|
2001-12-13 17:16:09 +00:00
|
|
|
#include "unotools/localfilehelper.hxx"
|
|
|
|
|
2001-01-16 14:28:25 +00:00
|
|
|
using namespace ::ucb;
|
2001-06-07 06:40:08 +00:00
|
|
|
using namespace com::sun::star::beans;
|
|
|
|
using namespace com::sun::star::container;
|
2001-01-16 14:28:25 +00:00
|
|
|
using namespace com::sun::star::lang;
|
|
|
|
using namespace com::sun::star::sdbc;
|
2001-12-11 14:01:22 +00:00
|
|
|
using namespace com::sun::star::task;
|
2001-01-16 14:28:25 +00:00
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::ucb;
|
|
|
|
using namespace rtl;
|
|
|
|
using namespace comphelper;
|
|
|
|
using namespace osl;
|
|
|
|
|
|
|
|
DECLARE_LIST( StringList_Impl, OUString* );
|
|
|
|
|
|
|
|
#define CONVERT_DATETIME( aUnoDT, aToolsDT ) \
|
|
|
|
aToolsDT = DateTime( Date( aUnoDT.Day, aUnoDT.Month, aUnoDT.Year ), \
|
|
|
|
Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.HundredthSeconds ) );
|
|
|
|
|
|
|
|
namespace utl
|
|
|
|
{
|
|
|
|
|
|
|
|
sal_Bool UCBContentHelper::Transfer_Impl( const String& rSource, const String& rDest, sal_Bool bMoveData, sal_Int32 nNameClash )
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_True, bKillSource = sal_False;
|
|
|
|
INetURLObject aSourceObj( rSource );
|
|
|
|
DBG_ASSERT( aSourceObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
|
|
|
|
INetURLObject aDestObj( rDest );
|
|
|
|
DBG_ASSERT( aDestObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
if ( bMoveData && aSourceObj.GetProtocol() != aDestObj.GetProtocol() )
|
|
|
|
{
|
|
|
|
bMoveData = sal_False;
|
|
|
|
bKillSource = sal_True;
|
|
|
|
}
|
|
|
|
String aName = aDestObj.getName();
|
|
|
|
aDestObj.removeSegment();
|
|
|
|
aDestObj.setFinalSlash();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2001-06-29 11:47:37 +00:00
|
|
|
Content aDestPath( aDestObj.GetMainURL( INetURLObject::NO_DECODE ), Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
|
2001-01-16 14:28:25 +00:00
|
|
|
Reference< ::com::sun::star::ucb::XCommandInfo > xInfo = aDestPath.getCommands();
|
|
|
|
OUString aTransferName = OUString::createFromAscii( "transfer" );
|
|
|
|
if ( xInfo->hasCommandByName( aTransferName ) )
|
|
|
|
{
|
|
|
|
aDestPath.executeCommand( aTransferName, makeAny(
|
2001-06-29 11:47:37 +00:00
|
|
|
::com::sun::star::ucb::TransferInfo( bMoveData, aSourceObj.GetMainURL( INetURLObject::NO_DECODE ), aName, nNameClash ) ) );
|
2001-01-16 14:28:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERRORFILE( "transfer command not available" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
bRet = sal_False;
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
bRet = sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bKillSource )
|
|
|
|
UCBContentHelper::Kill( rSource );
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool UCBContentHelper::IsDocument( const String& rContent )
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
INetURLObject aObj( rContent );
|
|
|
|
DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2001-06-29 11:47:37 +00:00
|
|
|
Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
|
2001-01-16 14:28:25 +00:00
|
|
|
bRet = aCnt.isDocument();
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "CommandAbortedException" );
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::IllegalIdentifierException& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "IllegalIdentifierException" );
|
|
|
|
}
|
|
|
|
catch( ContentCreationException& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "IllegalIdentifierException" );
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
2001-07-16 08:30:44 +00:00
|
|
|
DBG_WARNING( "Any other exception" );
|
2001-01-16 14:28:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2001-09-10 15:34:48 +00:00
|
|
|
Any UCBContentHelper::GetProperty( const String& rContent, const ::rtl::OUString& rName )
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
INetURLObject aObj( rContent );
|
|
|
|
DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
|
|
|
|
return aCnt.getPropertyValue( rName );
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "CommandAbortedException" );
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::IllegalIdentifierException& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "IllegalIdentifierException" );
|
|
|
|
}
|
|
|
|
catch( ContentCreationException& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "IllegalIdentifierException" );
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "Any other exception" );
|
|
|
|
}
|
|
|
|
|
|
|
|
return Any();
|
|
|
|
}
|
|
|
|
|
2001-01-16 14:28:25 +00:00
|
|
|
sal_Bool UCBContentHelper::IsFolder( const String& rContent )
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
INetURLObject aObj( rContent );
|
|
|
|
DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
try
|
|
|
|
{
|
2001-06-29 11:47:37 +00:00
|
|
|
Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
|
2001-01-16 14:28:25 +00:00
|
|
|
bRet = aCnt.isFolder();
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "CommandAbortedException" );
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::IllegalIdentifierException& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "IllegalIdentifierException" );
|
|
|
|
}
|
|
|
|
catch( ContentCreationException& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "IllegalIdentifierException" );
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
2001-07-16 08:30:44 +00:00
|
|
|
DBG_WARNING( "Any other exception" );
|
2001-01-16 14:28:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool UCBContentHelper::GetTitle( const String& rContent, String& rTitle )
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
INetURLObject aObj( rContent );
|
|
|
|
DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
try
|
|
|
|
{
|
2001-06-29 11:47:37 +00:00
|
|
|
Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
|
2001-01-16 14:28:25 +00:00
|
|
|
OUString aTemp;
|
2001-06-28 13:51:49 +00:00
|
|
|
if ( aCnt.getPropertyValue( OUString::createFromAscii( "Title" ) ) >>= aTemp )
|
|
|
|
{
|
|
|
|
rTitle = String( aTemp );
|
|
|
|
bRet = sal_True;
|
|
|
|
}
|
2001-01-16 14:28:25 +00:00
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool UCBContentHelper::Kill( const String& rContent )
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_True;
|
|
|
|
INetURLObject aDeleteObj( rContent );
|
|
|
|
DBG_ASSERT( aDeleteObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2001-06-29 11:47:37 +00:00
|
|
|
Content aCnt( aDeleteObj.GetMainURL( INetURLObject::NO_DECODE ), Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
|
2001-01-16 14:28:25 +00:00
|
|
|
aCnt.executeCommand( OUString::createFromAscii( "delete" ), makeAny( sal_Bool( sal_True ) ) );
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
DBG_WARNING( "CommandAbortedException" );
|
|
|
|
bRet = sal_False;
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
2001-07-16 08:30:44 +00:00
|
|
|
DBG_WARNING( "Any other exception" );
|
2001-01-16 14:28:25 +00:00
|
|
|
bRet = sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Sequence < OUString > UCBContentHelper::GetFolderContents( const String& rFolder, sal_Bool bFolder, sal_Bool bSorted )
|
|
|
|
{
|
|
|
|
StringList_Impl* pFiles = NULL;
|
|
|
|
INetURLObject aFolderObj( rFolder );
|
|
|
|
DBG_ASSERT( aFolderObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
try
|
|
|
|
{
|
2001-06-29 11:47:37 +00:00
|
|
|
Content aCnt( aFolderObj.GetMainURL( INetURLObject::NO_DECODE ), Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
|
2001-01-16 14:28:25 +00:00
|
|
|
Reference< XResultSet > xResultSet;
|
2001-12-13 17:16:09 +00:00
|
|
|
Sequence< OUString > aProps( bSorted ? 2 : 1 );
|
2001-01-16 14:28:25 +00:00
|
|
|
OUString* pProps = aProps.getArray();
|
|
|
|
pProps[0] = OUString::createFromAscii( "Title" );
|
2001-12-13 17:16:09 +00:00
|
|
|
if ( bSorted )
|
|
|
|
pProps[1] = OUString::createFromAscii( "IsFolder" );
|
2001-01-16 14:28:25 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ResultSetInclude eInclude = bFolder ? INCLUDE_FOLDERS_AND_DOCUMENTS : INCLUDE_DOCUMENTS_ONLY;
|
|
|
|
if ( !bSorted )
|
|
|
|
{
|
|
|
|
xResultSet = aCnt.createCursor( aProps, eInclude );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Reference< com::sun::star::ucb::XDynamicResultSet > xDynResultSet;
|
|
|
|
xDynResultSet = aCnt.createDynamicCursor( aProps, eInclude );
|
|
|
|
|
|
|
|
Reference < com::sun::star::ucb::XAnyCompareFactory > xFactory;
|
|
|
|
Reference < XMultiServiceFactory > xMgr = getProcessServiceFactory();
|
|
|
|
Reference < com::sun::star::ucb::XSortedDynamicResultSetFactory > xSRSFac(
|
|
|
|
xMgr->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SortedDynamicResultSetFactory") ), UNO_QUERY );
|
|
|
|
|
|
|
|
Sequence< com::sun::star::ucb::NumberedSortingInfo > aSortInfo( 2 );
|
|
|
|
com::sun::star::ucb::NumberedSortingInfo* pInfo = aSortInfo.getArray();
|
|
|
|
pInfo[ 0 ].ColumnIndex = 2;
|
|
|
|
pInfo[ 0 ].Ascending = sal_False;
|
|
|
|
pInfo[ 1 ].ColumnIndex = 1;
|
|
|
|
pInfo[ 1 ].Ascending = sal_True;
|
|
|
|
|
|
|
|
Reference< com::sun::star::ucb::XDynamicResultSet > xDynamicResultSet;
|
|
|
|
xDynamicResultSet =
|
|
|
|
xSRSFac->createSortedDynamicResultSet( xDynResultSet, aSortInfo, xFactory );
|
|
|
|
if ( xDynamicResultSet.is() )
|
|
|
|
{
|
|
|
|
sal_Int16 nCaps = xDynamicResultSet->getCapabilities();
|
|
|
|
xResultSet = xDynamicResultSet->getStaticResultSet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
2001-01-25 07:27:35 +00:00
|
|
|
// folder not exists?
|
2001-01-16 14:28:25 +00:00
|
|
|
}
|
2001-07-16 08:30:44 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( xResultSet.is() )
|
|
|
|
{
|
|
|
|
pFiles = new StringList_Impl;
|
|
|
|
Reference< com::sun::star::ucb::XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
while ( xResultSet->next() )
|
|
|
|
{
|
|
|
|
OUString aId = xContentAccess->queryContentIdentifierString();
|
|
|
|
OUString* pFile = new OUString( aId );
|
|
|
|
pFiles->Insert( pFile, LIST_APPEND );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pFiles )
|
|
|
|
{
|
|
|
|
ULONG nCount = pFiles->Count();
|
|
|
|
Sequence < OUString > aRet( nCount );
|
|
|
|
OUString* pRet = aRet.getArray();
|
|
|
|
for ( ULONG i = 0; i < nCount; ++i )
|
|
|
|
{
|
|
|
|
OUString* pFile = pFiles->GetObject(i);
|
|
|
|
pRet[i] = *( pFile );
|
|
|
|
delete pFile;
|
|
|
|
}
|
|
|
|
delete pFiles;
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return Sequence < OUString > ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Sequence < OUString > UCBContentHelper::GetResultSet( const String& rURL )
|
|
|
|
{
|
|
|
|
StringList_Impl* pList = NULL;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Content aCnt( rURL, Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
|
|
|
|
Reference< XResultSet > xResultSet;
|
|
|
|
Reference< com::sun::star::ucb::XDynamicResultSet > xDynResultSet;
|
|
|
|
Sequence< OUString > aProps(3);
|
|
|
|
OUString* pProps = aProps.getArray();
|
|
|
|
pProps[0] = OUString::createFromAscii( "Title" );
|
|
|
|
pProps[1] = OUString::createFromAscii( "ContentType" );
|
|
|
|
pProps[2] = OUString::createFromAscii( "IsFolder" );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xDynResultSet = aCnt.createDynamicCursor( aProps, INCLUDE_FOLDERS_AND_DOCUMENTS );
|
|
|
|
if ( xDynResultSet.is() )
|
|
|
|
xResultSet = xDynResultSet->getStaticResultSet();
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( xResultSet.is() )
|
|
|
|
{
|
|
|
|
pList = new StringList_Impl;
|
|
|
|
Reference< com::sun::star::sdbc::XRow > xRow( xResultSet, UNO_QUERY );
|
|
|
|
Reference< com::sun::star::ucb::XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
while ( xResultSet->next() )
|
|
|
|
{
|
|
|
|
String aTitle( xRow->getString(1) );
|
|
|
|
String aType( xRow->getString(2) );
|
|
|
|
sal_Bool bFolder = xRow->getBoolean(3);
|
|
|
|
String aRow = aTitle;
|
|
|
|
aRow += '\t';
|
|
|
|
aRow += aType;
|
|
|
|
aRow += '\t';
|
|
|
|
aRow += String( xContentAccess->queryContentIdentifierString() );
|
|
|
|
OUString* pRow = new OUString( aRow );
|
|
|
|
pList->Insert( pRow, LIST_APPEND );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pList )
|
|
|
|
{
|
|
|
|
ULONG nCount = pList->Count();
|
|
|
|
Sequence < OUString > aRet( nCount );
|
|
|
|
OUString* pRet = aRet.getArray();
|
|
|
|
for ( ULONG i = 0; i < nCount; ++i )
|
|
|
|
{
|
|
|
|
OUString* pEntry = pList->GetObject(i);
|
|
|
|
pRet[i] = *( pEntry );
|
|
|
|
delete pEntry;
|
|
|
|
}
|
|
|
|
delete pList;
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return Sequence < OUString > ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool UCBContentHelper::CopyTo( const String& rSource, const String& rDest )
|
|
|
|
{
|
|
|
|
return Transfer_Impl( rSource, rDest, sal_False, NameClash::ERROR );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool UCBContentHelper::MoveTo( const String& rSource, const String& rDest, sal_Int32 nNameClash )
|
|
|
|
{
|
|
|
|
return Transfer_Impl( rSource, rDest, sal_True, nNameClash );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2001-06-07 06:40:08 +00:00
|
|
|
sal_Bool UCBContentHelper::CanMakeFolder( const String& rFolder )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Content aCnt( rFolder, Reference< XCommandEnvironment > () );
|
|
|
|
Reference< XContentCreator > xCreator = Reference< XContentCreator >( aCnt.get(), UNO_QUERY );
|
|
|
|
if ( !xCreator.is() )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
Sequence< ContentInfo > aInfo = xCreator->queryCreatableContentsInfo();
|
|
|
|
sal_Int32 nCount = aInfo.getLength();
|
|
|
|
if ( nCount == 0 )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
for ( sal_Int32 i = 0; i < nCount; ++i )
|
|
|
|
{
|
|
|
|
// Simply look for the first KIND_FOLDER...
|
|
|
|
const ContentInfo & rCurr = aInfo[i];
|
|
|
|
if ( rCurr.Attributes & ContentInfoAttribute::KIND_FOLDER )
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& ) {}
|
|
|
|
catch( RuntimeException& ) {}
|
|
|
|
catch( Exception& ) {}
|
|
|
|
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2003-03-27 16:45:03 +00:00
|
|
|
sal_Bool UCBContentHelper::MakeFolder( const String& rFolder, sal_Bool bNewOnly )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
INetURLObject aURL( rFolder );
|
|
|
|
DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
String aTitle = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
|
|
|
|
aURL.removeSegment();
|
2001-07-06 14:08:07 +00:00
|
|
|
Content aCnt;
|
|
|
|
Content aNew;
|
2001-12-11 14:01:22 +00:00
|
|
|
Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
|
|
|
|
Reference< XInteractionHandler > xInteractionHandler = Reference< XInteractionHandler > (
|
|
|
|
xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uui.InteractionHandler") ) ), UNO_QUERY );
|
2002-11-05 08:00:53 +00:00
|
|
|
if ( Content::create( aURL.GetMainURL( INetURLObject::NO_DECODE ), new CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() ), aCnt ) )
|
2003-03-27 16:45:03 +00:00
|
|
|
return MakeFolder( aCnt, aTitle, aNew, bNewOnly );
|
2001-07-06 14:08:07 +00:00
|
|
|
else
|
|
|
|
return sal_False;
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
|
2003-03-27 16:45:03 +00:00
|
|
|
sal_Bool UCBContentHelper::MakeFolder( Content& aCnt, const String& aTitle, Content& rNew, sal_Bool bNewOnly )
|
2001-07-06 14:08:07 +00:00
|
|
|
{
|
2003-03-27 16:45:03 +00:00
|
|
|
sal_Bool bAlreadyExists = sal_False;
|
2002-12-09 15:29:09 +00:00
|
|
|
|
2001-01-16 14:28:25 +00:00
|
|
|
try
|
|
|
|
{
|
2001-06-07 06:40:08 +00:00
|
|
|
Reference< XContentCreator > xCreator = Reference< XContentCreator >( aCnt.get(), UNO_QUERY );
|
|
|
|
if ( !xCreator.is() )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
Sequence< ContentInfo > aInfo = xCreator->queryCreatableContentsInfo();
|
|
|
|
sal_Int32 nCount = aInfo.getLength();
|
|
|
|
if ( nCount == 0 )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
for ( sal_Int32 i = 0; i < nCount; ++i )
|
|
|
|
{
|
|
|
|
// Simply look for the first KIND_FOLDER...
|
|
|
|
const ContentInfo & rCurr = aInfo[i];
|
|
|
|
if ( rCurr.Attributes & ContentInfoAttribute::KIND_FOLDER )
|
|
|
|
{
|
|
|
|
// Make sure the only required bootstrap property is "Title",
|
|
|
|
const Sequence< Property > & rProps = rCurr.Properties;
|
|
|
|
if ( rProps.getLength() != 1 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ( !rProps[ 0 ].Name.equalsAsciiL(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Sequence<OUString> aNames(1);
|
|
|
|
OUString* pNames = aNames.getArray();
|
|
|
|
pNames[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) );
|
|
|
|
Sequence<Any> aValues(1);
|
|
|
|
Any* pValues = aValues.getArray();
|
|
|
|
pValues[0] = makeAny( OUString( aTitle ) );
|
|
|
|
|
2001-07-06 14:08:07 +00:00
|
|
|
if ( !aCnt.insertNewContent( rCurr.Type, aNames, aValues, rNew ) )
|
2001-06-07 06:40:08 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
}
|
2001-01-16 14:28:25 +00:00
|
|
|
}
|
2001-11-27 10:03:52 +00:00
|
|
|
catch ( InteractiveIOException& r )
|
|
|
|
{
|
|
|
|
if ( r.Code == IOErrorCode_ALREADY_EXISTING )
|
|
|
|
{
|
2003-03-27 16:45:03 +00:00
|
|
|
bAlreadyExists = sal_True;
|
2001-11-27 10:03:52 +00:00
|
|
|
}
|
|
|
|
}
|
2002-12-09 15:29:09 +00:00
|
|
|
catch ( NameClashException& )
|
|
|
|
{
|
2003-03-27 16:45:03 +00:00
|
|
|
bAlreadyExists = sal_True;
|
2002-12-09 15:29:09 +00:00
|
|
|
}
|
2001-01-16 14:28:25 +00:00
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( RuntimeException& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
2001-06-07 06:40:08 +00:00
|
|
|
}
|
|
|
|
catch( Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-03-27 16:45:03 +00:00
|
|
|
if( bAlreadyExists && !bNewOnly )
|
2002-12-09 15:29:09 +00:00
|
|
|
{
|
|
|
|
INetURLObject aObj( aCnt.getURL() );
|
|
|
|
aObj.Append( aTitle );
|
|
|
|
rNew = Content( aObj.GetMainURL( INetURLObject::NO_DECODE ), Reference < XCommandEnvironment >() );
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
2001-06-07 06:40:08 +00:00
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool UCBContentHelper::HasParentFolder( const String& rFolder )
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
2001-07-03 12:48:07 +00:00
|
|
|
try
|
2001-06-07 06:40:08 +00:00
|
|
|
{
|
2001-07-03 12:48:07 +00:00
|
|
|
Content aCnt( rFolder, Reference< XCommandEnvironment > () );
|
|
|
|
Reference< XChild > xChild( aCnt.get(), UNO_QUERY );
|
|
|
|
if ( xChild.is() )
|
2001-06-07 06:40:08 +00:00
|
|
|
{
|
2001-07-03 12:48:07 +00:00
|
|
|
Reference< XContent > xParent( xChild->getParent(), UNO_QUERY );
|
|
|
|
if ( xParent.is() )
|
|
|
|
{
|
|
|
|
String aParentURL = String( xParent->getIdentifier()->getContentIdentifier() );
|
|
|
|
bRet = ( aParentURL.Len() > 0 && aParentURL != rFolder );
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
}
|
2001-01-16 14:28:25 +00:00
|
|
|
}
|
2001-07-03 12:48:07 +00:00
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
2001-01-16 14:28:25 +00:00
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ULONG UCBContentHelper::GetSize( const String& rContent )
|
|
|
|
{
|
|
|
|
ULONG nSize = 0;
|
|
|
|
sal_Int64 nTemp = 0;
|
|
|
|
INetURLObject aObj( rContent );
|
|
|
|
DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
try
|
|
|
|
{
|
2001-06-29 11:47:37 +00:00
|
|
|
Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
|
2001-01-16 14:28:25 +00:00
|
|
|
aCnt.getPropertyValue( OUString::createFromAscii( "Size" ) ) >>= nTemp;
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
nSize = (UINT32)nTemp;
|
|
|
|
return nSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool UCBContentHelper::IsYounger( const String& rIsYoung, const String& rIsOlder )
|
|
|
|
{
|
|
|
|
DateTime aYoungDate, aOlderDate;
|
|
|
|
INetURLObject aYoungObj( rIsYoung );
|
|
|
|
DBG_ASSERT( aYoungObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
INetURLObject aOlderObj( rIsOlder );
|
|
|
|
DBG_ASSERT( aOlderObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::ucb::XCommandEnvironment > aCmdEnv;
|
2001-06-29 11:47:37 +00:00
|
|
|
Content aYoung( aYoungObj.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv );
|
2001-01-16 14:28:25 +00:00
|
|
|
::com::sun::star::util::DateTime aTempYoungDate;
|
|
|
|
aYoung.getPropertyValue( OUString::createFromAscii( "DateModified" ) ) >>= aTempYoungDate;
|
|
|
|
CONVERT_DATETIME( aTempYoungDate, aYoungDate );
|
2001-06-29 11:47:37 +00:00
|
|
|
Content aOlder( aOlderObj.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv );
|
2001-01-16 14:28:25 +00:00
|
|
|
::com::sun::star::util::DateTime aTempOlderDate;
|
|
|
|
aOlder.getPropertyValue( OUString::createFromAscii( "DateModified" ) ) >>= aTempOlderDate;
|
|
|
|
CONVERT_DATETIME( aTempOlderDate, aOlderDate );
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::ucb::CommandAbortedException& )
|
|
|
|
{
|
|
|
|
}
|
2001-06-07 06:40:08 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& )
|
2001-01-16 14:28:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return ( aYoungDate > aOlderDate );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
sal_Bool UCBContentHelper::Find( const String& rFolder, const String& rName, String& rFile, BOOL bAllowWildCards )
|
|
|
|
{
|
|
|
|
BOOL bWild = bAllowWildCards && rName.Search( '*' ) != STRING_NOTFOUND || rName.Search( '?' ) != STRING_NOTFOUND;
|
|
|
|
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
|
|
|
|
// get a list of URLs for all children of rFolder
|
|
|
|
Sequence< ::rtl::OUString > aFiles = GetFolderContents( rFolder, sal_False );
|
|
|
|
|
|
|
|
const ::rtl::OUString* pFiles = aFiles.getConstArray();
|
|
|
|
UINT32 i, nCount = aFiles.getLength();
|
|
|
|
for ( i = 0; i < nCount; ++i )
|
|
|
|
{
|
|
|
|
// get the last name of the URLs and compare it with rName
|
|
|
|
INetURLObject aFileObject( pFiles[i] );
|
|
|
|
String aFile = aFileObject.getName(
|
2004-12-13 11:48:13 +00:00
|
|
|
INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ).toAsciiLowerCase();
|
2001-01-16 14:28:25 +00:00
|
|
|
if ( bWild && WildCard( rName ).Matches( aFile ) || aFile == rName )
|
|
|
|
{
|
|
|
|
// names match
|
2001-06-29 11:47:37 +00:00
|
|
|
rFile = aFileObject.GetMainURL( INetURLObject::NO_DECODE );
|
2001-01-16 14:28:25 +00:00
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
sal_Bool UCBContentHelper::Exists( const String& rURL )
|
|
|
|
{
|
2001-12-13 17:16:09 +00:00
|
|
|
|
|
|
|
String sObjectPhysicalName;
|
|
|
|
sal_Bool bIsLocalFile = ::utl::LocalFileHelper::ConvertURLToPhysicalName( rURL, sObjectPhysicalName );
|
|
|
|
// try to create a directory entry for the URL given
|
|
|
|
if ( bIsLocalFile )
|
|
|
|
{
|
|
|
|
::rtl::OUString sIn( sObjectPhysicalName ), sOut;
|
|
|
|
if ( osl_File_E_None == osl_getFileURLFromSystemPath( sIn.pData, &sOut.pData ) )
|
|
|
|
{
|
2003-03-27 16:45:03 +00:00
|
|
|
// #106526 osl_getDirectoryItem is an existence check
|
|
|
|
// no further osl_getFileStatus call necessary
|
2001-12-13 17:16:09 +00:00
|
|
|
DirectoryItem aItem;
|
2003-03-27 16:45:03 +00:00
|
|
|
return (FileBase::E_None == DirectoryItem::get(sOut, aItem));
|
2001-12-13 17:16:09 +00:00
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
2001-01-16 14:28:25 +00:00
|
|
|
// divide URL into folder and name part
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
INetURLObject aObj( rURL );
|
|
|
|
::rtl::OUString aFileName = aObj.getName(
|
2004-12-13 11:48:13 +00:00
|
|
|
INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ).toAsciiLowerCase();
|
2001-01-16 14:28:25 +00:00
|
|
|
aObj.removeSegment();
|
|
|
|
aObj.removeFinalSlash();
|
|
|
|
|
2001-07-18 16:22:26 +00:00
|
|
|
// get a list of URLs for all children of rFolder
|
2001-12-13 17:16:09 +00:00
|
|
|
Sequence< ::rtl::OUString > aFiles = GetFolderContents( aObj.GetMainURL( INetURLObject::NO_DECODE ), sal_True, sal_False );
|
2001-07-18 16:22:26 +00:00
|
|
|
|
|
|
|
const ::rtl::OUString* pFiles = aFiles.getConstArray();
|
|
|
|
UINT32 i, nCount = aFiles.getLength();
|
|
|
|
for ( i = 0; i < nCount; ++i )
|
|
|
|
{
|
|
|
|
// get the last name of the URLs and compare it with rName
|
|
|
|
INetURLObject aFileObject( pFiles[i] );
|
|
|
|
::rtl::OUString aFile = aFileObject.getName(
|
2004-12-13 11:48:13 +00:00
|
|
|
INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ).toAsciiLowerCase();
|
2001-07-18 16:22:26 +00:00
|
|
|
if ( aFile == aFileName )
|
|
|
|
{
|
|
|
|
// names match
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-01-16 14:28:25 +00:00
|
|
|
|
2001-07-18 16:22:26 +00:00
|
|
|
return bRet;
|
2001-01-16 14:28:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
sal_Bool UCBContentHelper::FindInPath( const String& rPath, const String& rName, String& rFile, char cDelim, BOOL bAllowWildCards )
|
|
|
|
{
|
|
|
|
// extract the single folder names from the path variable and try to find the file in one of these folders
|
|
|
|
USHORT nTokenCount = rPath.GetTokenCount( cDelim );
|
|
|
|
USHORT nIndex = 0;
|
|
|
|
for ( USHORT nToken = 0; nToken < nTokenCount; ++nToken )
|
|
|
|
{
|
|
|
|
String aPath = rPath.GetToken( nToken, cDelim );
|
|
|
|
if ( Find( aPath, rName, rFile, bAllowWildCards ) )
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
2001-01-25 07:27:35 +00:00
|
|
|
|