1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "filglob.hxx"
31 #include "filerror.hxx"
34 #include <osl/file.hxx>
36 #include <ucbhelper/cancelcommandexecution.hxx>
37 #include <com/sun/star/ucb/CommandAbortedException.hpp>
38 #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
39 #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
40 #include <com/sun/star/lang/IllegalArgumentException.hpp>
41 #include <com/sun/star/ucb/IOErrorCode.hpp>
42 #include <com/sun/star/ucb/MissingPropertiesException.hpp>
43 #include <com/sun/star/ucb/MissingInputStreamException.hpp>
44 #include <com/sun/star/ucb/NameClashException.hpp>
45 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
46 #include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
47 #include "com/sun/star/beans/PropertyState.hpp"
48 #include "com/sun/star/beans/PropertyValue.hpp"
49 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
50 #include "com/sun/star/uno/Any.hxx"
51 #include "com/sun/star/uno/Sequence.hxx"
52 #include "osl/diagnose.h"
53 #include "rtl/ustrbuf.hxx"
54 #include <rtl/uri.hxx>
55 #include <rtl/ustring.hxx>
56 #include "sal/types.h"
58 using namespace ucbhelper
;
60 using namespace ::com::sun::star
;
61 using namespace com::sun::star::task
;
62 using namespace com::sun::star::beans
;
63 using namespace com::sun::star::lang
;
64 using namespace com::sun::star::uno
;
65 using namespace com::sun::star::ucb
;
69 Sequence
< Any
> generateErrorArguments(
70 rtl::OUString
const & rPhysicalUrl
)
72 rtl::OUString aResourceName
;
73 rtl::OUString aResourceType
;
75 bool bResourceName
= false;
76 bool bResourceType
= false;
77 bool bRemoveProperty
= false;
79 if (osl::FileBase::getSystemPathFromFileURL(
82 == osl::FileBase::E_None
)
85 // The resource types "folder" (i.e., directory) and
86 // "volume" seem to be
87 // the most interesting when producing meaningful error messages:
88 osl::DirectoryItem aItem
;
89 if (osl::DirectoryItem::get(rPhysicalUrl
, aItem
) ==
90 osl::FileBase::E_None
)
92 osl::FileStatus
aStatus( osl_FileStatus_Mask_Type
);
93 if (aItem
.getFileStatus(aStatus
) == osl::FileBase::E_None
)
94 switch (aStatus
.getFileType())
96 case osl::FileStatus::Directory
:
97 aResourceType
= rtl::OUString( "folder");
101 case osl::FileStatus::Volume
:
103 aResourceType
= rtl::OUString( "volume");
104 bResourceType
= true;
105 osl::VolumeInfo
aVolumeInfo(
106 osl_VolumeInfo_Mask_Attributes
);
107 if( osl::Directory::getVolumeInfo(
108 rPhysicalUrl
,aVolumeInfo
) ==
109 osl::FileBase::E_None
)
111 bRemovable
= aVolumeInfo
.getRemoveableFlag();
112 bRemoveProperty
= true;
116 case osl::FileStatus::Regular
:
117 case osl::FileStatus::Fifo
:
118 case osl::FileStatus::Socket
:
119 case osl::FileStatus::Link
:
120 case osl::FileStatus::Special
:
121 case osl::FileStatus::Unknown
:
122 // do nothing for now
127 Sequence
< Any
> aArguments( 1 +
128 (bResourceName
? 1 : 0) +
129 (bResourceType
? 1 : 0) +
130 (bRemoveProperty
? 1 : 0) );
133 <<= PropertyValue(rtl::OUString( "Uri"),
135 makeAny(rPhysicalUrl
),
136 PropertyState_DIRECT_VALUE
);
139 <<= PropertyValue(rtl::OUString( "ResourceName"),
141 makeAny(aResourceName
),
142 PropertyState_DIRECT_VALUE
);
145 <<= PropertyValue(rtl::OUString( "ResourceType"),
147 makeAny(aResourceType
),
148 PropertyState_DIRECT_VALUE
);
151 <<= PropertyValue(rtl::OUString( "Removable"),
154 PropertyState_DIRECT_VALUE
);
162 namespace fileaccess
{
165 sal_Bool
isChild( const rtl::OUString
& srcUnqPath
,
166 const rtl::OUString
& dstUnqPath
)
168 static sal_Unicode slash
= '/';
169 // Simple lexical comparison
170 sal_Int32 srcL
= srcUnqPath
.getLength();
171 sal_Int32 dstL
= dstUnqPath
.getLength();
174 ( srcUnqPath
== dstUnqPath
)
178 ( srcUnqPath
.compareTo( dstUnqPath
, srcL
) == 0 )
180 ( dstUnqPath
[ srcL
] == slash
) )
185 rtl::OUString
newName(
186 const rtl::OUString
& aNewPrefix
,
187 const rtl::OUString
& aOldPrefix
,
188 const rtl::OUString
& old_Name
)
190 sal_Int32 srcL
= aOldPrefix
.getLength();
192 rtl::OUString new_Name
= old_Name
.copy( srcL
);
193 new_Name
= ( aNewPrefix
+ new_Name
);
198 rtl::OUString
getTitle( const rtl::OUString
& aPath
)
200 sal_Unicode slash
= '/';
201 sal_Int32 lastIndex
= aPath
.lastIndexOf( slash
);
202 return aPath
.copy( lastIndex
+ 1 );
206 rtl::OUString
getParentName( const rtl::OUString
& aFileName
)
208 sal_Int32 lastIndex
= aFileName
.lastIndexOf( sal_Unicode('/') );
209 rtl::OUString aParent
= aFileName
.copy( 0,lastIndex
);
211 if( aParent
[ aParent
.getLength()-1] == sal_Unicode(':') && aParent
.getLength() == 6 )
212 aParent
+= rtl::OUString("/");
214 if ( aParent
== "file://" )
215 aParent
= rtl::OUString("file:///");
221 osl::FileBase::RC
osl_File_copy( const rtl::OUString
& strPath
,
222 const rtl::OUString
& strDestPath
,
227 osl::DirectoryItem aItem
;
228 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
229 return osl::FileBase::E_EXIST
;
232 return osl::File::copy( strPath
,strDestPath
);
236 osl::FileBase::RC
osl_File_move( const rtl::OUString
& strPath
,
237 const rtl::OUString
& strDestPath
,
242 osl::DirectoryItem aItem
;
243 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
244 return osl::FileBase::E_EXIST
;
247 return osl::File::move( strPath
,strDestPath
);
253 const Reference
< XCommandEnvironment
>& xEnv
,
254 const rtl::OUString
& aUncPath
,
255 BaseContent
* pContent
,
258 Reference
<XCommandProcessor
> xComProc(pContent
);
260 IOErrorCode ioErrorCode
;
262 if( errorCode
== TASKHANDLER_UNSUPPORTED_COMMAND
)
264 aAny
<<= UnsupportedCommandException( ::rtl::OUString( OSL_LOG_PREFIX
), uno::Reference
< uno::XInterface
>() );
265 cancelCommandExecution( aAny
,xEnv
);
267 else if( errorCode
== TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT
||
268 errorCode
== TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT
||
269 errorCode
== TASKHANDLING_WRONG_OPEN_ARGUMENT
||
270 errorCode
== TASKHANDLING_WRONG_DELETE_ARGUMENT
||
271 errorCode
== TASKHANDLING_WRONG_TRANSFER_ARGUMENT
||
272 errorCode
== TASKHANDLING_WRONG_INSERT_ARGUMENT
||
273 errorCode
== TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT
)
275 IllegalArgumentException excep
;
276 excep
.ArgumentPosition
= 0;
278 cancelCommandExecution(
281 else if( errorCode
== TASKHANDLING_UNSUPPORTED_OPEN_MODE
)
283 UnsupportedOpenModeException excep
;
284 excep
.Mode
= sal::static_int_cast
< sal_Int16
>(minorCode
);
286 cancelCommandExecution( aAny
,xEnv
);
288 else if(errorCode
== TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND
||
289 errorCode
== TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND
||
290 errorCode
== TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND
)
295 // error in opening file
296 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE
||
297 // error in opening file
298 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_WRITE
||
299 // error in opening file
300 errorCode
== TASKHANDLING_OPEN_FOR_STREAM
||
301 // error in opening file
302 errorCode
== TASKHANDLING_OPEN_FOR_INPUTSTREAM
||
303 // error in opening file
304 errorCode
== TASKHANDLING_OPEN_FILE_FOR_PAGING
)
308 case FileBase::E_NAMETOOLONG
:
309 // pathname was too long
310 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
312 case FileBase::E_NXIO
:
313 // No such device or address
314 case FileBase::E_NODEV
:
316 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
318 case FileBase::E_NOTDIR
:
319 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
321 case FileBase::E_NOENT
:
322 // No such file or directory
323 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
325 case FileBase::E_ROFS
:
326 // #i4735# handle ROFS transparently as ACCESS_DENIED
327 case FileBase::E_ACCES
:
328 // permission denied<P>
329 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
331 case FileBase::E_ISDIR
:
333 ioErrorCode
= IOErrorCode_NO_FILE
;
335 case FileBase::E_NOTREADY
:
336 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
338 case FileBase::E_MFILE
:
339 // too many open files used by the process
340 case FileBase::E_NFILE
:
341 // too many open files in the system
342 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
344 case FileBase::E_INVAL
:
345 // the format of the parameters was not valid
346 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
348 case FileBase::E_NOMEM
:
349 // not enough memory for allocating structures
350 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
352 case FileBase::E_BUSY
:
354 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
356 case FileBase::E_AGAIN
:
357 // Operation would block
358 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
360 case FileBase::E_NOLCK
: // No record locks available
361 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
364 case FileBase::E_FAULT
: // Bad address
365 case FileBase::E_LOOP
: // Too many symbolic links encountered
366 case FileBase::E_NOSPC
: // No space left on device
367 case FileBase::E_INTR
: // function call was interrupted
368 case FileBase::E_IO
: // I/O error
369 case FileBase::E_MULTIHOP
: // Multihop attempted
370 case FileBase::E_NOLINK
: // Link has been severed
372 ioErrorCode
= IOErrorCode_GENERAL
;
376 cancelCommandExecution(
378 generateErrorArguments(aUncPath
),
380 rtl::OUString( "an error occurred during file opening"),
383 else if( errorCode
== TASKHANDLING_OPEN_FOR_DIRECTORYLISTING
||
384 errorCode
== TASKHANDLING_OPENDIRECTORY_FOR_REMOVE
)
388 case FileBase::E_INVAL
:
389 // the format of the parameters was not valid
390 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
392 case FileBase::E_NOENT
:
393 // the specified path doesn't exist
394 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
396 case FileBase::E_NOTDIR
:
397 // the specified path is not an directory
398 ioErrorCode
= IOErrorCode_NO_DIRECTORY
;
400 case FileBase::E_NOMEM
:
401 // not enough memory for allocating structures
402 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
404 case FileBase::E_ROFS
:
405 // #i4735# handle ROFS transparently as ACCESS_DENIED
406 case FileBase::E_ACCES
: // permission denied
407 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
409 case FileBase::E_NOTREADY
:
410 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
412 case FileBase::E_MFILE
:
413 // too many open files used by the process
414 case FileBase::E_NFILE
:
415 // too many open files in the system
416 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
418 case FileBase::E_NAMETOOLONG
:
419 // File name too long
420 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
422 case FileBase::E_LOOP
:
423 // Too many symbolic links encountered<p>
425 ioErrorCode
= IOErrorCode_GENERAL
;
429 cancelCommandExecution(
431 generateErrorArguments(aUncPath
),
433 rtl::OUString( "an error occurred during opening a directory"),
436 else if( errorCode
== TASKHANDLING_NOTCONNECTED_FOR_WRITE
||
437 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE
||
438 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_WRITE
||
439 errorCode
== TASKHANDLING_NOTCONNECTED_FOR_PAGING
||
440 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING
||
441 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_PAGING
)
443 ioErrorCode
= IOErrorCode_UNKNOWN
;
444 cancelCommandExecution(
446 generateErrorArguments(aUncPath
),
448 rtl::OUString( "an error occurred writing or reading from a file"),
451 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_NO_SPACE
)
453 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
454 cancelCommandExecution(
456 generateErrorArguments(aUncPath
),
458 rtl::OUString( "device full"),
461 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_WRITE
||
462 errorCode
== TASKHANDLING_READING_FILE_FOR_PAGING
)
466 case FileBase::E_INVAL
:
467 // the format of the parameters was not valid
468 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
470 case FileBase::E_FBIG
:
472 ioErrorCode
= IOErrorCode_CANT_WRITE
;
474 case FileBase::E_NOSPC
:
475 // No space left on device
476 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
478 case FileBase::E_NXIO
:
479 // No such device or address
480 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
482 case FileBase::E_NOLINK
:
483 // Link has been severed
484 case FileBase::E_ISDIR
:
486 ioErrorCode
= IOErrorCode_NO_FILE
;
488 case FileBase::E_AGAIN
:
489 // Operation would block
490 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
492 case FileBase::E_TIMEDOUT
:
493 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
495 case FileBase::E_NOLCK
: // No record locks available
496 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
498 case FileBase::E_IO
: // I/O error
499 case FileBase::E_BADF
: // Bad file
500 case FileBase::E_FAULT
: // Bad address
501 case FileBase::E_INTR
: // function call was interrupted
503 ioErrorCode
= IOErrorCode_GENERAL
;
506 cancelCommandExecution(
508 generateErrorArguments(aUncPath
),
510 rtl::OUString( "an error occurred during opening a file"),
513 else if( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
||
514 errorCode
== TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND
)
516 Sequence
< ::rtl::OUString
> aSeq( 1 );
518 ( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
) ?
519 rtl::OUString("Title") :
520 rtl::OUString("ContentType");
522 aAny
<<= MissingPropertiesException(
523 rtl::OUString( "a property is missing necessary"
524 "to create a content"),
527 cancelCommandExecution(aAny
,xEnv
);
529 else if( errorCode
== TASKHANDLING_FILESIZE_FOR_WRITE
)
533 case FileBase::E_INVAL
:
534 // the format of the parameters was not valid
535 case FileBase::E_OVERFLOW
:
536 // The resulting file offset would be a value which cannot
537 // be represented correctly for regular files
538 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
541 ioErrorCode
= IOErrorCode_GENERAL
;
544 cancelCommandExecution(
546 generateErrorArguments(aUncPath
),
548 rtl::OUString( "there were problems with the filesize"),
551 else if(errorCode
== TASKHANDLING_INPUTSTREAM_FOR_WRITE
)
553 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
555 MissingInputStreamException(
556 rtl::OUString( "the inputstream is missing necessary"
557 "to create a content"),
559 cancelCommandExecution(aAny
,xEnv
);
561 else if( errorCode
== TASKHANDLING_NOREPLACE_FOR_WRITE
)
562 // Overwrite = false and file exists
564 NameClashException excep
;
565 excep
.Name
= getTitle(aUncPath
);
566 excep
.Classification
= InteractionClassification_ERROR
;
567 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
568 excep
.Context
= xContext
;
569 excep
.Message
= rtl::OUString( "file exists and overwrite forbidden");
571 cancelCommandExecution( aAny
,xEnv
);
573 else if( errorCode
== TASKHANDLING_INVALID_NAME_MKDIR
)
575 InteractiveAugmentedIOException excep
;
576 excep
.Code
= IOErrorCode_INVALID_CHARACTER
;
578 prop
.Name
= rtl::OUString("ResourceName");
580 rtl::OUString
m_aClashingName(
583 rtl_UriDecodeWithCharset
,
584 RTL_TEXTENCODING_UTF8
));
585 prop
.Value
<<= m_aClashingName
;
586 Sequence
<Any
> seq(1);
588 excep
.Arguments
= seq
;
589 excep
.Classification
= InteractionClassification_ERROR
;
590 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
591 excep
.Context
= xContext
;
592 excep
.Message
= rtl::OUString( "the name contained invalid characters");
597 cancelCommandExecution( aAny
,xEnv
);
599 // ioErrorCode = IOErrorCode_INVALID_CHARACTER;
600 // cancelCommandExecution(
602 // generateErrorArguments(aUncPath),
604 // rtl::OUString( "the name contained invalid characters"),
607 else if( errorCode
== TASKHANDLING_FOLDER_EXISTS_MKDIR
)
609 NameClashException excep
;
610 excep
.Name
= getTitle(aUncPath
);
611 excep
.Classification
= InteractionClassification_ERROR
;
612 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
613 excep
.Context
= xContext
;
614 excep
.Message
= rtl::OUString( "folder exists and overwrite forbidden");
619 cancelCommandExecution( aAny
,xEnv
);
621 // ioErrorCode = IOErrorCode_ALREADY_EXISTING;
622 // cancelCommandExecution(
624 // generateErrorArguments(aUncPath),
626 // rtl::OUString( "the folder exists"),
629 else if( errorCode
== TASKHANDLING_ENSUREDIR_FOR_WRITE
||
630 errorCode
== TASKHANDLING_CREATEDIRECTORY_MKDIR
)
634 case FileBase::E_ACCES
:
635 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
637 case FileBase::E_ROFS
:
638 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
640 case FileBase::E_NAMETOOLONG
:
641 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
644 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
647 cancelCommandExecution(
649 generateErrorArguments(getParentName(aUncPath
)),
650 //TODO! ok to supply physical URL to getParentName()?
652 rtl::OUString( "a folder could not be created"),
655 else if( errorCode
== TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE
||
656 errorCode
== TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE
||
657 errorCode
== TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE
)
661 case FileBase::E_INVAL
: // the format of the parameters was not valid
662 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
664 case FileBase::E_NOMEM
: // not enough memory for allocating structures
665 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
667 case FileBase::E_ROFS
: // #i4735# handle ROFS transparently as ACCESS_DENIED
668 case FileBase::E_ACCES
: // permission denied
669 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
671 case FileBase::E_MFILE
: // too many open files used by the process
672 case FileBase::E_NFILE
: // too many open files in the system
673 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
675 case FileBase::E_NOLINK
: // Link has been severed
676 case FileBase::E_NOENT
: // No such file or directory
677 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
679 case FileBase::E_NAMETOOLONG
: // File name too long
680 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
682 case FileBase::E_NOTDIR
: // A component of the path prefix of path is not a directory
683 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
685 case FileBase::E_LOOP
: // Too many symbolic links encountered
686 case FileBase::E_IO
: // I/O error
687 case FileBase::E_MULTIHOP
: // Multihop attempted
688 case FileBase::E_FAULT
: // Bad address
689 case FileBase::E_INTR
: // function call was interrupted
690 case FileBase::E_NOSYS
: // Function not implemented
691 case FileBase::E_NOSPC
: // No space left on device
692 case FileBase::E_NXIO
: // No such device or address
693 case FileBase::E_OVERFLOW
: // Value too large for defined data type
694 case FileBase::E_BADF
: // Invalid oslDirectoryItem parameter
696 ioErrorCode
= IOErrorCode_GENERAL
;
699 cancelCommandExecution(
701 generateErrorArguments(aUncPath
),
703 rtl::OUString( "a file status object could not be filled"),
706 else if( errorCode
== TASKHANDLING_DELETEFILE_FOR_REMOVE
||
707 errorCode
== TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE
)
711 case FileBase::E_INVAL
: // the format of the parameters was not valid
712 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
714 case FileBase::E_NOMEM
: // not enough memory for allocating structures
715 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
717 case FileBase::E_ACCES
: // Permission denied
718 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
720 case FileBase::E_PERM
: // Operation not permitted
721 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
723 case FileBase::E_NAMETOOLONG
: // File name too long
724 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
726 case FileBase::E_NOLINK
: // Link has been severed
727 case FileBase::E_NOENT
: // No such file or directory
728 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
730 case FileBase::E_ISDIR
: // Is a directory
731 case FileBase::E_ROFS
: // Read-only file system
732 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
734 case FileBase::E_BUSY
: // Device or resource busy
735 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
737 case FileBase::E_FAULT
: // Bad address
738 case FileBase::E_LOOP
: // Too many symbolic links encountered
739 case FileBase::E_IO
: // I/O error
740 case FileBase::E_INTR
: // function call was interrupted
741 case FileBase::E_MULTIHOP
: // Multihop attempted
743 ioErrorCode
= IOErrorCode_GENERAL
;
746 cancelCommandExecution(
748 generateErrorArguments(aUncPath
),
750 rtl::OUString( "a file or directory could not be deleted"),
753 else if( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
754 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
755 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
756 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
||
757 errorCode
== TASKHANDLING_TRANSFER_DESTFILETYPE
||
758 errorCode
== TASKHANDLING_FILETYPE_FOR_REMOVE
||
759 errorCode
== TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE
||
760 errorCode
== TASKHANDLING_TRANSFER_INVALIDURL
)
765 case FileBase::E_NOENT
: // No such file or directory
766 if ( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
767 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
768 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
769 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
)
771 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
772 aMsg
= rtl::OUString( "source file/folder does not exist");
777 ioErrorCode
= IOErrorCode_GENERAL
;
778 aMsg
= rtl::OUString( "a general error during transfer command");
782 ioErrorCode
= IOErrorCode_GENERAL
;
783 aMsg
= rtl::OUString( "a general error during transfer command");
786 cancelCommandExecution(
788 generateErrorArguments(aUncPath
),
793 else if( errorCode
== TASKHANDLING_TRANSFER_ACCESSINGROOT
)
795 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
796 cancelCommandExecution(
798 generateErrorArguments(aUncPath
),
800 rtl::OUString( "accessing the root during transfer"),
803 else if( errorCode
== TASKHANDLING_TRANSFER_INVALIDSCHEME
)
805 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
808 InteractiveBadTransferURLException(
809 rtl::OUString( "bad tranfer url"),
811 cancelCommandExecution( aAny
,xEnv
);
813 else if( errorCode
== TASKHANDLING_OVERWRITE_FOR_MOVE
||
814 errorCode
== TASKHANDLING_OVERWRITE_FOR_COPY
||
815 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_MOVE
||
816 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_COPY
||
817 errorCode
== TASKHANDLING_KEEPERROR_FOR_MOVE
||
818 errorCode
== TASKHANDLING_KEEPERROR_FOR_COPY
||
819 errorCode
== TASKHANDLING_RENAME_FOR_MOVE
||
820 errorCode
== TASKHANDLING_RENAME_FOR_COPY
||
821 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_MOVE
||
822 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_COPY
)
825 "general error during transfer");
829 case FileBase::E_EXIST
:
830 ioErrorCode
= IOErrorCode_ALREADY_EXISTING
;
832 case FileBase::E_INVAL
: // the format of the parameters was not valid
833 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
835 case FileBase::E_NOMEM
: // not enough memory for allocating structures
836 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
838 case FileBase::E_ACCES
: // Permission denied
839 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
841 case FileBase::E_PERM
: // Operation not permitted
842 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
844 case FileBase::E_NAMETOOLONG
: // File name too long
845 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
847 case FileBase::E_NOENT
: // No such file or directory
848 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
849 aMsg
= rtl::OUString( "file/folder does not exist");
851 case FileBase::E_ROFS
: // Read-only file system<p>
852 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
855 ioErrorCode
= IOErrorCode_GENERAL
;
858 cancelCommandExecution(
860 generateErrorArguments(aUncPath
),
865 else if( errorCode
== TASKHANDLING_NAMECLASH_FOR_COPY
||
866 errorCode
== TASKHANDLING_NAMECLASH_FOR_MOVE
)
868 NameClashException excep
;
869 excep
.Name
= getTitle(aUncPath
);
870 excep
.Classification
= InteractionClassification_ERROR
;
871 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
872 excep
.Context
= xContext
;
873 excep
.Message
= rtl::OUString( "name clash during copy or move");
876 cancelCommandExecution(aAny
,xEnv
);
878 else if( errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE
||
879 errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY
)
881 Reference
<XInterface
> xContext(
883 UnsupportedNameClashException excep
;
884 excep
.NameClash
= minorCode
;
885 excep
.Context
= xContext
;
886 excep
.Message
= rtl::OUString( "name clash value not supported during copy or move");
889 cancelCommandExecution(aAny
,xEnv
);
893 // case TASKHANDLER_NO_ERROR:
899 } // end namespace fileaccess
901 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */