diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2001-12-13 17:16:09 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2001-12-13 17:16:09 +0000 |
commit | 70109968517901d1b585307beec293431b46e05c (patch) | |
tree | 8e984bed3ddd2c9e32e495fa7c79a8c55258a5ac /unotools/source | |
parent | bb1ff595bbc4b1c38a5f04f07b2f2d32019e114b (diff) |
#95933# use a different approach in UCBContentHelper::Exists: with the old approach, corrupted siblings of the dir in question may lead to deadlocks
Diffstat (limited to 'unotools/source')
-rw-r--r-- | unotools/source/ucbhelper/ucbhelper.cxx | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/unotools/source/ucbhelper/ucbhelper.cxx b/unotools/source/ucbhelper/ucbhelper.cxx index d88a1b3657fe..3641190456b4 100644 --- a/unotools/source/ucbhelper/ucbhelper.cxx +++ b/unotools/source/ucbhelper/ucbhelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ucbhelper.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: pb $ $Date: 2001-12-11 15:01:22 $ + * last change: $Author: vg $ $Date: 2001-12-13 18:16:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -137,6 +137,8 @@ #include <tools/urlobj.hxx> #include <tools/datetime.hxx> +#include "unotools/localfilehelper.hxx" + using namespace ::ucb; using namespace com::sun::star::beans; using namespace com::sun::star::container; @@ -364,10 +366,11 @@ Sequence < OUString > UCBContentHelper::GetFolderContents( const String& rFolder { Content aCnt( aFolderObj.GetMainURL( INetURLObject::NO_DECODE ), Reference< ::com::sun::star::ucb::XCommandEnvironment > () ); Reference< XResultSet > xResultSet; - Sequence< OUString > aProps(2); + Sequence< OUString > aProps( bSorted ? 2 : 1 ); OUString* pProps = aProps.getArray(); pProps[0] = OUString::createFromAscii( "Title" ); - pProps[1] = OUString::createFromAscii( "IsFolder" ); + if ( bSorted ) + pProps[1] = OUString::createFromAscii( "IsFolder" ); try { @@ -780,6 +783,32 @@ sal_Bool UCBContentHelper::Find( const String& rFolder, const String& rName, Str // ----------------------------------------------------------------------- sal_Bool UCBContentHelper::Exists( const String& rURL ) { + + 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 ) ) + { + ::osl::FileBase::RC eResult = FileBase::E_None; + + DirectoryItem aItem; + if ( FileBase::E_None == DirectoryItem::get( sOut, aItem ) ) + { + FileStatus aStatus( FileStatusMask_FileName ); + eResult = aItem.getFileStatus( aStatus ); + if ( FileBase::E_NOENT == eResult ) + { // there is no such entry + return sal_False; + } + return sal_True; + } + } + return sal_False; + } + // divide URL into folder and name part sal_Bool bRet = sal_False; INetURLObject aObj( rURL ); @@ -789,7 +818,7 @@ sal_Bool UCBContentHelper::Exists( const String& rURL ) aObj.removeFinalSlash(); // get a list of URLs for all children of rFolder - Sequence< ::rtl::OUString > aFiles = GetFolderContents( aObj.GetMainURL( INetURLObject::NO_DECODE ), sal_True ); + Sequence< ::rtl::OUString > aFiles = GetFolderContents( aObj.GetMainURL( INetURLObject::NO_DECODE ), sal_True, sal_False ); const ::rtl::OUString* pFiles = aFiles.getConstArray(); UINT32 i, nCount = aFiles.getLength(); |