1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "filglob.hxx"
21 #include "filerror.hxx"
23 #include <osl/file.hxx>
24 #include <ucbhelper/cancelcommandexecution.hxx>
25 #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
26 #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
27 #include <com/sun/star/lang/IllegalArgumentException.hpp>
28 #include <com/sun/star/ucb/IOErrorCode.hpp>
29 #include <com/sun/star/ucb/MissingPropertiesException.hpp>
30 #include <com/sun/star/ucb/MissingInputStreamException.hpp>
31 #include <com/sun/star/ucb/NameClashException.hpp>
32 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
33 #include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
34 #include <com/sun/star/beans/PropertyState.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
37 #include <com/sun/star/uno/Any.hxx>
38 #include <com/sun/star/uno/Sequence.hxx>
39 #include <osl/diagnose.h>
40 #include <rtl/uri.hxx>
41 #include <rtl/ustring.hxx>
42 #include <sal/types.h>
44 using namespace ucbhelper
;
46 using namespace ::com::sun::star
;
47 using namespace com::sun::star::task
;
48 using namespace com::sun::star::beans
;
49 using namespace com::sun::star::lang
;
50 using namespace com::sun::star::uno
;
51 using namespace com::sun::star::ucb
;
55 Sequence
< Any
> generateErrorArguments(
56 OUString
const & rPhysicalUrl
)
58 OUString aResourceName
;
59 OUString aResourceType
;
60 bool bRemovable
= false;
61 bool bResourceName
= false;
62 bool bResourceType
= false;
63 bool bRemoveProperty
= false;
65 if (osl::FileBase::getSystemPathFromFileURL(
68 == osl::FileBase::E_None
)
71 // The resource types "folder" (i.e., directory) and
72 // "volume" seem to be
73 // the most interesting when producing meaningful error messages:
74 osl::DirectoryItem aItem
;
75 if (osl::DirectoryItem::get(rPhysicalUrl
, aItem
) ==
76 osl::FileBase::E_None
)
78 osl::FileStatus
aStatus( osl_FileStatus_Mask_Type
);
79 if (aItem
.getFileStatus(aStatus
) == osl::FileBase::E_None
)
80 switch (aStatus
.getFileType())
82 case osl::FileStatus::Directory
:
83 aResourceType
= "folder";
87 case osl::FileStatus::Volume
:
89 aResourceType
= "volume";
91 osl::VolumeInfo
aVolumeInfo(
92 osl_VolumeInfo_Mask_Attributes
);
93 if( osl::Directory::getVolumeInfo(
94 rPhysicalUrl
,aVolumeInfo
) ==
95 osl::FileBase::E_None
)
97 bRemovable
= aVolumeInfo
.getRemoveableFlag();
98 bRemoveProperty
= true;
102 case osl::FileStatus::Regular
:
103 case osl::FileStatus::Fifo
:
104 case osl::FileStatus::Socket
:
105 case osl::FileStatus::Link
:
106 case osl::FileStatus::Special
:
107 case osl::FileStatus::Unknown
:
108 // do nothing for now
113 Sequence
< Any
> aArguments( 1 +
114 (bResourceName
? 1 : 0) +
115 (bResourceType
? 1 : 0) +
116 (bRemoveProperty
? 1 : 0) );
119 <<= PropertyValue("Uri",
121 makeAny(rPhysicalUrl
),
122 PropertyState_DIRECT_VALUE
);
125 <<= PropertyValue("ResourceName",
127 makeAny(aResourceName
),
128 PropertyState_DIRECT_VALUE
);
131 <<= PropertyValue("ResourceType",
133 makeAny(aResourceType
),
134 PropertyState_DIRECT_VALUE
);
137 <<= PropertyValue("Removable",
140 PropertyState_DIRECT_VALUE
);
147 namespace fileaccess
{
150 bool isChild( const OUString
& srcUnqPath
,
151 const OUString
& dstUnqPath
)
153 static const sal_Unicode slash
= '/';
154 // Simple lexical comparison
155 sal_Int32 srcL
= srcUnqPath
.getLength();
156 sal_Int32 dstL
= dstUnqPath
.getLength();
159 ( srcUnqPath
== dstUnqPath
)
163 dstUnqPath
.startsWith(srcUnqPath
)
165 ( dstUnqPath
[ srcL
] == slash
) )
171 const OUString
& aNewPrefix
,
172 const OUString
& aOldPrefix
,
173 const OUString
& old_Name
)
175 sal_Int32 srcL
= aOldPrefix
.getLength();
177 return aNewPrefix
+ old_Name
.copy( srcL
);
181 OUString
getTitle( const OUString
& aPath
)
183 sal_Int32 lastIndex
= aPath
.lastIndexOf( '/' );
184 return aPath
.copy( lastIndex
+ 1 );
188 OUString
getParentName( const OUString
& aFileName
)
190 sal_Int32 lastIndex
= aFileName
.lastIndexOf( '/' );
191 OUString aParent
= aFileName
.copy( 0,lastIndex
);
193 if( aParent
.endsWith(":") && aParent
.getLength() == 6 )
196 if ( aParent
== "file://" )
197 aParent
= "file:///";
203 osl::FileBase::RC
osl_File_copy( const OUString
& strPath
,
204 const OUString
& strDestPath
,
209 osl::DirectoryItem aItem
;
210 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
211 return osl::FileBase::E_EXIST
;
214 return osl::File::copy( strPath
,strDestPath
);
218 osl::FileBase::RC
osl_File_move( const OUString
& strPath
,
219 const OUString
& strDestPath
,
224 osl::DirectoryItem aItem
;
225 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
226 return osl::FileBase::E_EXIST
;
229 return osl::File::move( strPath
,strDestPath
);
235 const Reference
< XCommandEnvironment
>& xEnv
,
236 const OUString
& aUncPath
,
237 BaseContent
* pContent
,
240 Reference
<XCommandProcessor
> xComProc(pContent
);
242 IOErrorCode ioErrorCode
;
244 if( errorCode
== TASKHANDLER_UNSUPPORTED_COMMAND
)
246 aAny
<<= UnsupportedCommandException( OSL_LOG_PREFIX
);
247 cancelCommandExecution( aAny
,xEnv
);
249 else if( errorCode
== TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT
||
250 errorCode
== TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT
||
251 errorCode
== TASKHANDLING_WRONG_OPEN_ARGUMENT
||
252 errorCode
== TASKHANDLING_WRONG_DELETE_ARGUMENT
||
253 errorCode
== TASKHANDLING_WRONG_TRANSFER_ARGUMENT
||
254 errorCode
== TASKHANDLING_WRONG_INSERT_ARGUMENT
||
255 errorCode
== TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT
)
257 IllegalArgumentException excep
;
258 excep
.ArgumentPosition
= 0;
259 cancelCommandExecution(Any(excep
), xEnv
);
261 else if( errorCode
== TASKHANDLING_UNSUPPORTED_OPEN_MODE
)
263 UnsupportedOpenModeException excep
;
264 excep
.Mode
= sal::static_int_cast
< sal_Int16
>(minorCode
);
265 cancelCommandExecution( Any(excep
),xEnv
);
267 else if(errorCode
== TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND
||
268 errorCode
== TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND
||
269 errorCode
== TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND
)
274 // error in opening file
275 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE
||
276 // error in opening file
277 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_WRITE
||
278 // error in opening file
279 errorCode
== TASKHANDLING_OPEN_FOR_STREAM
||
280 // error in opening file
281 errorCode
== TASKHANDLING_OPEN_FOR_INPUTSTREAM
||
282 // error in opening file
283 errorCode
== TASKHANDLING_OPEN_FILE_FOR_PAGING
)
287 case FileBase::E_NAMETOOLONG
:
288 // pathname was too long
289 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
291 case FileBase::E_NXIO
:
292 // No such device or address
293 case FileBase::E_NODEV
:
295 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
297 case FileBase::E_NOTDIR
:
298 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
300 case FileBase::E_NOENT
:
301 // No such file or directory
302 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
304 case FileBase::E_ROFS
:
305 // #i4735# handle ROFS transparently as ACCESS_DENIED
306 case FileBase::E_ACCES
:
307 case FileBase::E_PERM
:
308 // permission denied<P>
309 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
311 case FileBase::E_ISDIR
:
313 ioErrorCode
= IOErrorCode_NO_FILE
;
315 case FileBase::E_NOTREADY
:
316 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
318 case FileBase::E_MFILE
:
319 // too many open files used by the process
320 case FileBase::E_NFILE
:
321 // too many open files in the system
322 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
324 case FileBase::E_INVAL
:
325 // the format of the parameters was not valid
326 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
328 case FileBase::E_NOMEM
:
329 // not enough memory for allocating structures
330 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
332 case FileBase::E_BUSY
:
334 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
336 case FileBase::E_AGAIN
:
337 // Operation would block
338 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
340 case FileBase::E_NOLCK
: // No record locks available
341 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
343 case FileBase::E_NOSYS
:
344 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
346 case FileBase::E_FAULT
: // Bad address
347 case FileBase::E_LOOP
: // Too many symbolic links encountered
348 case FileBase::E_NOSPC
: // No space left on device
349 case FileBase::E_INTR
: // function call was interrupted
350 case FileBase::E_IO
: // I/O error
351 case FileBase::E_MULTIHOP
: // Multihop attempted
352 case FileBase::E_NOLINK
: // Link has been severed
354 ioErrorCode
= IOErrorCode_GENERAL
;
358 cancelCommandExecution(
360 generateErrorArguments(aUncPath
),
362 "an error occurred during file opening",
365 else if( errorCode
== TASKHANDLING_OPEN_FOR_DIRECTORYLISTING
||
366 errorCode
== TASKHANDLING_OPENDIRECTORY_FOR_REMOVE
)
370 case FileBase::E_INVAL
:
371 // the format of the parameters was not valid
372 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
374 case FileBase::E_NOENT
:
375 // the specified path doesn't exist
376 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
378 case FileBase::E_NOTDIR
:
379 // the specified path is not a directory
380 ioErrorCode
= IOErrorCode_NO_DIRECTORY
;
382 case FileBase::E_NOMEM
:
383 // not enough memory for allocating structures
384 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
386 case FileBase::E_ROFS
:
387 // #i4735# handle ROFS transparently as ACCESS_DENIED
388 case FileBase::E_ACCES
: // permission denied
389 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
391 case FileBase::E_NOTREADY
:
392 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
394 case FileBase::E_MFILE
:
395 // too many open files used by the process
396 case FileBase::E_NFILE
:
397 // too many open files in the system
398 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
400 case FileBase::E_NAMETOOLONG
:
401 // File name too long
402 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
404 case FileBase::E_LOOP
:
405 // Too many symbolic links encountered<p>
407 ioErrorCode
= IOErrorCode_GENERAL
;
411 cancelCommandExecution(
413 generateErrorArguments(aUncPath
),
415 "an error occurred during opening a directory",
418 else if( errorCode
== TASKHANDLING_NOTCONNECTED_FOR_WRITE
||
419 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE
||
420 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_WRITE
||
421 errorCode
== TASKHANDLING_NOTCONNECTED_FOR_PAGING
||
422 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING
||
423 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_PAGING
)
425 ioErrorCode
= IOErrorCode_UNKNOWN
;
426 cancelCommandExecution(
428 generateErrorArguments(aUncPath
),
430 "an error occurred writing or reading from a file",
433 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_NO_SPACE
)
435 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
436 cancelCommandExecution(
438 generateErrorArguments(aUncPath
),
443 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_WRITE
||
444 errorCode
== TASKHANDLING_READING_FILE_FOR_PAGING
)
448 case FileBase::E_INVAL
:
449 // the format of the parameters was not valid
450 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
452 case FileBase::E_FBIG
:
454 ioErrorCode
= IOErrorCode_CANT_WRITE
;
456 case FileBase::E_NOSPC
:
457 // No space left on device
458 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
460 case FileBase::E_NXIO
:
461 // No such device or address
462 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
464 case FileBase::E_NOLINK
:
465 // Link has been severed
466 case FileBase::E_ISDIR
:
468 ioErrorCode
= IOErrorCode_NO_FILE
;
470 case FileBase::E_AGAIN
:
471 // Operation would block
472 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
474 case FileBase::E_TIMEDOUT
:
475 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
477 case FileBase::E_NOLCK
: // No record locks available
478 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
480 case FileBase::E_IO
: // I/O error
481 case FileBase::E_BADF
: // Bad file
482 case FileBase::E_FAULT
: // Bad address
483 case FileBase::E_INTR
: // function call was interrupted
485 ioErrorCode
= IOErrorCode_GENERAL
;
488 cancelCommandExecution(
490 generateErrorArguments(aUncPath
),
492 "an error occurred during opening a file",
495 else if( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
||
496 errorCode
== TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND
)
498 Sequence
< OUString
> aSeq( 1 );
500 ( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
) ?
501 OUStringLiteral("Title") :
502 OUStringLiteral("ContentType");
504 aAny
<<= MissingPropertiesException(
505 "a property is missing, necessary to create a content",
508 cancelCommandExecution(aAny
,xEnv
);
510 else if( errorCode
== TASKHANDLING_FILESIZE_FOR_WRITE
)
514 case FileBase::E_INVAL
:
515 // the format of the parameters was not valid
516 case FileBase::E_OVERFLOW
:
517 // The resulting file offset would be a value which cannot
518 // be represented correctly for regular files
519 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
522 ioErrorCode
= IOErrorCode_GENERAL
;
525 cancelCommandExecution(
527 generateErrorArguments(aUncPath
),
529 "there were problems with the filesize",
532 else if(errorCode
== TASKHANDLING_INPUTSTREAM_FOR_WRITE
)
535 MissingInputStreamException(
536 "the inputstream is missing, necessary to create a content",
538 cancelCommandExecution(aAny
,xEnv
);
540 else if( errorCode
== TASKHANDLING_NOREPLACE_FOR_WRITE
)
541 // Overwrite = false and file exists
543 NameClashException excep
;
544 excep
.Name
= getTitle(aUncPath
);
545 excep
.Classification
= InteractionClassification_ERROR
;
546 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
547 excep
.Message
= "file exists and overwrite forbidden";
548 cancelCommandExecution( Any(excep
), xEnv
);
550 else if( errorCode
== TASKHANDLING_INVALID_NAME_MKDIR
)
552 InteractiveAugmentedIOException excep
;
553 excep
.Code
= IOErrorCode_INVALID_CHARACTER
;
555 prop
.Name
= "ResourceName";
557 OUString
aClashingName(
560 rtl_UriDecodeWithCharset
,
561 RTL_TEXTENCODING_UTF8
));
562 prop
.Value
<<= aClashingName
;
563 Sequence
<Any
> seq(1);
565 excep
.Arguments
= seq
;
566 excep
.Classification
= InteractionClassification_ERROR
;
567 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
568 excep
.Message
= "the name contained invalid characters";
571 cancelCommandExecution( Any(excep
), xEnv
);
572 // ioErrorCode = IOErrorCode_INVALID_CHARACTER;
573 // cancelCommandExecution(
575 // generateErrorArguments(aUncPath),
577 // OUString( "the name contained invalid characters"),
580 else if( errorCode
== TASKHANDLING_FOLDER_EXISTS_MKDIR
)
582 NameClashException excep
;
583 excep
.Name
= getTitle(aUncPath
);
584 excep
.Classification
= InteractionClassification_ERROR
;
585 excep
.Context
= xComProc
;
586 excep
.Message
= "folder exists and overwrite forbidden";
589 cancelCommandExecution( Any(excep
), xEnv
);
590 // ioErrorCode = IOErrorCode_ALREADY_EXISTING;
591 // cancelCommandExecution(
593 // generateErrorArguments(aUncPath),
595 // OUString( "the folder exists"),
598 else if( errorCode
== TASKHANDLING_ENSUREDIR_FOR_WRITE
||
599 errorCode
== TASKHANDLING_CREATEDIRECTORY_MKDIR
)
603 case FileBase::E_ACCES
:
604 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
606 case FileBase::E_ROFS
:
607 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
609 case FileBase::E_NAMETOOLONG
:
610 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
613 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
616 cancelCommandExecution(
618 generateErrorArguments(getParentName(aUncPath
)),
619 //TODO! ok to supply physical URL to getParentName()?
621 "a folder could not be created",
624 else if( errorCode
== TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE
||
625 errorCode
== TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE
||
626 errorCode
== TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE
)
630 case FileBase::E_INVAL
: // the format of the parameters was not valid
631 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
633 case FileBase::E_NOMEM
: // not enough memory for allocating structures
634 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
636 case FileBase::E_ROFS
: // #i4735# handle ROFS transparently as ACCESS_DENIED
637 case FileBase::E_ACCES
: // permission denied
638 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
640 case FileBase::E_MFILE
: // too many open files used by the process
641 case FileBase::E_NFILE
: // too many open files in the system
642 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
644 case FileBase::E_NOLINK
: // Link has been severed
645 case FileBase::E_NOENT
: // No such file or directory
646 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
648 case FileBase::E_NAMETOOLONG
: // File name too long
649 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
651 case FileBase::E_NOTDIR
: // A component of the path prefix of path is not a directory
652 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
654 case FileBase::E_LOOP
: // Too many symbolic links encountered
655 case FileBase::E_IO
: // I/O error
656 case FileBase::E_MULTIHOP
: // Multihop attempted
657 case FileBase::E_FAULT
: // Bad address
658 case FileBase::E_INTR
: // function call was interrupted
659 case FileBase::E_NOSYS
: // Function not implemented
660 case FileBase::E_NOSPC
: // No space left on device
661 case FileBase::E_NXIO
: // No such device or address
662 case FileBase::E_OVERFLOW
: // Value too large for defined data type
663 case FileBase::E_BADF
: // Invalid oslDirectoryItem parameter
665 ioErrorCode
= IOErrorCode_GENERAL
;
668 cancelCommandExecution(
670 generateErrorArguments(aUncPath
),
672 "a file status object could not be filled",
675 else if( errorCode
== TASKHANDLING_DELETEFILE_FOR_REMOVE
||
676 errorCode
== TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE
)
680 case FileBase::E_INVAL
: // the format of the parameters was not valid
681 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
683 case FileBase::E_NOMEM
: // not enough memory for allocating structures
684 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
686 case FileBase::E_ACCES
: // Permission denied
687 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
689 case FileBase::E_PERM
: // Operation not permitted
690 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
692 case FileBase::E_NAMETOOLONG
: // File name too long
693 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
695 case FileBase::E_NOLINK
: // Link has been severed
696 case FileBase::E_NOENT
: // No such file or directory
697 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
699 case FileBase::E_ISDIR
: // Is a directory
700 case FileBase::E_ROFS
: // Read-only file system
701 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
703 case FileBase::E_BUSY
: // Device or resource busy
704 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
706 case FileBase::E_FAULT
: // Bad address
707 case FileBase::E_LOOP
: // Too many symbolic links encountered
708 case FileBase::E_IO
: // I/O error
709 case FileBase::E_INTR
: // function call was interrupted
710 case FileBase::E_MULTIHOP
: // Multihop attempted
712 ioErrorCode
= IOErrorCode_GENERAL
;
715 cancelCommandExecution(
717 generateErrorArguments(aUncPath
),
719 "a file or directory could not be deleted",
722 else if( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
723 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
724 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
725 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
||
726 errorCode
== TASKHANDLING_TRANSFER_DESTFILETYPE
||
727 errorCode
== TASKHANDLING_FILETYPE_FOR_REMOVE
||
728 errorCode
== TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE
||
729 errorCode
== TASKHANDLING_TRANSFER_INVALIDURL
)
734 case FileBase::E_NOENT
: // No such file or directory
735 if ( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
736 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
737 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
738 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
)
740 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
741 aMsg
= "source file/folder does not exist";
746 ioErrorCode
= IOErrorCode_GENERAL
;
747 aMsg
= "a general error during transfer command";
751 ioErrorCode
= IOErrorCode_GENERAL
;
752 aMsg
= "a general error during transfer command";
755 cancelCommandExecution(
757 generateErrorArguments(aUncPath
),
762 else if( errorCode
== TASKHANDLING_TRANSFER_ACCESSINGROOT
)
764 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
765 cancelCommandExecution(
767 generateErrorArguments(aUncPath
),
769 "accessing the root during transfer",
772 else if( errorCode
== TASKHANDLING_TRANSFER_INVALIDSCHEME
)
774 aAny
<<= InteractiveBadTransferURLException(
777 cancelCommandExecution( aAny
,xEnv
);
779 else if( errorCode
== TASKHANDLING_OVERWRITE_FOR_MOVE
||
780 errorCode
== TASKHANDLING_OVERWRITE_FOR_COPY
||
781 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_MOVE
||
782 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_COPY
||
783 errorCode
== TASKHANDLING_KEEPERROR_FOR_MOVE
||
784 errorCode
== TASKHANDLING_KEEPERROR_FOR_COPY
||
785 errorCode
== TASKHANDLING_RENAME_FOR_MOVE
||
786 errorCode
== TASKHANDLING_RENAME_FOR_COPY
||
787 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_MOVE
||
788 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_COPY
)
791 "general error during transfer");
795 case FileBase::E_EXIST
:
796 ioErrorCode
= IOErrorCode_ALREADY_EXISTING
;
798 case FileBase::E_INVAL
: // the format of the parameters was not valid
799 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
801 case FileBase::E_NOMEM
: // not enough memory for allocating structures
802 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
804 case FileBase::E_ACCES
: // Permission denied
805 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
807 case FileBase::E_PERM
: // Operation not permitted
808 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
810 case FileBase::E_NAMETOOLONG
: // File name too long
811 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
813 case FileBase::E_NOENT
: // No such file or directory
814 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
815 aMsg
= "file/folder does not exist";
817 case FileBase::E_ROFS
: // Read-only file system<p>
818 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
821 ioErrorCode
= IOErrorCode_GENERAL
;
824 cancelCommandExecution(
826 generateErrorArguments(aUncPath
),
831 else if( errorCode
== TASKHANDLING_NAMECLASH_FOR_COPY
||
832 errorCode
== TASKHANDLING_NAMECLASH_FOR_MOVE
)
834 NameClashException excep
;
835 excep
.Name
= getTitle(aUncPath
);
836 excep
.Classification
= InteractionClassification_ERROR
;
837 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
838 excep
.Message
= "name clash during copy or move";
840 cancelCommandExecution(Any(excep
), xEnv
);
842 else if( errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE
||
843 errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY
)
845 UnsupportedNameClashException excep
;
846 excep
.NameClash
= minorCode
;
847 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
848 excep
.Message
= "name clash value not supported during copy or move";
850 cancelCommandExecution(Any(excep
), xEnv
);
854 // case TASKHANDLER_NO_ERROR:
860 } // end namespace fileaccess
862 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */