1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: filglob.cxx,v $
10 * $Revision: 1.26.4.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
34 #include "filglob.hxx"
35 #ifndef _FILERROR_HXX_
36 #include "filerror.hxx"
40 #include <osl/file.hxx>
41 #ifndef INCLUDED_STL_VECTOR
43 #define INCLUDED_STL_VECTOR
45 #include <ucbhelper/cancelcommandexecution.hxx>
46 #include <com/sun/star/ucb/CommandAbortedException.hpp>
47 #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
48 #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
49 #include <com/sun/star/lang/IllegalArgumentException.hpp>
50 #include <com/sun/star/ucb/IOErrorCode.hpp>
51 #include <com/sun/star/ucb/MissingPropertiesException.hpp>
52 #include <com/sun/star/ucb/MissingInputStreamException.hpp>
53 #include <com/sun/star/ucb/NameClashException.hpp>
54 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
55 #include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
56 #include "com/sun/star/beans/PropertyState.hpp"
57 #include "com/sun/star/beans/PropertyValue.hpp"
58 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
59 #include "com/sun/star/uno/Any.hxx"
60 #include "com/sun/star/uno/Sequence.hxx"
61 #include "osl/diagnose.h"
62 #include "rtl/ustrbuf.hxx"
63 #include <rtl/uri.hxx>
64 #include <rtl/ustring.hxx>
65 #include "sal/types.h"
67 using namespace ucbhelper
;
69 using namespace ::com::sun::star
;
70 using namespace com::sun::star::task
;
71 using namespace com::sun::star::beans
;
72 using namespace com::sun::star::lang
;
73 using namespace com::sun::star::uno
;
74 using namespace com::sun::star::ucb
;
78 Sequence
< Any
> generateErrorArguments(
79 rtl::OUString
const & rPhysicalUrl
)
81 rtl::OUString aResourceName
;
82 rtl::OUString aResourceType
;
84 bool bResourceName
= false;
85 bool bResourceType
= false;
86 bool bRemoveProperty
= false;
88 if (osl::FileBase::getSystemPathFromFileURL(
91 == osl::FileBase::E_None
)
94 // The resource types "folder" (i.e., directory) and
95 // "volume" seem to be
96 // the most interesting when producing meaningful error messages:
97 osl::DirectoryItem aItem
;
98 if (osl::DirectoryItem::get(rPhysicalUrl
, aItem
) ==
99 osl::FileBase::E_None
)
101 osl::FileStatus
aStatus( FileStatusMask_Type
);
102 if (aItem
.getFileStatus(aStatus
) == osl::FileBase::E_None
)
103 switch (aStatus
.getFileType())
105 case osl::FileStatus::Directory
:
108 RTL_CONSTASCII_USTRINGPARAM("folder"));
109 bResourceType
= true;
112 case osl::FileStatus::Volume
:
116 RTL_CONSTASCII_USTRINGPARAM("volume"));
117 bResourceType
= true;
118 osl::VolumeInfo
aVolumeInfo(
119 VolumeInfoMask_Attributes
);
120 if( osl::Directory::getVolumeInfo(
121 rPhysicalUrl
,aVolumeInfo
) ==
122 osl::FileBase::E_None
)
124 bRemovable
= aVolumeInfo
.getRemoveableFlag();
125 bRemoveProperty
= true;
129 case osl::FileStatus::Regular
:
130 case osl::FileStatus::Fifo
:
131 case osl::FileStatus::Socket
:
132 case osl::FileStatus::Link
:
133 case osl::FileStatus::Special
:
134 case osl::FileStatus::Unknown
:
135 // do nothing for now
140 Sequence
< Any
> aArguments( 1 +
141 (bResourceName
? 1 : 0) +
142 (bResourceType
? 1 : 0) +
143 (bRemoveProperty
? 1 : 0) );
146 <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
149 makeAny(rPhysicalUrl
),
150 PropertyState_DIRECT_VALUE
);
153 <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
156 makeAny(aResourceName
),
157 PropertyState_DIRECT_VALUE
);
160 <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
163 makeAny(aResourceType
),
164 PropertyState_DIRECT_VALUE
);
167 <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
171 PropertyState_DIRECT_VALUE
);
179 namespace fileaccess
{
182 sal_Bool
isChild( const rtl::OUString
& srcUnqPath
,
183 const rtl::OUString
& dstUnqPath
)
185 static sal_Unicode slash
= '/';
186 // Simple lexical comparison
187 sal_Int32 srcL
= srcUnqPath
.getLength();
188 sal_Int32 dstL
= dstUnqPath
.getLength();
191 ( srcUnqPath
== dstUnqPath
)
195 ( srcUnqPath
.compareTo( dstUnqPath
, srcL
) == 0 )
197 ( dstUnqPath
[ srcL
] == slash
) )
202 rtl::OUString
newName(
203 const rtl::OUString
& aNewPrefix
,
204 const rtl::OUString
& aOldPrefix
,
205 const rtl::OUString
& old_Name
)
207 sal_Int32 srcL
= aOldPrefix
.getLength();
209 rtl::OUString new_Name
= old_Name
.copy( srcL
);
210 new_Name
= ( aNewPrefix
+ new_Name
);
215 rtl::OUString
getTitle( const rtl::OUString
& aPath
)
217 sal_Unicode slash
= '/';
218 sal_Int32 lastIndex
= aPath
.lastIndexOf( slash
);
219 return aPath
.copy( lastIndex
+ 1 );
223 rtl::OUString
getParentName( const rtl::OUString
& aFileName
)
225 sal_Int32 lastIndex
= aFileName
.lastIndexOf( sal_Unicode('/') );
226 rtl::OUString aParent
= aFileName
.copy( 0,lastIndex
);
228 if( aParent
[ aParent
.getLength()-1] == sal_Unicode(':') && aParent
.getLength() == 6 )
229 aParent
+= rtl::OUString::createFromAscii( "/" );
231 if( 0 == aParent
.compareToAscii( "file://" ) )
232 aParent
= rtl::OUString::createFromAscii( "file:///" );
238 osl::FileBase::RC
osl_File_copy( const rtl::OUString
& strPath
,
239 const rtl::OUString
& strDestPath
,
244 osl::DirectoryItem aItem
;
245 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
246 return osl::FileBase::E_EXIST
;
249 return osl::File::copy( strPath
,strDestPath
);
253 osl::FileBase::RC
osl_File_move( const rtl::OUString
& strPath
,
254 const rtl::OUString
& strDestPath
,
259 osl::DirectoryItem aItem
;
260 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
261 return osl::FileBase::E_EXIST
;
264 return osl::File::move( strPath
,strDestPath
);
270 const Reference
< XCommandEnvironment
>& xEnv
,
271 const rtl::OUString
& aUncPath
,
272 BaseContent
* pContent
,
275 Reference
<XCommandProcessor
> xComProc(pContent
);
277 IOErrorCode ioErrorCode
;
279 if( errorCode
== TASKHANDLER_UNSUPPORTED_COMMAND
)
281 aAny
<<= UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX
) ), uno::Reference
< uno::XInterface
>() );
282 cancelCommandExecution( aAny
,xEnv
);
284 else if( errorCode
== TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT
||
285 errorCode
== TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT
||
286 errorCode
== TASKHANDLING_WRONG_OPEN_ARGUMENT
||
287 errorCode
== TASKHANDLING_WRONG_DELETE_ARGUMENT
||
288 errorCode
== TASKHANDLING_WRONG_TRANSFER_ARGUMENT
||
289 errorCode
== TASKHANDLING_WRONG_INSERT_ARGUMENT
)
291 IllegalArgumentException excep
;
292 excep
.ArgumentPosition
= 0;
294 cancelCommandExecution(
297 else if( errorCode
== TASKHANDLING_UNSUPPORTED_OPEN_MODE
)
299 UnsupportedOpenModeException excep
;
300 excep
.Mode
= sal::static_int_cast
< sal_Int16
>(minorCode
);
302 cancelCommandExecution( aAny
,xEnv
);
304 else if(errorCode
== TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND
||
305 errorCode
== TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND
||
306 errorCode
== TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND
)
311 // error in opening file
312 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE
||
313 // error in opening file
314 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_WRITE
||
315 // error in opening file
316 errorCode
== TASKHANDLING_OPEN_FOR_STREAM
||
317 // error in opening file
318 errorCode
== TASKHANDLING_OPEN_FOR_INPUTSTREAM
||
319 // error in opening file
320 errorCode
== TASKHANDLING_OPEN_FILE_FOR_PAGING
)
324 case FileBase::E_NAMETOOLONG
:
325 // pathname was too long
326 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
328 case FileBase::E_NXIO
:
329 // No such device or address
330 case FileBase::E_NODEV
:
332 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
334 case FileBase::E_NOENT
:
335 // No such file or directory
336 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
338 case FileBase::E_ROFS
:
339 // #i4735# handle ROFS transparently as ACCESS_DENIED
340 case FileBase::E_ACCES
:
341 // permission denied<P>
342 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
344 case FileBase::E_ISDIR
:
346 ioErrorCode
= IOErrorCode_NO_FILE
;
348 case FileBase::E_NOTREADY
:
349 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
351 case FileBase::E_MFILE
:
352 // too many open files used by the process
353 case FileBase::E_NFILE
:
354 // too many open files in the system
355 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
357 case FileBase::E_INVAL
:
358 // the format of the parameters was not valid
359 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
361 case FileBase::E_NOMEM
:
362 // not enough memory for allocating structures
363 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
365 case FileBase::E_BUSY
:
367 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
369 case FileBase::E_AGAIN
:
370 // Operation would block
371 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
373 case FileBase::E_NOLCK
: // No record locks available
374 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
377 case FileBase::E_FAULT
: // Bad address
378 case FileBase::E_LOOP
: // Too many symbolic links encountered
379 case FileBase::E_NOSPC
: // No space left on device
380 case FileBase::E_INTR
: // function call was interrupted
381 case FileBase::E_IO
: // I/O error
382 case FileBase::E_MULTIHOP
: // Multihop attempted
383 case FileBase::E_NOLINK
: // Link has been severed
385 ioErrorCode
= IOErrorCode_GENERAL
;
389 cancelCommandExecution(
391 generateErrorArguments(aUncPath
),
394 RTL_CONSTASCII_USTRINGPARAM(
395 "an error occured during file opening")),
398 else if( errorCode
== TASKHANDLING_OPEN_FOR_DIRECTORYLISTING
||
399 errorCode
== TASKHANDLING_OPENDIRECTORY_FOR_REMOVE
)
403 case FileBase::E_INVAL
:
404 // the format of the parameters was not valid
405 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
407 case FileBase::E_NOENT
:
408 // the specified path doesn't exist
409 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
411 case FileBase::E_NOTDIR
:
412 // the specified path is not an directory
413 ioErrorCode
= IOErrorCode_NO_DIRECTORY
;
415 case FileBase::E_NOMEM
:
416 // not enough memory for allocating structures
417 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
419 case FileBase::E_ROFS
:
420 // #i4735# handle ROFS transparently as ACCESS_DENIED
421 case FileBase::E_ACCES
: // permission denied
422 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
424 case FileBase::E_NOTREADY
:
425 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
427 case FileBase::E_MFILE
:
428 // too many open files used by the process
429 case FileBase::E_NFILE
:
430 // too many open files in the system
431 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
433 case FileBase::E_NAMETOOLONG
:
434 // File name too long
435 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
437 case FileBase::E_LOOP
:
438 // Too many symbolic links encountered<p>
440 ioErrorCode
= IOErrorCode_GENERAL
;
444 cancelCommandExecution(
446 generateErrorArguments(aUncPath
),
449 RTL_CONSTASCII_USTRINGPARAM(
450 "an error occured during opening a directory")),
453 else if( errorCode
== TASKHANDLING_NOTCONNECTED_FOR_WRITE
||
454 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE
||
455 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_WRITE
||
456 errorCode
== TASKHANDLING_NOTCONNECTED_FOR_PAGING
||
457 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING
||
458 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_PAGING
)
460 ioErrorCode
= IOErrorCode_UNKNOWN
;
461 cancelCommandExecution(
463 generateErrorArguments(aUncPath
),
466 RTL_CONSTASCII_USTRINGPARAM(
467 "an error occured writing or reading from a file")),
470 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_NO_SPACE
)
472 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
473 cancelCommandExecution(
475 generateErrorArguments(aUncPath
),
478 RTL_CONSTASCII_USTRINGPARAM(
482 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_WRITE
||
483 errorCode
== TASKHANDLING_READING_FILE_FOR_PAGING
)
487 case FileBase::E_INVAL
:
488 // the format of the parameters was not valid
489 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
491 case FileBase::E_FBIG
:
493 ioErrorCode
= IOErrorCode_CANT_WRITE
;
495 case FileBase::E_NOSPC
:
496 // No space left on device
497 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
499 case FileBase::E_NXIO
:
500 // No such device or address
501 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
503 case FileBase::E_NOLINK
:
504 // Link has been severed
505 case FileBase::E_ISDIR
:
507 ioErrorCode
= IOErrorCode_NO_FILE
;
509 case FileBase::E_AGAIN
:
510 // Operation would block
511 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
513 case FileBase::E_TIMEDOUT
:
514 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
516 case FileBase::E_NOLCK
: // No record locks available
517 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
519 case FileBase::E_IO
: // I/O error
520 case FileBase::E_BADF
: // Bad file
521 case FileBase::E_FAULT
: // Bad address
522 case FileBase::E_INTR
: // function call was interrupted
524 ioErrorCode
= IOErrorCode_GENERAL
;
527 cancelCommandExecution(
529 generateErrorArguments(aUncPath
),
532 RTL_CONSTASCII_USTRINGPARAM(
533 "an error occured during opening a file")),
536 else if( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
||
537 errorCode
== TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND
)
539 Sequence
< ::rtl::OUString
> aSeq( 1 );
541 ( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
) ?
542 rtl::OUString::createFromAscii( "Title" ) :
543 rtl::OUString::createFromAscii( "ContentType" );
545 aAny
<<= MissingPropertiesException(
547 RTL_CONSTASCII_USTRINGPARAM(
548 "a property is missing necessary"
549 "to create a content")),
552 cancelCommandExecution(aAny
,xEnv
);
554 else if( errorCode
== TASKHANDLING_FILESIZE_FOR_WRITE
)
558 case FileBase::E_INVAL
:
559 // the format of the parameters was not valid
560 case FileBase::E_OVERFLOW
:
561 // The resulting file offset would be a value which cannot
562 // be represented correctly for regular files
563 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
566 ioErrorCode
= IOErrorCode_GENERAL
;
569 cancelCommandExecution(
571 generateErrorArguments(aUncPath
),
574 RTL_CONSTASCII_USTRINGPARAM(
575 "there were problems with the filesize")),
578 else if(errorCode
== TASKHANDLING_INPUTSTREAM_FOR_WRITE
)
580 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
582 MissingInputStreamException(
584 RTL_CONSTASCII_USTRINGPARAM(
585 "the inputstream is missing necessary"
586 "to create a content")),
588 cancelCommandExecution(aAny
,xEnv
);
590 else if( errorCode
== TASKHANDLING_NOREPLACE_FOR_WRITE
)
591 // Overwrite = false and file exists
593 NameClashException excep
;
594 excep
.Name
= getTitle(aUncPath
);
595 excep
.Classification
= InteractionClassification_ERROR
;
596 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
597 excep
.Context
= xContext
;
598 excep
.Message
= rtl::OUString(
599 RTL_CONSTASCII_USTRINGPARAM(
600 "file exists and overwrite forbidden"));
602 cancelCommandExecution( aAny
,xEnv
);
604 else if( errorCode
== TASKHANDLING_INVALID_NAME_MKDIR
)
606 InteractiveAugmentedIOException excep
;
607 excep
.Code
= IOErrorCode_INVALID_CHARACTER
;
609 prop
.Name
= rtl::OUString::createFromAscii("ResourceName");
611 rtl::OUString
m_aClashingName(
614 rtl_UriDecodeWithCharset
,
615 RTL_TEXTENCODING_UTF8
));
616 prop
.Value
<<= m_aClashingName
;
617 Sequence
<Any
> seq(1);
619 excep
.Arguments
= seq
;
620 excep
.Classification
= InteractionClassification_ERROR
;
621 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
622 excep
.Context
= xContext
;
623 excep
.Message
= rtl::OUString(
624 RTL_CONSTASCII_USTRINGPARAM(
625 "the name contained invalid characters"));
630 cancelCommandExecution( aAny
,xEnv
);
632 // ioErrorCode = IOErrorCode_INVALID_CHARACTER;
633 // cancelCommandExecution(
635 // generateErrorArguments(aUncPath),
638 // RTL_CONSTASCII_USTRINGPARAM(
639 // "the name contained invalid characters")),
642 else if( errorCode
== TASKHANDLING_FOLDER_EXISTS_MKDIR
)
644 NameClashException excep
;
645 excep
.Name
= getTitle(aUncPath
);
646 excep
.Classification
= InteractionClassification_ERROR
;
647 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
648 excep
.Context
= xContext
;
649 excep
.Message
= rtl::OUString(
650 RTL_CONSTASCII_USTRINGPARAM(
651 "folder exists and overwrite forbidden"));
656 cancelCommandExecution( aAny
,xEnv
);
658 // ioErrorCode = IOErrorCode_ALREADY_EXISTING;
659 // cancelCommandExecution(
661 // generateErrorArguments(aUncPath),
664 // RTL_CONSTASCII_USTRINGPARAM(
665 // "the folder exists")),
668 else if( errorCode
== TASKHANDLING_ENSUREDIR_FOR_WRITE
||
669 errorCode
== TASKHANDLING_CREATEDIRECTORY_MKDIR
)
673 case FileBase::E_ACCES
:
674 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
676 case FileBase::E_ROFS
:
677 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
679 case FileBase::E_NAMETOOLONG
:
680 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
683 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
686 cancelCommandExecution(
688 generateErrorArguments(getParentName(aUncPath
)),
689 //TODO! ok to supply physical URL to getParentName()?
692 RTL_CONSTASCII_USTRINGPARAM(
693 "a folder could not be created")),
696 else if( errorCode
== TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE
||
697 errorCode
== TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE
||
698 errorCode
== TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE
)
702 case FileBase::E_INVAL
: // the format of the parameters was not valid
703 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
705 case FileBase::E_NOMEM
: // not enough memory for allocating structures
706 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
708 case FileBase::E_ROFS
: // #i4735# handle ROFS transparently as ACCESS_DENIED
709 case FileBase::E_ACCES
: // permission denied
710 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
712 case FileBase::E_MFILE
: // too many open files used by the process
713 case FileBase::E_NFILE
: // too many open files in the system
714 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
716 case FileBase::E_NOLINK
: // Link has been severed
717 case FileBase::E_NOENT
: // No such file or directory
718 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
720 case FileBase::E_NAMETOOLONG
: // File name too long
721 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
723 case FileBase::E_NOTDIR
: // A component of the path prefix of path is not a directory
724 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
726 case FileBase::E_LOOP
: // Too many symbolic links encountered
727 case FileBase::E_IO
: // I/O error
728 case FileBase::E_MULTIHOP
: // Multihop attempted
729 case FileBase::E_FAULT
: // Bad address
730 case FileBase::E_INTR
: // function call was interrupted
731 case FileBase::E_NOSYS
: // Function not implemented
732 case FileBase::E_NOSPC
: // No space left on device
733 case FileBase::E_NXIO
: // No such device or address
734 case FileBase::E_OVERFLOW
: // Value too large for defined data type
735 case FileBase::E_BADF
: // Invalid oslDirectoryItem parameter
737 ioErrorCode
= IOErrorCode_GENERAL
;
740 cancelCommandExecution(
742 generateErrorArguments(aUncPath
),
745 RTL_CONSTASCII_USTRINGPARAM(
746 "a file status object could not be filled")),
749 else if( errorCode
== TASKHANDLING_DELETEFILE_FOR_REMOVE
||
750 errorCode
== TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE
)
754 case FileBase::E_INVAL
: // the format of the parameters was not valid
755 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
757 case FileBase::E_NOMEM
: // not enough memory for allocating structures
758 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
760 case FileBase::E_ACCES
: // Permission denied
761 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
763 case FileBase::E_PERM
: // Operation not permitted
764 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
766 case FileBase::E_NAMETOOLONG
: // File name too long
767 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
769 case FileBase::E_NOLINK
: // Link has been severed
770 case FileBase::E_NOENT
: // No such file or directory
771 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
773 case FileBase::E_ISDIR
: // Is a directory
774 case FileBase::E_ROFS
: // Read-only file system
775 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
777 case FileBase::E_BUSY
: // Device or resource busy
778 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
780 case FileBase::E_FAULT
: // Bad address
781 case FileBase::E_LOOP
: // Too many symbolic links encountered
782 case FileBase::E_IO
: // I/O error
783 case FileBase::E_INTR
: // function call was interrupted
784 case FileBase::E_MULTIHOP
: // Multihop attempted
786 ioErrorCode
= IOErrorCode_GENERAL
;
789 cancelCommandExecution(
791 generateErrorArguments(aUncPath
),
794 RTL_CONSTASCII_USTRINGPARAM(
795 "a file or directory could not be deleted")),
798 else if( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
799 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
800 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
801 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
||
802 errorCode
== TASKHANDLING_TRANSFER_DESTFILETYPE
||
803 errorCode
== TASKHANDLING_FILETYPE_FOR_REMOVE
||
804 errorCode
== TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE
||
805 errorCode
== TASKHANDLING_TRANSFER_INVALIDURL
)
810 case FileBase::E_NOENT
: // No such file or directory
811 if ( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
812 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
813 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
814 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
)
816 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
817 aMsg
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
818 "source file/folder does not exist"));
823 ioErrorCode
= IOErrorCode_GENERAL
;
824 aMsg
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
825 "a general error during transfer command"));
829 ioErrorCode
= IOErrorCode_GENERAL
;
830 aMsg
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
831 "a general error during transfer command"));
834 cancelCommandExecution(
836 generateErrorArguments(aUncPath
),
841 else if( errorCode
== TASKHANDLING_TRANSFER_ACCESSINGROOT
)
843 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
844 cancelCommandExecution(
846 generateErrorArguments(aUncPath
),
849 RTL_CONSTASCII_USTRINGPARAM(
850 "accessing the root during transfer")),
853 else if( errorCode
== TASKHANDLING_TRANSFER_INVALIDSCHEME
)
855 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
858 InteractiveBadTransferURLException(
860 RTL_CONSTASCII_USTRINGPARAM(
863 cancelCommandExecution( aAny
,xEnv
);
865 else if( errorCode
== TASKHANDLING_OVERWRITE_FOR_MOVE
||
866 errorCode
== TASKHANDLING_OVERWRITE_FOR_COPY
||
867 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_MOVE
||
868 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_COPY
||
869 errorCode
== TASKHANDLING_KEEPERROR_FOR_MOVE
||
870 errorCode
== TASKHANDLING_KEEPERROR_FOR_COPY
||
871 errorCode
== TASKHANDLING_RENAME_FOR_MOVE
||
872 errorCode
== TASKHANDLING_RENAME_FOR_COPY
||
873 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_MOVE
||
874 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_COPY
)
876 rtl::OUString
aMsg(RTL_CONSTASCII_USTRINGPARAM(
877 "general error during transfer"));
881 case FileBase::E_EXIST
:
882 ioErrorCode
= IOErrorCode_ALREADY_EXISTING
;
884 case FileBase::E_INVAL
: // the format of the parameters was not valid
885 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
887 case FileBase::E_NOMEM
: // not enough memory for allocating structures
888 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
890 case FileBase::E_ACCES
: // Permission denied
891 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
893 case FileBase::E_PERM
: // Operation not permitted
894 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
896 case FileBase::E_NAMETOOLONG
: // File name too long
897 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
899 case FileBase::E_NOENT
: // No such file or directory
900 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
901 aMsg
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
902 "file/folder does not exist"));
904 case FileBase::E_ROFS
: // Read-only file system<p>
905 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
908 ioErrorCode
= IOErrorCode_GENERAL
;
911 cancelCommandExecution(
913 generateErrorArguments(aUncPath
),
918 else if( errorCode
== TASKHANDLING_NAMECLASH_FOR_COPY
||
919 errorCode
== TASKHANDLING_NAMECLASH_FOR_MOVE
)
921 NameClashException excep
;
922 excep
.Name
= getTitle(aUncPath
);
923 excep
.Classification
= InteractionClassification_ERROR
;
924 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
925 excep
.Context
= xContext
;
926 excep
.Message
= rtl::OUString(
927 RTL_CONSTASCII_USTRINGPARAM(
928 "name clash during copy or move"));
931 cancelCommandExecution(aAny
,xEnv
);
933 else if( errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE
||
934 errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY
)
936 Reference
<XInterface
> xContext(
938 UnsupportedNameClashException excep
;
939 excep
.NameClash
= minorCode
;
940 excep
.Context
= xContext
;
941 excep
.Message
= rtl::OUString(
942 RTL_CONSTASCII_USTRINGPARAM(
943 "name clash value not supported during copy or move"));
946 cancelCommandExecution(aAny
,xEnv
);
950 // case TASKHANDLER_NO_ERROR:
956 } // end namespace fileaccess