1*2f86921cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2f86921cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2f86921cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2f86921cSAndrew Rist * distributed with this work for additional information 6*2f86921cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2f86921cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2f86921cSAndrew Rist * "License"); you may not use this file except in compliance 9*2f86921cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2f86921cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2f86921cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2f86921cSAndrew Rist * software distributed under the License is distributed on an 15*2f86921cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2f86921cSAndrew Rist * KIND, either express or implied. See the License for the 17*2f86921cSAndrew Rist * specific language governing permissions and limitations 18*2f86921cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2f86921cSAndrew Rist *************************************************************/ 21*2f86921cSAndrew Rist 22*2f86921cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_ucb.hxx" 26cdf0e10cSrcweir #include <stdio.h> 27cdf0e10cSrcweir #include "filglob.hxx" 28cdf0e10cSrcweir #ifndef _FILERROR_HXX_ 29cdf0e10cSrcweir #include "filerror.hxx" 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir #include "shell.hxx" 32cdf0e10cSrcweir #include "bc.hxx" 33cdf0e10cSrcweir #include <osl/file.hxx> 34cdf0e10cSrcweir #ifndef INCLUDED_STL_VECTOR 35cdf0e10cSrcweir #include <vector> 36cdf0e10cSrcweir #define INCLUDED_STL_VECTOR 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #include <ucbhelper/cancelcommandexecution.hxx> 39cdf0e10cSrcweir #include <com/sun/star/ucb/CommandAbortedException.hpp> 40cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedCommandException.hpp> 41cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp> 42cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp> 43cdf0e10cSrcweir #include <com/sun/star/ucb/IOErrorCode.hpp> 44cdf0e10cSrcweir #include <com/sun/star/ucb/MissingPropertiesException.hpp> 45cdf0e10cSrcweir #include <com/sun/star/ucb/MissingInputStreamException.hpp> 46cdf0e10cSrcweir #include <com/sun/star/ucb/NameClashException.hpp> 47cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> 48cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedNameClashException.hpp> 49cdf0e10cSrcweir #include "com/sun/star/beans/PropertyState.hpp" 50cdf0e10cSrcweir #include "com/sun/star/beans/PropertyValue.hpp" 51cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> 52cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx" 53cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx" 54cdf0e10cSrcweir #include "osl/diagnose.h" 55cdf0e10cSrcweir #include "rtl/ustrbuf.hxx" 56cdf0e10cSrcweir #include <rtl/uri.hxx> 57cdf0e10cSrcweir #include <rtl/ustring.hxx> 58cdf0e10cSrcweir #include "sal/types.h" 59cdf0e10cSrcweir 60cdf0e10cSrcweir using namespace ucbhelper; 61cdf0e10cSrcweir using namespace osl; 62cdf0e10cSrcweir using namespace ::com::sun::star; 63cdf0e10cSrcweir using namespace com::sun::star::task; 64cdf0e10cSrcweir using namespace com::sun::star::beans; 65cdf0e10cSrcweir using namespace com::sun::star::lang; 66cdf0e10cSrcweir using namespace com::sun::star::uno; 67cdf0e10cSrcweir using namespace com::sun::star::ucb; 68cdf0e10cSrcweir 69cdf0e10cSrcweir namespace { 70cdf0e10cSrcweir 71cdf0e10cSrcweir Sequence< Any > generateErrorArguments( 72cdf0e10cSrcweir rtl::OUString const & rPhysicalUrl) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir rtl::OUString aResourceName; 75cdf0e10cSrcweir rtl::OUString aResourceType; 76cdf0e10cSrcweir sal_Bool bRemovable; 77cdf0e10cSrcweir bool bResourceName = false; 78cdf0e10cSrcweir bool bResourceType = false; 79cdf0e10cSrcweir bool bRemoveProperty = false; 80cdf0e10cSrcweir 81cdf0e10cSrcweir if (osl::FileBase::getSystemPathFromFileURL( 82cdf0e10cSrcweir rPhysicalUrl, 83cdf0e10cSrcweir aResourceName) 84cdf0e10cSrcweir == osl::FileBase::E_None) 85cdf0e10cSrcweir bResourceName = true; 86cdf0e10cSrcweir 87cdf0e10cSrcweir // The resource types "folder" (i.e., directory) and 88cdf0e10cSrcweir // "volume" seem to be 89cdf0e10cSrcweir // the most interesting when producing meaningful error messages: 90cdf0e10cSrcweir osl::DirectoryItem aItem; 91cdf0e10cSrcweir if (osl::DirectoryItem::get(rPhysicalUrl, aItem) == 92cdf0e10cSrcweir osl::FileBase::E_None) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir osl::FileStatus aStatus( FileStatusMask_Type ); 95cdf0e10cSrcweir if (aItem.getFileStatus(aStatus) == osl::FileBase::E_None) 96cdf0e10cSrcweir switch (aStatus.getFileType()) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir case osl::FileStatus::Directory: 99cdf0e10cSrcweir aResourceType 100cdf0e10cSrcweir = rtl::OUString( 101cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("folder")); 102cdf0e10cSrcweir bResourceType = true; 103cdf0e10cSrcweir break; 104cdf0e10cSrcweir 105cdf0e10cSrcweir case osl::FileStatus::Volume: 106cdf0e10cSrcweir { 107cdf0e10cSrcweir aResourceType 108cdf0e10cSrcweir = rtl::OUString( 109cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("volume")); 110cdf0e10cSrcweir bResourceType = true; 111cdf0e10cSrcweir osl::VolumeInfo aVolumeInfo( 112cdf0e10cSrcweir VolumeInfoMask_Attributes ); 113cdf0e10cSrcweir if( osl::Directory::getVolumeInfo( 114cdf0e10cSrcweir rPhysicalUrl,aVolumeInfo ) == 115cdf0e10cSrcweir osl::FileBase::E_None ) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir bRemovable = aVolumeInfo.getRemoveableFlag(); 118cdf0e10cSrcweir bRemoveProperty = true; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir } 121cdf0e10cSrcweir break; 122cdf0e10cSrcweir case osl::FileStatus::Regular: 123cdf0e10cSrcweir case osl::FileStatus::Fifo: 124cdf0e10cSrcweir case osl::FileStatus::Socket: 125cdf0e10cSrcweir case osl::FileStatus::Link: 126cdf0e10cSrcweir case osl::FileStatus::Special: 127cdf0e10cSrcweir case osl::FileStatus::Unknown: 128cdf0e10cSrcweir // do nothing for now 129cdf0e10cSrcweir break; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir Sequence< Any > aArguments( 1 + 134cdf0e10cSrcweir (bResourceName ? 1 : 0) + 135cdf0e10cSrcweir (bResourceType ? 1 : 0) + 136cdf0e10cSrcweir (bRemoveProperty ? 1 : 0) ); 137cdf0e10cSrcweir sal_Int32 i = 0; 138cdf0e10cSrcweir aArguments[i++] 139cdf0e10cSrcweir <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 140cdf0e10cSrcweir "Uri")), 141cdf0e10cSrcweir -1, 142cdf0e10cSrcweir makeAny(rPhysicalUrl), 143cdf0e10cSrcweir PropertyState_DIRECT_VALUE); 144cdf0e10cSrcweir if (bResourceName) 145cdf0e10cSrcweir aArguments[i++] 146cdf0e10cSrcweir <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 147cdf0e10cSrcweir "ResourceName")), 148cdf0e10cSrcweir -1, 149cdf0e10cSrcweir makeAny(aResourceName), 150cdf0e10cSrcweir PropertyState_DIRECT_VALUE); 151cdf0e10cSrcweir if (bResourceType) 152cdf0e10cSrcweir aArguments[i++] 153cdf0e10cSrcweir <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 154cdf0e10cSrcweir "ResourceType")), 155cdf0e10cSrcweir -1, 156cdf0e10cSrcweir makeAny(aResourceType), 157cdf0e10cSrcweir PropertyState_DIRECT_VALUE); 158cdf0e10cSrcweir if (bRemoveProperty) 159cdf0e10cSrcweir aArguments[i++] 160cdf0e10cSrcweir <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 161cdf0e10cSrcweir "Removable")), 162cdf0e10cSrcweir -1, 163cdf0e10cSrcweir makeAny(bRemovable), 164cdf0e10cSrcweir PropertyState_DIRECT_VALUE); 165cdf0e10cSrcweir 166cdf0e10cSrcweir return aArguments; 167cdf0e10cSrcweir } 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir 171cdf0e10cSrcweir 172cdf0e10cSrcweir namespace fileaccess { 173cdf0e10cSrcweir 174cdf0e10cSrcweir 175cdf0e10cSrcweir sal_Bool isChild( const rtl::OUString& srcUnqPath, 176cdf0e10cSrcweir const rtl::OUString& dstUnqPath ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir static sal_Unicode slash = '/'; 179cdf0e10cSrcweir // Simple lexical comparison 180cdf0e10cSrcweir sal_Int32 srcL = srcUnqPath.getLength(); 181cdf0e10cSrcweir sal_Int32 dstL = dstUnqPath.getLength(); 182cdf0e10cSrcweir 183cdf0e10cSrcweir return ( 184cdf0e10cSrcweir ( srcUnqPath == dstUnqPath ) 185cdf0e10cSrcweir || 186cdf0e10cSrcweir ( ( dstL > srcL ) 187cdf0e10cSrcweir && 188cdf0e10cSrcweir ( srcUnqPath.compareTo( dstUnqPath, srcL ) == 0 ) 189cdf0e10cSrcweir && 190cdf0e10cSrcweir ( dstUnqPath[ srcL ] == slash ) ) 191cdf0e10cSrcweir ); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir 195cdf0e10cSrcweir rtl::OUString newName( 196cdf0e10cSrcweir const rtl::OUString& aNewPrefix, 197cdf0e10cSrcweir const rtl::OUString& aOldPrefix, 198cdf0e10cSrcweir const rtl::OUString& old_Name ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir sal_Int32 srcL = aOldPrefix.getLength(); 201cdf0e10cSrcweir 202cdf0e10cSrcweir rtl::OUString new_Name = old_Name.copy( srcL ); 203cdf0e10cSrcweir new_Name = ( aNewPrefix + new_Name ); 204cdf0e10cSrcweir return new_Name; 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir 208cdf0e10cSrcweir rtl::OUString getTitle( const rtl::OUString& aPath ) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir sal_Unicode slash = '/'; 211cdf0e10cSrcweir sal_Int32 lastIndex = aPath.lastIndexOf( slash ); 212cdf0e10cSrcweir return aPath.copy( lastIndex + 1 ); 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir 216cdf0e10cSrcweir rtl::OUString getParentName( const rtl::OUString& aFileName ) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir sal_Int32 lastIndex = aFileName.lastIndexOf( sal_Unicode('/') ); 219cdf0e10cSrcweir rtl::OUString aParent = aFileName.copy( 0,lastIndex ); 220cdf0e10cSrcweir 221cdf0e10cSrcweir if( aParent[ aParent.getLength()-1] == sal_Unicode(':') && aParent.getLength() == 6 ) 222cdf0e10cSrcweir aParent += rtl::OUString::createFromAscii( "/" ); 223cdf0e10cSrcweir 224cdf0e10cSrcweir if( 0 == aParent.compareToAscii( "file://" ) ) 225cdf0e10cSrcweir aParent = rtl::OUString::createFromAscii( "file:///" ); 226cdf0e10cSrcweir 227cdf0e10cSrcweir return aParent; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir 231cdf0e10cSrcweir osl::FileBase::RC osl_File_copy( const rtl::OUString& strPath, 232cdf0e10cSrcweir const rtl::OUString& strDestPath, 233cdf0e10cSrcweir sal_Bool test ) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir if( test ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir osl::DirectoryItem aItem; 238cdf0e10cSrcweir if( osl::DirectoryItem::get( strDestPath,aItem ) != osl::FileBase:: E_NOENT ) 239cdf0e10cSrcweir return osl::FileBase::E_EXIST; 240cdf0e10cSrcweir } 241cdf0e10cSrcweir 242cdf0e10cSrcweir return osl::File::copy( strPath,strDestPath ); 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir 246cdf0e10cSrcweir osl::FileBase::RC osl_File_move( const rtl::OUString& strPath, 247cdf0e10cSrcweir const rtl::OUString& strDestPath, 248cdf0e10cSrcweir sal_Bool test ) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir if( test ) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir osl::DirectoryItem aItem; 253cdf0e10cSrcweir if( osl::DirectoryItem::get( strDestPath,aItem ) != osl::FileBase:: E_NOENT ) 254cdf0e10cSrcweir return osl::FileBase::E_EXIST; 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir return osl::File::move( strPath,strDestPath ); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir void throw_handler( 261cdf0e10cSrcweir sal_Int32 errorCode, 262cdf0e10cSrcweir sal_Int32 minorCode, 263cdf0e10cSrcweir const Reference< XCommandEnvironment >& xEnv, 264cdf0e10cSrcweir const rtl::OUString& aUncPath, 265cdf0e10cSrcweir BaseContent* pContent, 266cdf0e10cSrcweir bool isHandled ) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir Reference<XCommandProcessor> xComProc(pContent); 269cdf0e10cSrcweir Any aAny; 270cdf0e10cSrcweir IOErrorCode ioErrorCode; 271cdf0e10cSrcweir 272cdf0e10cSrcweir if( errorCode == TASKHANDLER_UNSUPPORTED_COMMAND ) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir aAny <<= UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 275cdf0e10cSrcweir cancelCommandExecution( aAny,xEnv ); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir else if( errorCode == TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT || 278cdf0e10cSrcweir errorCode == TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT || 279cdf0e10cSrcweir errorCode == TASKHANDLING_WRONG_OPEN_ARGUMENT || 280cdf0e10cSrcweir errorCode == TASKHANDLING_WRONG_DELETE_ARGUMENT || 281cdf0e10cSrcweir errorCode == TASKHANDLING_WRONG_TRANSFER_ARGUMENT || 282cdf0e10cSrcweir errorCode == TASKHANDLING_WRONG_INSERT_ARGUMENT || 283cdf0e10cSrcweir errorCode == TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT ) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir IllegalArgumentException excep; 286cdf0e10cSrcweir excep.ArgumentPosition = 0; 287cdf0e10cSrcweir aAny <<= excep; 288cdf0e10cSrcweir cancelCommandExecution( 289cdf0e10cSrcweir aAny,xEnv); 290cdf0e10cSrcweir } 291cdf0e10cSrcweir else if( errorCode == TASKHANDLING_UNSUPPORTED_OPEN_MODE ) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir UnsupportedOpenModeException excep; 294cdf0e10cSrcweir excep.Mode = sal::static_int_cast< sal_Int16 >(minorCode); 295cdf0e10cSrcweir aAny <<= excep; 296cdf0e10cSrcweir cancelCommandExecution( aAny,xEnv ); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir else if(errorCode == TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND || 299cdf0e10cSrcweir errorCode == TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND || 300cdf0e10cSrcweir errorCode == TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND ) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir // What to do here? 303cdf0e10cSrcweir } 304cdf0e10cSrcweir else if( 305cdf0e10cSrcweir // error in opening file 306cdf0e10cSrcweir errorCode == TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE || 307cdf0e10cSrcweir // error in opening file 308cdf0e10cSrcweir errorCode == TASKHANDLING_NO_OPEN_FILE_FOR_WRITE || 309cdf0e10cSrcweir // error in opening file 310cdf0e10cSrcweir errorCode == TASKHANDLING_OPEN_FOR_STREAM || 311cdf0e10cSrcweir // error in opening file 312cdf0e10cSrcweir errorCode == TASKHANDLING_OPEN_FOR_INPUTSTREAM || 313cdf0e10cSrcweir // error in opening file 314cdf0e10cSrcweir errorCode == TASKHANDLING_OPEN_FILE_FOR_PAGING ) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir switch( minorCode ) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir case FileBase::E_NAMETOOLONG: 319cdf0e10cSrcweir // pathname was too long 320cdf0e10cSrcweir ioErrorCode = IOErrorCode_NAME_TOO_LONG; 321cdf0e10cSrcweir break; 322cdf0e10cSrcweir case FileBase::E_NXIO: 323cdf0e10cSrcweir // No such device or address 324cdf0e10cSrcweir case FileBase::E_NODEV: 325cdf0e10cSrcweir // No such device 326cdf0e10cSrcweir ioErrorCode = IOErrorCode_INVALID_DEVICE; 327cdf0e10cSrcweir break; 328cdf0e10cSrcweir case FileBase::E_NOENT: 329cdf0e10cSrcweir // No such file or directory 330cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_EXISTING; 331cdf0e10cSrcweir break; 332cdf0e10cSrcweir case FileBase::E_ROFS: 333cdf0e10cSrcweir // #i4735# handle ROFS transparently as ACCESS_DENIED 334cdf0e10cSrcweir case FileBase::E_ACCES: 335cdf0e10cSrcweir // permission denied<P> 336cdf0e10cSrcweir ioErrorCode = IOErrorCode_ACCESS_DENIED; 337cdf0e10cSrcweir break; 338cdf0e10cSrcweir case FileBase::E_ISDIR: 339cdf0e10cSrcweir // Is a directory<p> 340cdf0e10cSrcweir ioErrorCode = IOErrorCode_NO_FILE; 341cdf0e10cSrcweir break; 342cdf0e10cSrcweir case FileBase::E_NOTREADY: 343cdf0e10cSrcweir ioErrorCode = IOErrorCode_DEVICE_NOT_READY; 344cdf0e10cSrcweir break; 345cdf0e10cSrcweir case FileBase::E_MFILE: 346cdf0e10cSrcweir // too many open files used by the process 347cdf0e10cSrcweir case FileBase::E_NFILE: 348cdf0e10cSrcweir // too many open files in the system 349cdf0e10cSrcweir ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES; 350cdf0e10cSrcweir break; 351cdf0e10cSrcweir case FileBase::E_INVAL: 352cdf0e10cSrcweir // the format of the parameters was not valid 353cdf0e10cSrcweir ioErrorCode = IOErrorCode_INVALID_PARAMETER; 354cdf0e10cSrcweir break; 355cdf0e10cSrcweir case FileBase::E_NOMEM: 356cdf0e10cSrcweir // not enough memory for allocating structures 357cdf0e10cSrcweir ioErrorCode = IOErrorCode_OUT_OF_MEMORY; 358cdf0e10cSrcweir break; 359cdf0e10cSrcweir case FileBase::E_BUSY: 360cdf0e10cSrcweir // Text file busy 361cdf0e10cSrcweir ioErrorCode = IOErrorCode_LOCKING_VIOLATION; 362cdf0e10cSrcweir break; 363cdf0e10cSrcweir case FileBase::E_AGAIN: 364cdf0e10cSrcweir // Operation would block 365cdf0e10cSrcweir ioErrorCode = IOErrorCode_LOCKING_VIOLATION; 366cdf0e10cSrcweir break; 367cdf0e10cSrcweir case FileBase::E_NOLCK: // No record locks available 368cdf0e10cSrcweir ioErrorCode = IOErrorCode_LOCKING_VIOLATION; 369cdf0e10cSrcweir break; 370cdf0e10cSrcweir 371cdf0e10cSrcweir case FileBase::E_FAULT: // Bad address 372cdf0e10cSrcweir case FileBase::E_LOOP: // Too many symbolic links encountered 373cdf0e10cSrcweir case FileBase::E_NOSPC: // No space left on device 374cdf0e10cSrcweir case FileBase::E_INTR: // function call was interrupted 375cdf0e10cSrcweir case FileBase::E_IO: // I/O error 376cdf0e10cSrcweir case FileBase::E_MULTIHOP: // Multihop attempted 377cdf0e10cSrcweir case FileBase::E_NOLINK: // Link has been severed 378cdf0e10cSrcweir default: 379cdf0e10cSrcweir ioErrorCode = IOErrorCode_GENERAL; 380cdf0e10cSrcweir break; 381cdf0e10cSrcweir } 382cdf0e10cSrcweir 383cdf0e10cSrcweir cancelCommandExecution( 384cdf0e10cSrcweir ioErrorCode, 385cdf0e10cSrcweir generateErrorArguments(aUncPath), 386cdf0e10cSrcweir xEnv, 387cdf0e10cSrcweir rtl::OUString( 388cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 389cdf0e10cSrcweir "an error occured during file opening")), 390cdf0e10cSrcweir xComProc); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir else if( errorCode == TASKHANDLING_OPEN_FOR_DIRECTORYLISTING || 393cdf0e10cSrcweir errorCode == TASKHANDLING_OPENDIRECTORY_FOR_REMOVE ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir switch( minorCode ) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir case FileBase::E_INVAL: 398cdf0e10cSrcweir // the format of the parameters was not valid 399cdf0e10cSrcweir ioErrorCode = IOErrorCode_INVALID_PARAMETER; 400cdf0e10cSrcweir break; 401cdf0e10cSrcweir case FileBase::E_NOENT: 402cdf0e10cSrcweir // the specified path doesn't exist 403cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_EXISTING; 404cdf0e10cSrcweir break; 405cdf0e10cSrcweir case FileBase::E_NOTDIR: 406cdf0e10cSrcweir // the specified path is not an directory 407cdf0e10cSrcweir ioErrorCode = IOErrorCode_NO_DIRECTORY; 408cdf0e10cSrcweir break; 409cdf0e10cSrcweir case FileBase::E_NOMEM: 410cdf0e10cSrcweir // not enough memory for allocating structures 411cdf0e10cSrcweir ioErrorCode = IOErrorCode_OUT_OF_MEMORY; 412cdf0e10cSrcweir break; 413cdf0e10cSrcweir case FileBase::E_ROFS: 414cdf0e10cSrcweir // #i4735# handle ROFS transparently as ACCESS_DENIED 415cdf0e10cSrcweir case FileBase::E_ACCES: // permission denied 416cdf0e10cSrcweir ioErrorCode = IOErrorCode_ACCESS_DENIED; 417cdf0e10cSrcweir break; 418cdf0e10cSrcweir case FileBase::E_NOTREADY: 419cdf0e10cSrcweir ioErrorCode = IOErrorCode_DEVICE_NOT_READY; 420cdf0e10cSrcweir break; 421cdf0e10cSrcweir case FileBase::E_MFILE: 422cdf0e10cSrcweir // too many open files used by the process 423cdf0e10cSrcweir case FileBase::E_NFILE: 424cdf0e10cSrcweir // too many open files in the system 425cdf0e10cSrcweir ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES; 426cdf0e10cSrcweir break; 427cdf0e10cSrcweir case FileBase::E_NAMETOOLONG: 428cdf0e10cSrcweir // File name too long 429cdf0e10cSrcweir ioErrorCode = IOErrorCode_NAME_TOO_LONG; 430cdf0e10cSrcweir break; 431cdf0e10cSrcweir case FileBase::E_LOOP: 432cdf0e10cSrcweir // Too many symbolic links encountered<p> 433cdf0e10cSrcweir default: 434cdf0e10cSrcweir ioErrorCode = IOErrorCode_GENERAL; 435cdf0e10cSrcweir break; 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir cancelCommandExecution( 439cdf0e10cSrcweir ioErrorCode, 440cdf0e10cSrcweir generateErrorArguments(aUncPath), 441cdf0e10cSrcweir xEnv, 442cdf0e10cSrcweir rtl::OUString( 443cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 444cdf0e10cSrcweir "an error occured during opening a directory")), 445cdf0e10cSrcweir xComProc); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir else if( errorCode == TASKHANDLING_NOTCONNECTED_FOR_WRITE || 448cdf0e10cSrcweir errorCode == TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE || 449cdf0e10cSrcweir errorCode == TASKHANDLING_IOEXCEPTION_FOR_WRITE || 450cdf0e10cSrcweir errorCode == TASKHANDLING_NOTCONNECTED_FOR_PAGING || 451cdf0e10cSrcweir errorCode == TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING || 452cdf0e10cSrcweir errorCode == TASKHANDLING_IOEXCEPTION_FOR_PAGING ) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir ioErrorCode = IOErrorCode_UNKNOWN; 455cdf0e10cSrcweir cancelCommandExecution( 456cdf0e10cSrcweir ioErrorCode, 457cdf0e10cSrcweir generateErrorArguments(aUncPath), 458cdf0e10cSrcweir xEnv, 459cdf0e10cSrcweir rtl::OUString( 460cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 461cdf0e10cSrcweir "an error occured writing or reading from a file")), 462cdf0e10cSrcweir xComProc ); 463cdf0e10cSrcweir } 464cdf0e10cSrcweir else if( errorCode == TASKHANDLING_FILEIOERROR_FOR_NO_SPACE ) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir ioErrorCode = IOErrorCode_OUT_OF_DISK_SPACE; 467cdf0e10cSrcweir cancelCommandExecution( 468cdf0e10cSrcweir ioErrorCode, 469cdf0e10cSrcweir generateErrorArguments(aUncPath), 470cdf0e10cSrcweir xEnv, 471cdf0e10cSrcweir rtl::OUString( 472cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 473cdf0e10cSrcweir "device full")), 474cdf0e10cSrcweir xComProc); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir else if( errorCode == TASKHANDLING_FILEIOERROR_FOR_WRITE || 477cdf0e10cSrcweir errorCode == TASKHANDLING_READING_FILE_FOR_PAGING ) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir switch( minorCode ) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir case FileBase::E_INVAL: 482cdf0e10cSrcweir // the format of the parameters was not valid 483cdf0e10cSrcweir ioErrorCode = IOErrorCode_INVALID_PARAMETER; 484cdf0e10cSrcweir break; 485cdf0e10cSrcweir case FileBase::E_FBIG: 486cdf0e10cSrcweir // File too large 487cdf0e10cSrcweir ioErrorCode = IOErrorCode_CANT_WRITE; 488cdf0e10cSrcweir break; 489cdf0e10cSrcweir case FileBase::E_NOSPC: 490cdf0e10cSrcweir // No space left on device 491cdf0e10cSrcweir ioErrorCode = IOErrorCode_OUT_OF_DISK_SPACE; 492cdf0e10cSrcweir break; 493cdf0e10cSrcweir case FileBase::E_NXIO: 494cdf0e10cSrcweir // No such device or address 495cdf0e10cSrcweir ioErrorCode = IOErrorCode_INVALID_DEVICE; 496cdf0e10cSrcweir break; 497cdf0e10cSrcweir case FileBase::E_NOLINK: 498cdf0e10cSrcweir // Link has been severed 499cdf0e10cSrcweir case FileBase::E_ISDIR: 500cdf0e10cSrcweir // Is a directory 501cdf0e10cSrcweir ioErrorCode = IOErrorCode_NO_FILE; 502cdf0e10cSrcweir break; 503cdf0e10cSrcweir case FileBase::E_AGAIN: 504cdf0e10cSrcweir // Operation would block 505cdf0e10cSrcweir ioErrorCode = IOErrorCode_LOCKING_VIOLATION; 506cdf0e10cSrcweir break; 507cdf0e10cSrcweir case FileBase::E_TIMEDOUT: 508cdf0e10cSrcweir ioErrorCode = IOErrorCode_DEVICE_NOT_READY; 509cdf0e10cSrcweir break; 510cdf0e10cSrcweir case FileBase::E_NOLCK: // No record locks available 511cdf0e10cSrcweir ioErrorCode = IOErrorCode_LOCKING_VIOLATION; 512cdf0e10cSrcweir break; 513cdf0e10cSrcweir case FileBase::E_IO: // I/O error 514cdf0e10cSrcweir case FileBase::E_BADF: // Bad file 515cdf0e10cSrcweir case FileBase::E_FAULT: // Bad address 516cdf0e10cSrcweir case FileBase::E_INTR: // function call was interrupted 517cdf0e10cSrcweir default: 518cdf0e10cSrcweir ioErrorCode = IOErrorCode_GENERAL; 519cdf0e10cSrcweir break; 520cdf0e10cSrcweir } 521cdf0e10cSrcweir cancelCommandExecution( 522cdf0e10cSrcweir ioErrorCode, 523cdf0e10cSrcweir generateErrorArguments(aUncPath), 524cdf0e10cSrcweir xEnv, 525cdf0e10cSrcweir rtl::OUString( 526cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 527cdf0e10cSrcweir "an error occured during opening a file")), 528cdf0e10cSrcweir xComProc); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir else if( errorCode == TASKHANDLING_NONAMESET_INSERT_COMMAND || 531cdf0e10cSrcweir errorCode == TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND ) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir Sequence< ::rtl::OUString > aSeq( 1 ); 534cdf0e10cSrcweir aSeq[0] = 535cdf0e10cSrcweir ( errorCode == TASKHANDLING_NONAMESET_INSERT_COMMAND ) ? 536cdf0e10cSrcweir rtl::OUString::createFromAscii( "Title" ) : 537cdf0e10cSrcweir rtl::OUString::createFromAscii( "ContentType" ); 538cdf0e10cSrcweir 539cdf0e10cSrcweir aAny <<= MissingPropertiesException( 540cdf0e10cSrcweir rtl::OUString( 541cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 542cdf0e10cSrcweir "a property is missing necessary" 543cdf0e10cSrcweir "to create a content")), 544cdf0e10cSrcweir xComProc, 545cdf0e10cSrcweir aSeq); 546cdf0e10cSrcweir cancelCommandExecution(aAny,xEnv); 547cdf0e10cSrcweir } 548cdf0e10cSrcweir else if( errorCode == TASKHANDLING_FILESIZE_FOR_WRITE ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir switch( minorCode ) 551cdf0e10cSrcweir { 552cdf0e10cSrcweir case FileBase::E_INVAL: 553cdf0e10cSrcweir // the format of the parameters was not valid 554cdf0e10cSrcweir case FileBase::E_OVERFLOW: 555cdf0e10cSrcweir // The resulting file offset would be a value which cannot 556cdf0e10cSrcweir // be represented correctly for regular files 557cdf0e10cSrcweir ioErrorCode = IOErrorCode_INVALID_PARAMETER; 558cdf0e10cSrcweir break; 559cdf0e10cSrcweir default: 560cdf0e10cSrcweir ioErrorCode = IOErrorCode_GENERAL; 561cdf0e10cSrcweir break; 562cdf0e10cSrcweir } 563cdf0e10cSrcweir cancelCommandExecution( 564cdf0e10cSrcweir ioErrorCode, 565cdf0e10cSrcweir generateErrorArguments(aUncPath), 566cdf0e10cSrcweir xEnv, 567cdf0e10cSrcweir rtl::OUString( 568cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 569cdf0e10cSrcweir "there were problems with the filesize")), 570cdf0e10cSrcweir xComProc); 571cdf0e10cSrcweir } 572cdf0e10cSrcweir else if(errorCode == TASKHANDLING_INPUTSTREAM_FOR_WRITE) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir Reference<XInterface> xContext(xComProc,UNO_QUERY); 575cdf0e10cSrcweir aAny <<= 576cdf0e10cSrcweir MissingInputStreamException( 577cdf0e10cSrcweir rtl::OUString( 578cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 579cdf0e10cSrcweir "the inputstream is missing necessary" 580cdf0e10cSrcweir "to create a content")), 581cdf0e10cSrcweir xContext); 582cdf0e10cSrcweir cancelCommandExecution(aAny,xEnv); 583cdf0e10cSrcweir } 584cdf0e10cSrcweir else if( errorCode == TASKHANDLING_NOREPLACE_FOR_WRITE ) 585cdf0e10cSrcweir // Overwrite = false and file exists 586cdf0e10cSrcweir { 587cdf0e10cSrcweir NameClashException excep; 588cdf0e10cSrcweir excep.Name = getTitle(aUncPath); 589cdf0e10cSrcweir excep.Classification = InteractionClassification_ERROR; 590cdf0e10cSrcweir Reference<XInterface> xContext(xComProc,UNO_QUERY); 591cdf0e10cSrcweir excep.Context = xContext; 592cdf0e10cSrcweir excep.Message = rtl::OUString( 593cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 594cdf0e10cSrcweir "file exists and overwrite forbidden")); 595cdf0e10cSrcweir aAny <<= excep; 596cdf0e10cSrcweir cancelCommandExecution( aAny,xEnv ); 597cdf0e10cSrcweir } 598cdf0e10cSrcweir else if( errorCode == TASKHANDLING_INVALID_NAME_MKDIR ) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir InteractiveAugmentedIOException excep; 601cdf0e10cSrcweir excep.Code = IOErrorCode_INVALID_CHARACTER; 602cdf0e10cSrcweir PropertyValue prop; 603cdf0e10cSrcweir prop.Name = rtl::OUString::createFromAscii("ResourceName"); 604cdf0e10cSrcweir prop.Handle = -1; 605cdf0e10cSrcweir rtl::OUString m_aClashingName( 606cdf0e10cSrcweir rtl::Uri::decode( 607cdf0e10cSrcweir getTitle(aUncPath), 608cdf0e10cSrcweir rtl_UriDecodeWithCharset, 609cdf0e10cSrcweir RTL_TEXTENCODING_UTF8)); 610cdf0e10cSrcweir prop.Value <<= m_aClashingName; 611cdf0e10cSrcweir Sequence<Any> seq(1); 612cdf0e10cSrcweir seq[0] <<= prop; 613cdf0e10cSrcweir excep.Arguments = seq; 614cdf0e10cSrcweir excep.Classification = InteractionClassification_ERROR; 615cdf0e10cSrcweir Reference<XInterface> xContext(xComProc,UNO_QUERY); 616cdf0e10cSrcweir excep.Context = xContext; 617cdf0e10cSrcweir excep.Message = rtl::OUString( 618cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 619cdf0e10cSrcweir "the name contained invalid characters")); 620cdf0e10cSrcweir if(isHandled) 621cdf0e10cSrcweir throw excep; 622cdf0e10cSrcweir else { 623cdf0e10cSrcweir aAny <<= excep; 624cdf0e10cSrcweir cancelCommandExecution( aAny,xEnv ); 625cdf0e10cSrcweir } 626cdf0e10cSrcweir // ioErrorCode = IOErrorCode_INVALID_CHARACTER; 627cdf0e10cSrcweir // cancelCommandExecution( 628cdf0e10cSrcweir // ioErrorCode, 629cdf0e10cSrcweir // generateErrorArguments(aUncPath), 630cdf0e10cSrcweir // xEnv, 631cdf0e10cSrcweir // rtl::OUString( 632cdf0e10cSrcweir // RTL_CONSTASCII_USTRINGPARAM( 633cdf0e10cSrcweir // "the name contained invalid characters")), 634cdf0e10cSrcweir // xComProc ); 635cdf0e10cSrcweir } 636cdf0e10cSrcweir else if( errorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR ) 637cdf0e10cSrcweir { 638cdf0e10cSrcweir NameClashException excep; 639cdf0e10cSrcweir excep.Name = getTitle(aUncPath); 640cdf0e10cSrcweir excep.Classification = InteractionClassification_ERROR; 641cdf0e10cSrcweir Reference<XInterface> xContext(xComProc,UNO_QUERY); 642cdf0e10cSrcweir excep.Context = xContext; 643cdf0e10cSrcweir excep.Message = rtl::OUString( 644cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 645cdf0e10cSrcweir "folder exists and overwrite forbidden")); 646cdf0e10cSrcweir if(isHandled) 647cdf0e10cSrcweir throw excep; 648cdf0e10cSrcweir else { 649cdf0e10cSrcweir aAny <<= excep; 650cdf0e10cSrcweir cancelCommandExecution( aAny,xEnv ); 651cdf0e10cSrcweir } 652cdf0e10cSrcweir // ioErrorCode = IOErrorCode_ALREADY_EXISTING; 653cdf0e10cSrcweir // cancelCommandExecution( 654cdf0e10cSrcweir // ioErrorCode, 655cdf0e10cSrcweir // generateErrorArguments(aUncPath), 656cdf0e10cSrcweir // xEnv, 657cdf0e10cSrcweir // rtl::OUString( 658cdf0e10cSrcweir // RTL_CONSTASCII_USTRINGPARAM( 659cdf0e10cSrcweir // "the folder exists")), 660cdf0e10cSrcweir // xComProc ); 661cdf0e10cSrcweir } 662cdf0e10cSrcweir else if( errorCode == TASKHANDLING_ENSUREDIR_FOR_WRITE || 663cdf0e10cSrcweir errorCode == TASKHANDLING_CREATEDIRECTORY_MKDIR ) 664cdf0e10cSrcweir { 665cdf0e10cSrcweir switch( minorCode ) 666cdf0e10cSrcweir { 667cdf0e10cSrcweir case FileBase::E_ACCES: 668cdf0e10cSrcweir ioErrorCode = IOErrorCode_ACCESS_DENIED; 669cdf0e10cSrcweir break; 670cdf0e10cSrcweir case FileBase::E_ROFS: 671cdf0e10cSrcweir ioErrorCode = IOErrorCode_WRITE_PROTECTED; 672cdf0e10cSrcweir break; 673cdf0e10cSrcweir case FileBase::E_NAMETOOLONG: 674cdf0e10cSrcweir ioErrorCode = IOErrorCode_NAME_TOO_LONG; 675cdf0e10cSrcweir break; 676cdf0e10cSrcweir default: 677cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_EXISTING_PATH; 678cdf0e10cSrcweir break; 679cdf0e10cSrcweir } 680cdf0e10cSrcweir cancelCommandExecution( 681cdf0e10cSrcweir ioErrorCode, 682cdf0e10cSrcweir generateErrorArguments(getParentName(aUncPath)), 683cdf0e10cSrcweir //TODO! ok to supply physical URL to getParentName()? 684cdf0e10cSrcweir xEnv, 685cdf0e10cSrcweir rtl::OUString( 686cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 687cdf0e10cSrcweir "a folder could not be created")), 688cdf0e10cSrcweir xComProc ); 689cdf0e10cSrcweir } 690cdf0e10cSrcweir else if( errorCode == TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE || 691cdf0e10cSrcweir errorCode == TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE || 692cdf0e10cSrcweir errorCode == TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE ) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir switch( minorCode ) 695cdf0e10cSrcweir { 696cdf0e10cSrcweir case FileBase::E_INVAL: // the format of the parameters was not valid 697cdf0e10cSrcweir ioErrorCode = IOErrorCode_INVALID_PARAMETER; 698cdf0e10cSrcweir break; 699cdf0e10cSrcweir case FileBase::E_NOMEM: // not enough memory for allocating structures 700cdf0e10cSrcweir ioErrorCode = IOErrorCode_OUT_OF_MEMORY; 701cdf0e10cSrcweir break; 702cdf0e10cSrcweir case FileBase::E_ROFS: // #i4735# handle ROFS transparently as ACCESS_DENIED 703cdf0e10cSrcweir case FileBase::E_ACCES: // permission denied 704cdf0e10cSrcweir ioErrorCode = IOErrorCode_ACCESS_DENIED; 705cdf0e10cSrcweir break; 706cdf0e10cSrcweir case FileBase::E_MFILE: // too many open files used by the process 707cdf0e10cSrcweir case FileBase::E_NFILE: // too many open files in the system 708cdf0e10cSrcweir ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES; 709cdf0e10cSrcweir break; 710cdf0e10cSrcweir case FileBase::E_NOLINK: // Link has been severed 711cdf0e10cSrcweir case FileBase::E_NOENT: // No such file or directory 712cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_EXISTING; 713cdf0e10cSrcweir break; 714cdf0e10cSrcweir case FileBase::E_NAMETOOLONG: // File name too long 715cdf0e10cSrcweir ioErrorCode = IOErrorCode_NAME_TOO_LONG; 716cdf0e10cSrcweir break; 717cdf0e10cSrcweir case FileBase::E_NOTDIR: // A component of the path prefix of path is not a directory 718cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_EXISTING_PATH; 719cdf0e10cSrcweir break; 720cdf0e10cSrcweir case FileBase::E_LOOP: // Too many symbolic links encountered 721cdf0e10cSrcweir case FileBase::E_IO: // I/O error 722cdf0e10cSrcweir case FileBase::E_MULTIHOP: // Multihop attempted 723cdf0e10cSrcweir case FileBase::E_FAULT: // Bad address 724cdf0e10cSrcweir case FileBase::E_INTR: // function call was interrupted 725cdf0e10cSrcweir case FileBase::E_NOSYS: // Function not implemented 726cdf0e10cSrcweir case FileBase::E_NOSPC: // No space left on device 727cdf0e10cSrcweir case FileBase::E_NXIO: // No such device or address 728cdf0e10cSrcweir case FileBase::E_OVERFLOW: // Value too large for defined data type 729cdf0e10cSrcweir case FileBase::E_BADF: // Invalid oslDirectoryItem parameter 730cdf0e10cSrcweir default: 731cdf0e10cSrcweir ioErrorCode = IOErrorCode_GENERAL; 732cdf0e10cSrcweir break; 733cdf0e10cSrcweir } 734cdf0e10cSrcweir cancelCommandExecution( 735cdf0e10cSrcweir ioErrorCode, 736cdf0e10cSrcweir generateErrorArguments(aUncPath), 737cdf0e10cSrcweir xEnv, 738cdf0e10cSrcweir rtl::OUString( 739cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 740cdf0e10cSrcweir "a file status object could not be filled")), 741cdf0e10cSrcweir xComProc ); 742cdf0e10cSrcweir } 743cdf0e10cSrcweir else if( errorCode == TASKHANDLING_DELETEFILE_FOR_REMOVE || 744cdf0e10cSrcweir errorCode == TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE ) 745cdf0e10cSrcweir { 746cdf0e10cSrcweir switch( minorCode ) 747cdf0e10cSrcweir { 748cdf0e10cSrcweir case FileBase::E_INVAL: // the format of the parameters was not valid 749cdf0e10cSrcweir ioErrorCode = IOErrorCode_INVALID_PARAMETER; 750cdf0e10cSrcweir break; 751cdf0e10cSrcweir case FileBase::E_NOMEM: // not enough memory for allocating structures 752cdf0e10cSrcweir ioErrorCode = IOErrorCode_OUT_OF_MEMORY; 753cdf0e10cSrcweir break; 754cdf0e10cSrcweir case FileBase::E_ACCES: // Permission denied 755cdf0e10cSrcweir ioErrorCode = IOErrorCode_ACCESS_DENIED; 756cdf0e10cSrcweir break; 757cdf0e10cSrcweir case FileBase::E_PERM: // Operation not permitted 758cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_SUPPORTED; 759cdf0e10cSrcweir break; 760cdf0e10cSrcweir case FileBase::E_NAMETOOLONG: // File name too long 761cdf0e10cSrcweir ioErrorCode = IOErrorCode_NAME_TOO_LONG; 762cdf0e10cSrcweir break; 763cdf0e10cSrcweir case FileBase::E_NOLINK: // Link has been severed 764cdf0e10cSrcweir case FileBase::E_NOENT: // No such file or directory 765cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_EXISTING; 766cdf0e10cSrcweir break; 767cdf0e10cSrcweir case FileBase::E_ISDIR: // Is a directory 768cdf0e10cSrcweir case FileBase::E_ROFS: // Read-only file system 769cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_SUPPORTED; 770cdf0e10cSrcweir break; 771cdf0e10cSrcweir case FileBase::E_BUSY: // Device or resource busy 772cdf0e10cSrcweir ioErrorCode = IOErrorCode_LOCKING_VIOLATION; 773cdf0e10cSrcweir break; 774cdf0e10cSrcweir case FileBase::E_FAULT: // Bad address 775cdf0e10cSrcweir case FileBase::E_LOOP: // Too many symbolic links encountered 776cdf0e10cSrcweir case FileBase::E_IO: // I/O error 777cdf0e10cSrcweir case FileBase::E_INTR: // function call was interrupted 778cdf0e10cSrcweir case FileBase::E_MULTIHOP: // Multihop attempted 779cdf0e10cSrcweir default: 780cdf0e10cSrcweir ioErrorCode = IOErrorCode_GENERAL; 781cdf0e10cSrcweir break; 782cdf0e10cSrcweir } 783cdf0e10cSrcweir cancelCommandExecution( 784cdf0e10cSrcweir ioErrorCode, 785cdf0e10cSrcweir generateErrorArguments(aUncPath), 786cdf0e10cSrcweir xEnv, 787cdf0e10cSrcweir rtl::OUString( 788cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 789cdf0e10cSrcweir "a file or directory could not be deleted")), 790cdf0e10cSrcweir xComProc ); 791cdf0e10cSrcweir } 792cdf0e10cSrcweir else if( errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCE || 793cdf0e10cSrcweir errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT || 794cdf0e10cSrcweir errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCE || 795cdf0e10cSrcweir errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT || 796cdf0e10cSrcweir errorCode == TASKHANDLING_TRANSFER_DESTFILETYPE || 797cdf0e10cSrcweir errorCode == TASKHANDLING_FILETYPE_FOR_REMOVE || 798cdf0e10cSrcweir errorCode == TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE || 799cdf0e10cSrcweir errorCode == TASKHANDLING_TRANSFER_INVALIDURL ) 800cdf0e10cSrcweir { 801cdf0e10cSrcweir rtl::OUString aMsg; 802cdf0e10cSrcweir switch( minorCode ) 803cdf0e10cSrcweir { 804cdf0e10cSrcweir case FileBase::E_NOENT: // No such file or directory 805cdf0e10cSrcweir if ( errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCE || 806cdf0e10cSrcweir errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT || 807cdf0e10cSrcweir errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCE || 808cdf0e10cSrcweir errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT ) 809cdf0e10cSrcweir { 810cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_EXISTING; 811cdf0e10cSrcweir aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 812cdf0e10cSrcweir "source file/folder does not exist")); 813cdf0e10cSrcweir break; 814cdf0e10cSrcweir } 815cdf0e10cSrcweir else 816cdf0e10cSrcweir { 817cdf0e10cSrcweir ioErrorCode = IOErrorCode_GENERAL; 818cdf0e10cSrcweir aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 819cdf0e10cSrcweir "a general error during transfer command")); 820cdf0e10cSrcweir break; 821cdf0e10cSrcweir } 822cdf0e10cSrcweir default: 823cdf0e10cSrcweir ioErrorCode = IOErrorCode_GENERAL; 824cdf0e10cSrcweir aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 825cdf0e10cSrcweir "a general error during transfer command")); 826cdf0e10cSrcweir break; 827cdf0e10cSrcweir } 828cdf0e10cSrcweir cancelCommandExecution( 829cdf0e10cSrcweir ioErrorCode, 830cdf0e10cSrcweir generateErrorArguments(aUncPath), 831cdf0e10cSrcweir xEnv, 832cdf0e10cSrcweir aMsg, 833cdf0e10cSrcweir xComProc ); 834cdf0e10cSrcweir } 835cdf0e10cSrcweir else if( errorCode == TASKHANDLING_TRANSFER_ACCESSINGROOT ) 836cdf0e10cSrcweir { 837cdf0e10cSrcweir ioErrorCode = IOErrorCode_WRITE_PROTECTED; 838cdf0e10cSrcweir cancelCommandExecution( 839cdf0e10cSrcweir ioErrorCode, 840cdf0e10cSrcweir generateErrorArguments(aUncPath), 841cdf0e10cSrcweir xEnv, 842cdf0e10cSrcweir rtl::OUString( 843cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 844cdf0e10cSrcweir "accessing the root during transfer")), 845cdf0e10cSrcweir xComProc ); 846cdf0e10cSrcweir } 847cdf0e10cSrcweir else if( errorCode == TASKHANDLING_TRANSFER_INVALIDSCHEME ) 848cdf0e10cSrcweir { 849cdf0e10cSrcweir Reference<XInterface> xContext(xComProc,UNO_QUERY); 850cdf0e10cSrcweir 851cdf0e10cSrcweir aAny <<= 852cdf0e10cSrcweir InteractiveBadTransferURLException( 853cdf0e10cSrcweir rtl::OUString( 854cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 855cdf0e10cSrcweir "bad tranfer url")), 856cdf0e10cSrcweir xContext); 857cdf0e10cSrcweir cancelCommandExecution( aAny,xEnv ); 858cdf0e10cSrcweir } 859cdf0e10cSrcweir else if( errorCode == TASKHANDLING_OVERWRITE_FOR_MOVE || 860cdf0e10cSrcweir errorCode == TASKHANDLING_OVERWRITE_FOR_COPY || 861cdf0e10cSrcweir errorCode == TASKHANDLING_NAMECLASHMOVE_FOR_MOVE || 862cdf0e10cSrcweir errorCode == TASKHANDLING_NAMECLASHMOVE_FOR_COPY || 863cdf0e10cSrcweir errorCode == TASKHANDLING_KEEPERROR_FOR_MOVE || 864cdf0e10cSrcweir errorCode == TASKHANDLING_KEEPERROR_FOR_COPY || 865cdf0e10cSrcweir errorCode == TASKHANDLING_RENAME_FOR_MOVE || 866cdf0e10cSrcweir errorCode == TASKHANDLING_RENAME_FOR_COPY || 867cdf0e10cSrcweir errorCode == TASKHANDLING_RENAMEMOVE_FOR_MOVE || 868cdf0e10cSrcweir errorCode == TASKHANDLING_RENAMEMOVE_FOR_COPY ) 869cdf0e10cSrcweir { 870cdf0e10cSrcweir rtl::OUString aMsg(RTL_CONSTASCII_USTRINGPARAM( 871cdf0e10cSrcweir "general error during transfer")); 872cdf0e10cSrcweir 873cdf0e10cSrcweir switch( minorCode ) 874cdf0e10cSrcweir { 875cdf0e10cSrcweir case FileBase::E_EXIST: 876cdf0e10cSrcweir ioErrorCode = IOErrorCode_ALREADY_EXISTING; 877cdf0e10cSrcweir break; 878cdf0e10cSrcweir case FileBase::E_INVAL: // the format of the parameters was not valid 879cdf0e10cSrcweir ioErrorCode = IOErrorCode_INVALID_PARAMETER; 880cdf0e10cSrcweir break; 881cdf0e10cSrcweir case FileBase::E_NOMEM: // not enough memory for allocating structures 882cdf0e10cSrcweir ioErrorCode = IOErrorCode_OUT_OF_MEMORY; 883cdf0e10cSrcweir break; 884cdf0e10cSrcweir case FileBase::E_ACCES: // Permission denied 885cdf0e10cSrcweir ioErrorCode = IOErrorCode_ACCESS_DENIED; 886cdf0e10cSrcweir break; 887cdf0e10cSrcweir case FileBase::E_PERM: // Operation not permitted 888cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_SUPPORTED; 889cdf0e10cSrcweir break; 890cdf0e10cSrcweir case FileBase::E_NAMETOOLONG: // File name too long 891cdf0e10cSrcweir ioErrorCode = IOErrorCode_NAME_TOO_LONG; 892cdf0e10cSrcweir break; 893cdf0e10cSrcweir case FileBase::E_NOENT: // No such file or directory 894cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_EXISTING; 895cdf0e10cSrcweir aMsg = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 896cdf0e10cSrcweir "file/folder does not exist")); 897cdf0e10cSrcweir break; 898cdf0e10cSrcweir case FileBase::E_ROFS: // Read-only file system<p> 899cdf0e10cSrcweir ioErrorCode = IOErrorCode_NOT_EXISTING; 900cdf0e10cSrcweir break; 901cdf0e10cSrcweir default: 902cdf0e10cSrcweir ioErrorCode = IOErrorCode_GENERAL; 903cdf0e10cSrcweir break; 904cdf0e10cSrcweir } 905cdf0e10cSrcweir cancelCommandExecution( 906cdf0e10cSrcweir ioErrorCode, 907cdf0e10cSrcweir generateErrorArguments(aUncPath), 908cdf0e10cSrcweir xEnv, 909cdf0e10cSrcweir aMsg, 910cdf0e10cSrcweir xComProc ); 911cdf0e10cSrcweir } 912cdf0e10cSrcweir else if( errorCode == TASKHANDLING_NAMECLASH_FOR_COPY || 913cdf0e10cSrcweir errorCode == TASKHANDLING_NAMECLASH_FOR_MOVE ) 914cdf0e10cSrcweir { 915cdf0e10cSrcweir NameClashException excep; 916cdf0e10cSrcweir excep.Name = getTitle(aUncPath); 917cdf0e10cSrcweir excep.Classification = InteractionClassification_ERROR; 918cdf0e10cSrcweir Reference<XInterface> xContext(xComProc,UNO_QUERY); 919cdf0e10cSrcweir excep.Context = xContext; 920cdf0e10cSrcweir excep.Message = rtl::OUString( 921cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 922cdf0e10cSrcweir "name clash during copy or move")); 923cdf0e10cSrcweir aAny <<= excep; 924cdf0e10cSrcweir 925cdf0e10cSrcweir cancelCommandExecution(aAny,xEnv); 926cdf0e10cSrcweir } 927cdf0e10cSrcweir else if( errorCode == TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE || 928cdf0e10cSrcweir errorCode == TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY ) 929cdf0e10cSrcweir { 930cdf0e10cSrcweir Reference<XInterface> xContext( 931cdf0e10cSrcweir xComProc,UNO_QUERY); 932cdf0e10cSrcweir UnsupportedNameClashException excep; 933cdf0e10cSrcweir excep.NameClash = minorCode; 934cdf0e10cSrcweir excep.Context = xContext; 935cdf0e10cSrcweir excep.Message = rtl::OUString( 936cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 937cdf0e10cSrcweir "name clash value not supported during copy or move")); 938cdf0e10cSrcweir 939cdf0e10cSrcweir aAny <<= excep; 940cdf0e10cSrcweir cancelCommandExecution(aAny,xEnv); 941cdf0e10cSrcweir } 942cdf0e10cSrcweir else 943cdf0e10cSrcweir { 944cdf0e10cSrcweir // case TASKHANDLER_NO_ERROR: 945cdf0e10cSrcweir return; 946cdf0e10cSrcweir } 947cdf0e10cSrcweir } 948cdf0e10cSrcweir 949cdf0e10cSrcweir 950cdf0e10cSrcweir } // end namespace fileaccess 951