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
;
366 case FileBase::E_BUSY
: // Text file busy
367 case FileBase::E_AGAIN
: // Operation would block
368 case FileBase::E_NOLCK
: // No record locks available
369 case FileBase::E_TXTBSY
:// Text file busy
370 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
373 case FileBase::E_FAULT
: // Bad address
374 case FileBase::E_LOOP
: // Too many symbolic links encountered
375 case FileBase::E_NOSPC
: // No space left on device
376 case FileBase::E_INTR
: // function call was interrupted
377 case FileBase::E_IO
: // I/O error
378 case FileBase::E_MULTIHOP
: // Multihop attempted
379 case FileBase::E_NOLINK
: // Link has been severed
381 ioErrorCode
= IOErrorCode_GENERAL
;
385 cancelCommandExecution(
387 generateErrorArguments(aUncPath
),
390 RTL_CONSTASCII_USTRINGPARAM(
391 "an error occured during file opening")),
394 else if( errorCode
== TASKHANDLING_OPEN_FOR_DIRECTORYLISTING
||
395 errorCode
== TASKHANDLING_OPENDIRECTORY_FOR_REMOVE
)
399 case FileBase::E_INVAL
:
400 // the format of the parameters was not valid
401 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
403 case FileBase::E_NOENT
:
404 // the specified path doesn't exist
405 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
407 case FileBase::E_NOTDIR
:
408 // the specified path is not an directory
409 ioErrorCode
= IOErrorCode_NO_DIRECTORY
;
411 case FileBase::E_NOMEM
:
412 // not enough memory for allocating structures
413 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
415 case FileBase::E_ROFS
:
416 // #i4735# handle ROFS transparently as ACCESS_DENIED
417 case FileBase::E_ACCES
: // permission denied
418 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
420 case FileBase::E_NOTREADY
:
421 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
423 case FileBase::E_MFILE
:
424 // too many open files used by the process
425 case FileBase::E_NFILE
:
426 // too many open files in the system
427 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
429 case FileBase::E_NAMETOOLONG
:
430 // File name too long
431 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
433 case FileBase::E_LOOP
:
434 // Too many symbolic links encountered<p>
436 ioErrorCode
= IOErrorCode_GENERAL
;
440 cancelCommandExecution(
442 generateErrorArguments(aUncPath
),
445 RTL_CONSTASCII_USTRINGPARAM(
446 "an error occured during opening a directory")),
449 else if( errorCode
== TASKHANDLING_NOTCONNECTED_FOR_WRITE
||
450 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE
||
451 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_WRITE
||
452 errorCode
== TASKHANDLING_NOTCONNECTED_FOR_PAGING
||
453 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING
||
454 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_PAGING
)
456 ioErrorCode
= IOErrorCode_UNKNOWN
;
457 cancelCommandExecution(
459 generateErrorArguments(aUncPath
),
462 RTL_CONSTASCII_USTRINGPARAM(
463 "an error occured writing or reading from a file")),
466 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_NO_SPACE
)
468 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
469 cancelCommandExecution(
471 generateErrorArguments(aUncPath
),
474 RTL_CONSTASCII_USTRINGPARAM(
478 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_WRITE
||
479 errorCode
== TASKHANDLING_READING_FILE_FOR_PAGING
)
483 case FileBase::E_INVAL
:
484 // the format of the parameters was not valid
485 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
487 case FileBase::E_FBIG
:
489 ioErrorCode
= IOErrorCode_CANT_WRITE
;
491 case FileBase::E_NOSPC
:
492 // No space left on device
493 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
495 case FileBase::E_NXIO
:
496 // No such device or address
497 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
499 case FileBase::E_NOLINK
:
500 // Link has been severed
501 case FileBase::E_ISDIR
:
503 ioErrorCode
= IOErrorCode_NO_FILE
;
505 case FileBase::E_AGAIN
:
506 // Operation would block
507 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
509 case FileBase::E_TIMEDOUT
:
510 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
512 case FileBase::E_NOLCK
: // No record locks available
513 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
515 case FileBase::E_IO
: // I/O error
516 case FileBase::E_BADF
: // Bad file
517 case FileBase::E_FAULT
: // Bad address
518 case FileBase::E_INTR
: // function call was interrupted
520 ioErrorCode
= IOErrorCode_GENERAL
;
523 cancelCommandExecution(
525 generateErrorArguments(aUncPath
),
528 RTL_CONSTASCII_USTRINGPARAM(
529 "an error occured during opening a file")),
532 else if( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
||
533 errorCode
== TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND
)
535 Sequence
< ::rtl::OUString
> aSeq( 1 );
537 ( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
) ?
538 rtl::OUString::createFromAscii( "Title" ) :
539 rtl::OUString::createFromAscii( "ContentType" );
541 aAny
<<= MissingPropertiesException(
543 RTL_CONSTASCII_USTRINGPARAM(
544 "a property is missing necessary"
545 "to create a content")),
548 cancelCommandExecution(aAny
,xEnv
);
550 else if( errorCode
== TASKHANDLING_FILESIZE_FOR_WRITE
)
554 case FileBase::E_INVAL
:
555 // the format of the parameters was not valid
556 case FileBase::E_OVERFLOW
:
557 // The resulting file offset would be a value which cannot
558 // be represented correctly for regular files
559 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
562 ioErrorCode
= IOErrorCode_GENERAL
;
565 cancelCommandExecution(
567 generateErrorArguments(aUncPath
),
570 RTL_CONSTASCII_USTRINGPARAM(
571 "there were problems with the filesize")),
574 else if(errorCode
== TASKHANDLING_INPUTSTREAM_FOR_WRITE
)
576 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
578 MissingInputStreamException(
580 RTL_CONSTASCII_USTRINGPARAM(
581 "the inputstream is missing necessary"
582 "to create a content")),
584 cancelCommandExecution(aAny
,xEnv
);
586 else if( errorCode
== TASKHANDLING_NOREPLACE_FOR_WRITE
)
587 // Overwrite = false and file exists
589 NameClashException excep
;
590 excep
.Name
= getTitle(aUncPath
);
591 excep
.Classification
= InteractionClassification_ERROR
;
592 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
593 excep
.Context
= xContext
;
594 excep
.Message
= rtl::OUString(
595 RTL_CONSTASCII_USTRINGPARAM(
596 "file exists and overwrite forbidden"));
598 cancelCommandExecution( aAny
,xEnv
);
600 else if( errorCode
== TASKHANDLING_INVALID_NAME_MKDIR
)
602 InteractiveAugmentedIOException excep
;
603 excep
.Code
= IOErrorCode_INVALID_CHARACTER
;
605 prop
.Name
= rtl::OUString::createFromAscii("ResourceName");
607 rtl::OUString
m_aClashingName(
610 rtl_UriDecodeWithCharset
,
611 RTL_TEXTENCODING_UTF8
));
612 prop
.Value
<<= m_aClashingName
;
613 Sequence
<Any
> seq(1);
615 excep
.Arguments
= seq
;
616 excep
.Classification
= InteractionClassification_ERROR
;
617 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
618 excep
.Context
= xContext
;
619 excep
.Message
= rtl::OUString(
620 RTL_CONSTASCII_USTRINGPARAM(
621 "the name contained invalid characters"));
626 cancelCommandExecution( aAny
,xEnv
);
628 // ioErrorCode = IOErrorCode_INVALID_CHARACTER;
629 // cancelCommandExecution(
631 // generateErrorArguments(aUncPath),
634 // RTL_CONSTASCII_USTRINGPARAM(
635 // "the name contained invalid characters")),
638 else if( errorCode
== TASKHANDLING_FOLDER_EXISTS_MKDIR
)
640 NameClashException excep
;
641 excep
.Name
= getTitle(aUncPath
);
642 excep
.Classification
= InteractionClassification_ERROR
;
643 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
644 excep
.Context
= xContext
;
645 excep
.Message
= rtl::OUString(
646 RTL_CONSTASCII_USTRINGPARAM(
647 "folder exists and overwrite forbidden"));
652 cancelCommandExecution( aAny
,xEnv
);
654 // ioErrorCode = IOErrorCode_ALREADY_EXISTING;
655 // cancelCommandExecution(
657 // generateErrorArguments(aUncPath),
660 // RTL_CONSTASCII_USTRINGPARAM(
661 // "the folder exists")),
664 else if( errorCode
== TASKHANDLING_ENSUREDIR_FOR_WRITE
||
665 errorCode
== TASKHANDLING_CREATEDIRECTORY_MKDIR
)
669 case FileBase::E_ACCES
:
670 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
672 case FileBase::E_ROFS
:
673 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
675 case FileBase::E_NAMETOOLONG
:
676 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
679 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
682 cancelCommandExecution(
684 generateErrorArguments(getParentName(aUncPath
)),
685 //TODO! ok to supply physical URL to getParentName()?
688 RTL_CONSTASCII_USTRINGPARAM(
689 "a folder could not be created")),
692 else if( errorCode
== TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE
||
693 errorCode
== TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE
||
694 errorCode
== TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE
)
698 case FileBase::E_INVAL
: // the format of the parameters was not valid
699 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
701 case FileBase::E_NOMEM
: // not enough memory for allocating structures
702 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
704 case FileBase::E_ROFS
: // #i4735# handle ROFS transparently as ACCESS_DENIED
705 case FileBase::E_ACCES
: // permission denied
706 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
708 case FileBase::E_MFILE
: // too many open files used by the process
709 case FileBase::E_NFILE
: // too many open files in the system
710 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
712 case FileBase::E_NOLINK
: // Link has been severed
713 case FileBase::E_NOENT
: // No such file or directory
714 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
716 case FileBase::E_NAMETOOLONG
: // File name too long
717 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
719 case FileBase::E_NOTDIR
: // A component of the path prefix of path is not a directory
720 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
722 case FileBase::E_LOOP
: // Too many symbolic links encountered
723 case FileBase::E_IO
: // I/O error
724 case FileBase::E_MULTIHOP
: // Multihop attempted
725 case FileBase::E_FAULT
: // Bad address
726 case FileBase::E_INTR
: // function call was interrupted
727 case FileBase::E_NOSYS
: // Function not implemented
728 case FileBase::E_NOSPC
: // No space left on device
729 case FileBase::E_NXIO
: // No such device or address
730 case FileBase::E_OVERFLOW
: // Value too large for defined data type
731 case FileBase::E_BADF
: // Invalid oslDirectoryItem parameter
733 ioErrorCode
= IOErrorCode_GENERAL
;
736 cancelCommandExecution(
738 generateErrorArguments(aUncPath
),
741 RTL_CONSTASCII_USTRINGPARAM(
742 "a file status object could not be filled")),
745 else if( errorCode
== TASKHANDLING_DELETEFILE_FOR_REMOVE
||
746 errorCode
== TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE
)
750 case FileBase::E_INVAL
: // the format of the parameters was not valid
751 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
753 case FileBase::E_NOMEM
: // not enough memory for allocating structures
754 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
756 case FileBase::E_ACCES
: // Permission denied
757 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
759 case FileBase::E_PERM
: // Operation not permitted
760 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
762 case FileBase::E_NAMETOOLONG
: // File name too long
763 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
765 case FileBase::E_NOLINK
: // Link has been severed
766 case FileBase::E_NOENT
: // No such file or directory
767 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
769 case FileBase::E_ISDIR
: // Is a directory
770 case FileBase::E_ROFS
: // Read-only file system
771 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
773 case FileBase::E_BUSY
: // Device or resource busy
774 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
776 case FileBase::E_FAULT
: // Bad address
777 case FileBase::E_LOOP
: // Too many symbolic links encountered
778 case FileBase::E_IO
: // I/O error
779 case FileBase::E_INTR
: // function call was interrupted
780 case FileBase::E_MULTIHOP
: // Multihop attempted
782 ioErrorCode
= IOErrorCode_GENERAL
;
785 cancelCommandExecution(
787 generateErrorArguments(aUncPath
),
790 RTL_CONSTASCII_USTRINGPARAM(
791 "a file or directory could not be deleted")),
794 else if( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
795 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
796 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
797 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
||
798 errorCode
== TASKHANDLING_TRANSFER_DESTFILETYPE
||
799 errorCode
== TASKHANDLING_FILETYPE_FOR_REMOVE
||
800 errorCode
== TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE
||
801 errorCode
== TASKHANDLING_TRANSFER_INVALIDURL
)
806 case FileBase::E_NOENT
: // No such file or directory
807 if ( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
808 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
809 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
810 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
)
812 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
813 aMsg
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
814 "source file/folder does not exist"));
819 ioErrorCode
= IOErrorCode_GENERAL
;
820 aMsg
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
821 "a general error during transfer command"));
825 ioErrorCode
= IOErrorCode_GENERAL
;
826 aMsg
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
827 "a general error during transfer command"));
830 cancelCommandExecution(
832 generateErrorArguments(aUncPath
),
837 else if( errorCode
== TASKHANDLING_TRANSFER_ACCESSINGROOT
)
839 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
840 cancelCommandExecution(
842 generateErrorArguments(aUncPath
),
845 RTL_CONSTASCII_USTRINGPARAM(
846 "accessing the root during transfer")),
849 else if( errorCode
== TASKHANDLING_TRANSFER_INVALIDSCHEME
)
851 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
854 InteractiveBadTransferURLException(
856 RTL_CONSTASCII_USTRINGPARAM(
859 cancelCommandExecution( aAny
,xEnv
);
861 else if( errorCode
== TASKHANDLING_OVERWRITE_FOR_MOVE
||
862 errorCode
== TASKHANDLING_OVERWRITE_FOR_COPY
||
863 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_MOVE
||
864 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_COPY
||
865 errorCode
== TASKHANDLING_KEEPERROR_FOR_MOVE
||
866 errorCode
== TASKHANDLING_KEEPERROR_FOR_COPY
||
867 errorCode
== TASKHANDLING_RENAME_FOR_MOVE
||
868 errorCode
== TASKHANDLING_RENAME_FOR_COPY
||
869 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_MOVE
||
870 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_COPY
)
872 rtl::OUString
aMsg(RTL_CONSTASCII_USTRINGPARAM(
873 "general error during transfer"));
877 case FileBase::E_EXIST
:
878 ioErrorCode
= IOErrorCode_ALREADY_EXISTING
;
880 case FileBase::E_INVAL
: // the format of the parameters was not valid
881 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
883 case FileBase::E_NOMEM
: // not enough memory for allocating structures
884 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
886 case FileBase::E_ACCES
: // Permission denied
887 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
889 case FileBase::E_PERM
: // Operation not permitted
890 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
892 case FileBase::E_NAMETOOLONG
: // File name too long
893 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
895 case FileBase::E_NOENT
: // No such file or directory
896 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
897 aMsg
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
898 "file/folder does not exist"));
900 case FileBase::E_ROFS
: // Read-only file system<p>
901 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
904 ioErrorCode
= IOErrorCode_GENERAL
;
907 cancelCommandExecution(
909 generateErrorArguments(aUncPath
),
914 else if( errorCode
== TASKHANDLING_NAMECLASH_FOR_COPY
||
915 errorCode
== TASKHANDLING_NAMECLASH_FOR_MOVE
)
917 NameClashException excep
;
918 excep
.Name
= getTitle(aUncPath
);
919 excep
.Classification
= InteractionClassification_ERROR
;
920 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
921 excep
.Context
= xContext
;
922 excep
.Message
= rtl::OUString(
923 RTL_CONSTASCII_USTRINGPARAM(
924 "name clash during copy or move"));
927 cancelCommandExecution(aAny
,xEnv
);
929 else if( errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE
||
930 errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY
)
932 Reference
<XInterface
> xContext(
934 UnsupportedNameClashException excep
;
935 excep
.NameClash
= minorCode
;
936 excep
.Context
= xContext
;
937 excep
.Message
= rtl::OUString(
938 RTL_CONSTASCII_USTRINGPARAM(
939 "name clash value not supported during copy or move"));
942 cancelCommandExecution(aAny
,xEnv
);
946 // case TASKHANDLER_NO_ERROR:
952 } // end namespace fileaccess