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 <sal/config.h>
22 #include <string_view>
24 #include "filglob.hxx"
25 #include "filerror.hxx"
27 #include <osl/file.hxx>
28 #include <ucbhelper/cancelcommandexecution.hxx>
29 #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
30 #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
31 #include <com/sun/star/lang/IllegalArgumentException.hpp>
32 #include <com/sun/star/ucb/IOErrorCode.hpp>
33 #include <com/sun/star/ucb/MissingPropertiesException.hpp>
34 #include <com/sun/star/ucb/MissingInputStreamException.hpp>
35 #include <com/sun/star/ucb/NameClashException.hpp>
36 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
37 #include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
38 #include <com/sun/star/beans/PropertyState.hpp>
39 #include <com/sun/star/beans/PropertyValue.hpp>
40 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
41 #include <com/sun/star/uno/Any.hxx>
42 #include <com/sun/star/uno/Sequence.hxx>
43 #include <osl/diagnose.h>
44 #include <rtl/uri.hxx>
45 #include <rtl/ustring.hxx>
46 #include <sal/types.h>
48 using namespace ucbhelper
;
50 using namespace ::com::sun::star
;
51 using namespace com::sun::star::task
;
52 using namespace com::sun::star::beans
;
53 using namespace com::sun::star::lang
;
54 using namespace com::sun::star::uno
;
55 using namespace com::sun::star::ucb
;
59 Sequence
< Any
> generateErrorArguments(
60 OUString
const & rPhysicalUrl
)
62 OUString aResourceName
;
63 OUString aResourceType
;
64 bool bRemovable
= false;
65 bool bResourceName
= false;
66 bool bResourceType
= false;
67 bool bRemoveProperty
= false;
69 if (osl::FileBase::getSystemPathFromFileURL(
72 == osl::FileBase::E_None
)
75 // The resource types "folder" (i.e., directory) and
76 // "volume" seem to be
77 // the most interesting when producing meaningful error messages:
78 osl::DirectoryItem aItem
;
79 if (osl::DirectoryItem::get(rPhysicalUrl
, aItem
) ==
80 osl::FileBase::E_None
)
82 osl::FileStatus
aStatus( osl_FileStatus_Mask_Type
);
83 if (aItem
.getFileStatus(aStatus
) == osl::FileBase::E_None
)
84 switch (aStatus
.getFileType())
86 case osl::FileStatus::Directory
:
87 aResourceType
= "folder";
91 case osl::FileStatus::Volume
:
93 aResourceType
= "volume";
95 osl::VolumeInfo
aVolumeInfo(
96 osl_VolumeInfo_Mask_Attributes
);
97 if( osl::Directory::getVolumeInfo(
98 rPhysicalUrl
,aVolumeInfo
) ==
99 osl::FileBase::E_None
)
101 bRemovable
= aVolumeInfo
.getRemoveableFlag();
102 bRemoveProperty
= true;
106 case osl::FileStatus::Regular
:
107 case osl::FileStatus::Fifo
:
108 case osl::FileStatus::Socket
:
109 case osl::FileStatus::Link
:
110 case osl::FileStatus::Special
:
111 case osl::FileStatus::Unknown
:
112 // do nothing for now
117 Sequence
< Any
> aArguments( 1 +
118 (bResourceName
? 1 : 0) +
119 (bResourceType
? 1 : 0) +
120 (bRemoveProperty
? 1 : 0) );
123 <<= PropertyValue("Uri",
125 makeAny(rPhysicalUrl
),
126 PropertyState_DIRECT_VALUE
);
129 <<= PropertyValue("ResourceName",
131 makeAny(aResourceName
),
132 PropertyState_DIRECT_VALUE
);
135 <<= PropertyValue("ResourceType",
137 makeAny(aResourceType
),
138 PropertyState_DIRECT_VALUE
);
141 <<= PropertyValue("Removable",
144 PropertyState_DIRECT_VALUE
);
151 namespace fileaccess
{
154 bool isChild( const OUString
& srcUnqPath
,
155 const OUString
& dstUnqPath
)
157 static const sal_Unicode slash
= '/';
158 // Simple lexical comparison
159 sal_Int32 srcL
= srcUnqPath
.getLength();
160 sal_Int32 dstL
= dstUnqPath
.getLength();
163 ( srcUnqPath
== dstUnqPath
)
167 dstUnqPath
.startsWith(srcUnqPath
)
169 ( dstUnqPath
[ srcL
] == slash
) )
175 std::u16string_view aNewPrefix
,
176 const OUString
& aOldPrefix
,
177 std::u16string_view old_Name
)
179 sal_Int32 srcL
= aOldPrefix
.getLength();
181 return OUString::Concat(aNewPrefix
) + old_Name
.substr( srcL
);
185 OUString
getTitle( const OUString
& aPath
)
187 sal_Int32 lastIndex
= aPath
.lastIndexOf( '/' );
188 return aPath
.copy( lastIndex
+ 1 );
192 OUString
getParentName( const OUString
& aFileName
)
194 sal_Int32 lastIndex
= aFileName
.lastIndexOf( '/' );
195 OUString aParent
= aFileName
.copy( 0,lastIndex
);
197 if( aParent
.endsWith(":") && aParent
.getLength() == 6 )
200 if ( aParent
== "file://" )
201 aParent
= "file:///";
207 osl::FileBase::RC
osl_File_copy( const OUString
& strPath
,
208 const OUString
& strDestPath
,
213 osl::DirectoryItem aItem
;
214 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
215 return osl::FileBase::E_EXIST
;
218 return osl::File::copy( strPath
,strDestPath
);
222 osl::FileBase::RC
osl_File_move( const OUString
& strPath
,
223 const OUString
& strDestPath
,
228 osl::DirectoryItem aItem
;
229 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
230 return osl::FileBase::E_EXIST
;
233 return osl::File::move( strPath
,strDestPath
);
239 const Reference
< XCommandEnvironment
>& xEnv
,
240 const OUString
& aUncPath
,
241 BaseContent
* pContent
,
244 Reference
<XCommandProcessor
> xComProc(pContent
);
246 IOErrorCode ioErrorCode
;
248 if( errorCode
== TASKHANDLER_UNSUPPORTED_COMMAND
)
250 aAny
<<= UnsupportedCommandException( OSL_LOG_PREFIX
);
251 cancelCommandExecution( aAny
,xEnv
);
253 else if( errorCode
== TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT
||
254 errorCode
== TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT
||
255 errorCode
== TASKHANDLING_WRONG_OPEN_ARGUMENT
||
256 errorCode
== TASKHANDLING_WRONG_DELETE_ARGUMENT
||
257 errorCode
== TASKHANDLING_WRONG_TRANSFER_ARGUMENT
||
258 errorCode
== TASKHANDLING_WRONG_INSERT_ARGUMENT
||
259 errorCode
== TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT
)
261 IllegalArgumentException excep
;
262 excep
.ArgumentPosition
= 0;
263 cancelCommandExecution(Any(excep
), xEnv
);
265 else if( errorCode
== TASKHANDLING_UNSUPPORTED_OPEN_MODE
)
267 UnsupportedOpenModeException excep
;
268 excep
.Mode
= sal::static_int_cast
< sal_Int16
>(minorCode
);
269 cancelCommandExecution( Any(excep
),xEnv
);
271 else if(errorCode
== TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND
||
272 errorCode
== TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND
||
273 errorCode
== TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND
)
278 // error in opening file
279 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE
||
280 // error in opening file
281 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_WRITE
||
282 // error in opening file
283 errorCode
== TASKHANDLING_OPEN_FOR_STREAM
||
284 // error in opening file
285 errorCode
== TASKHANDLING_OPEN_FOR_INPUTSTREAM
||
286 // error in opening file
287 errorCode
== TASKHANDLING_OPEN_FILE_FOR_PAGING
)
291 case FileBase::E_NAMETOOLONG
:
292 // pathname was too long
293 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
295 case FileBase::E_NXIO
:
296 // No such device or address
297 case FileBase::E_NODEV
:
299 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
301 case FileBase::E_NOTDIR
:
302 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
304 case FileBase::E_NOENT
:
305 // No such file or directory
306 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
308 case FileBase::E_ROFS
:
309 // #i4735# handle ROFS transparently as ACCESS_DENIED
310 case FileBase::E_ACCES
:
311 case FileBase::E_PERM
:
312 // permission denied<P>
313 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
315 case FileBase::E_ISDIR
:
317 ioErrorCode
= IOErrorCode_NO_FILE
;
319 case FileBase::E_NOTREADY
:
320 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
322 case FileBase::E_MFILE
:
323 // too many open files used by the process
324 case FileBase::E_NFILE
:
325 // too many open files in the system
326 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
328 case FileBase::E_INVAL
:
329 // the format of the parameters was not valid
330 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
332 case FileBase::E_NOMEM
:
333 // not enough memory for allocating structures
334 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
336 case FileBase::E_BUSY
:
338 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
340 case FileBase::E_AGAIN
:
341 // Operation would block
342 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
344 case FileBase::E_NOLCK
: // No record locks available
345 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
347 case FileBase::E_NOSYS
:
348 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
350 case FileBase::E_FAULT
: // Bad address
351 case FileBase::E_LOOP
: // Too many symbolic links encountered
352 case FileBase::E_NOSPC
: // No space left on device
353 case FileBase::E_INTR
: // function call was interrupted
354 case FileBase::E_IO
: // I/O error
355 case FileBase::E_MULTIHOP
: // Multihop attempted
356 case FileBase::E_NOLINK
: // Link has been severed
358 ioErrorCode
= IOErrorCode_GENERAL
;
362 cancelCommandExecution(
364 generateErrorArguments(aUncPath
),
366 "an error occurred during file opening",
369 else if( errorCode
== TASKHANDLING_OPEN_FOR_DIRECTORYLISTING
||
370 errorCode
== TASKHANDLING_OPENDIRECTORY_FOR_REMOVE
)
374 case FileBase::E_INVAL
:
375 // the format of the parameters was not valid
376 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
378 case FileBase::E_NOENT
:
379 // the specified path doesn't exist
380 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
382 case FileBase::E_NOTDIR
:
383 // the specified path is not a directory
384 ioErrorCode
= IOErrorCode_NO_DIRECTORY
;
386 case FileBase::E_NOMEM
:
387 // not enough memory for allocating structures
388 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
390 case FileBase::E_ROFS
:
391 // #i4735# handle ROFS transparently as ACCESS_DENIED
392 case FileBase::E_ACCES
: // permission denied
393 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
395 case FileBase::E_NOTREADY
:
396 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
398 case FileBase::E_MFILE
:
399 // too many open files used by the process
400 case FileBase::E_NFILE
:
401 // too many open files in the system
402 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
404 case FileBase::E_NAMETOOLONG
:
405 // File name too long
406 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
408 case FileBase::E_LOOP
:
409 // Too many symbolic links encountered<p>
411 ioErrorCode
= IOErrorCode_GENERAL
;
415 cancelCommandExecution(
417 generateErrorArguments(aUncPath
),
419 "an error occurred during opening a directory",
422 else if( errorCode
== TASKHANDLING_NOTCONNECTED_FOR_WRITE
||
423 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE
||
424 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_WRITE
||
425 errorCode
== TASKHANDLING_NOTCONNECTED_FOR_PAGING
||
426 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING
||
427 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_PAGING
)
429 ioErrorCode
= IOErrorCode_UNKNOWN
;
430 cancelCommandExecution(
432 generateErrorArguments(aUncPath
),
434 "an error occurred writing or reading from a file",
437 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_NO_SPACE
)
439 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
440 cancelCommandExecution(
442 generateErrorArguments(aUncPath
),
447 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_WRITE
||
448 errorCode
== TASKHANDLING_READING_FILE_FOR_PAGING
)
452 case FileBase::E_INVAL
:
453 // the format of the parameters was not valid
454 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
456 case FileBase::E_FBIG
:
458 ioErrorCode
= IOErrorCode_CANT_WRITE
;
460 case FileBase::E_NOSPC
:
461 // No space left on device
462 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
464 case FileBase::E_NXIO
:
465 // No such device or address
466 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
468 case FileBase::E_NOLINK
:
469 // Link has been severed
470 case FileBase::E_ISDIR
:
472 ioErrorCode
= IOErrorCode_NO_FILE
;
474 case FileBase::E_AGAIN
:
475 // Operation would block
476 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
478 case FileBase::E_TIMEDOUT
:
479 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
481 case FileBase::E_NOLCK
: // No record locks available
482 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
484 case FileBase::E_IO
: // I/O error
485 case FileBase::E_BADF
: // Bad file
486 case FileBase::E_FAULT
: // Bad address
487 case FileBase::E_INTR
: // function call was interrupted
489 ioErrorCode
= IOErrorCode_GENERAL
;
492 cancelCommandExecution(
494 generateErrorArguments(aUncPath
),
496 "an error occurred during opening a file",
499 else if( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
||
500 errorCode
== TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND
)
502 Sequence
< OUString
> aSeq( 1 );
504 ( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
) ?
505 std::u16string_view(u
"Title") :
506 std::u16string_view(u
"ContentType");
508 aAny
<<= MissingPropertiesException(
509 "a property is missing, necessary to create a content",
512 cancelCommandExecution(aAny
,xEnv
);
514 else if( errorCode
== TASKHANDLING_FILESIZE_FOR_WRITE
)
518 case FileBase::E_INVAL
:
519 // the format of the parameters was not valid
520 case FileBase::E_OVERFLOW
:
521 // The resulting file offset would be a value which cannot
522 // be represented correctly for regular files
523 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
526 ioErrorCode
= IOErrorCode_GENERAL
;
529 cancelCommandExecution(
531 generateErrorArguments(aUncPath
),
533 "there were problems with the filesize",
536 else if(errorCode
== TASKHANDLING_INPUTSTREAM_FOR_WRITE
)
539 MissingInputStreamException(
540 "the inputstream is missing, necessary to create a content",
542 cancelCommandExecution(aAny
,xEnv
);
544 else if( errorCode
== TASKHANDLING_NOREPLACE_FOR_WRITE
)
545 // Overwrite = false and file exists
547 NameClashException excep
;
548 excep
.Name
= getTitle(aUncPath
);
549 excep
.Classification
= InteractionClassification_ERROR
;
550 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
551 excep
.Message
= "file exists and overwrite forbidden";
552 cancelCommandExecution( Any(excep
), xEnv
);
554 else if( errorCode
== TASKHANDLING_INVALID_NAME_MKDIR
)
556 InteractiveAugmentedIOException excep
;
557 excep
.Code
= IOErrorCode_INVALID_CHARACTER
;
559 prop
.Name
= "ResourceName";
561 OUString
aClashingName(
564 rtl_UriDecodeWithCharset
,
565 RTL_TEXTENCODING_UTF8
));
566 prop
.Value
<<= aClashingName
;
567 excep
.Arguments
= { Any(prop
) };
568 excep
.Classification
= InteractionClassification_ERROR
;
569 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
570 excep
.Message
= "the name contained invalid characters";
573 cancelCommandExecution( Any(excep
), xEnv
);
574 // ioErrorCode = IOErrorCode_INVALID_CHARACTER;
575 // cancelCommandExecution(
577 // generateErrorArguments(aUncPath),
579 // OUString( "the name contained invalid characters"),
582 else if( errorCode
== TASKHANDLING_FOLDER_EXISTS_MKDIR
)
584 NameClashException excep
;
585 excep
.Name
= getTitle(aUncPath
);
586 excep
.Classification
= InteractionClassification_ERROR
;
587 excep
.Context
= xComProc
;
588 excep
.Message
= "folder exists and overwrite forbidden";
591 cancelCommandExecution( Any(excep
), xEnv
);
592 // ioErrorCode = IOErrorCode_ALREADY_EXISTING;
593 // cancelCommandExecution(
595 // generateErrorArguments(aUncPath),
597 // OUString( "the folder exists"),
600 else if( errorCode
== TASKHANDLING_ENSUREDIR_FOR_WRITE
||
601 errorCode
== TASKHANDLING_CREATEDIRECTORY_MKDIR
)
605 case FileBase::E_ACCES
:
606 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
608 case FileBase::E_ROFS
:
609 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
611 case FileBase::E_NAMETOOLONG
:
612 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
615 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
618 cancelCommandExecution(
620 generateErrorArguments(getParentName(aUncPath
)),
621 //TODO! ok to supply physical URL to getParentName()?
623 "a folder could not be created",
626 else if( errorCode
== TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE
||
627 errorCode
== TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE
||
628 errorCode
== TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE
)
632 case FileBase::E_INVAL
: // the format of the parameters was not valid
633 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
635 case FileBase::E_NOMEM
: // not enough memory for allocating structures
636 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
638 case FileBase::E_ROFS
: // #i4735# handle ROFS transparently as ACCESS_DENIED
639 case FileBase::E_ACCES
: // permission denied
640 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
642 case FileBase::E_MFILE
: // too many open files used by the process
643 case FileBase::E_NFILE
: // too many open files in the system
644 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
646 case FileBase::E_NOLINK
: // Link has been severed
647 case FileBase::E_NOENT
: // No such file or directory
648 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
650 case FileBase::E_NAMETOOLONG
: // File name too long
651 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
653 case FileBase::E_NOTDIR
: // A component of the path prefix of path is not a directory
654 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
656 case FileBase::E_LOOP
: // Too many symbolic links encountered
657 case FileBase::E_IO
: // I/O error
658 case FileBase::E_MULTIHOP
: // Multihop attempted
659 case FileBase::E_FAULT
: // Bad address
660 case FileBase::E_INTR
: // function call was interrupted
661 case FileBase::E_NOSYS
: // Function not implemented
662 case FileBase::E_NOSPC
: // No space left on device
663 case FileBase::E_NXIO
: // No such device or address
664 case FileBase::E_OVERFLOW
: // Value too large for defined data type
665 case FileBase::E_BADF
: // Invalid oslDirectoryItem parameter
667 ioErrorCode
= IOErrorCode_GENERAL
;
670 cancelCommandExecution(
672 generateErrorArguments(aUncPath
),
674 "a file status object could not be filled",
677 else if( errorCode
== TASKHANDLING_DELETEFILE_FOR_REMOVE
||
678 errorCode
== TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE
)
682 case FileBase::E_INVAL
: // the format of the parameters was not valid
683 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
685 case FileBase::E_NOMEM
: // not enough memory for allocating structures
686 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
688 case FileBase::E_ACCES
: // Permission denied
689 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
691 case FileBase::E_PERM
: // Operation not permitted
692 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
694 case FileBase::E_NAMETOOLONG
: // File name too long
695 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
697 case FileBase::E_NOLINK
: // Link has been severed
698 case FileBase::E_NOENT
: // No such file or directory
699 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
701 case FileBase::E_ISDIR
: // Is a directory
702 case FileBase::E_ROFS
: // Read-only file system
703 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
705 case FileBase::E_BUSY
: // Device or resource busy
706 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
708 case FileBase::E_FAULT
: // Bad address
709 case FileBase::E_LOOP
: // Too many symbolic links encountered
710 case FileBase::E_IO
: // I/O error
711 case FileBase::E_INTR
: // function call was interrupted
712 case FileBase::E_MULTIHOP
: // Multihop attempted
714 ioErrorCode
= IOErrorCode_GENERAL
;
717 cancelCommandExecution(
719 generateErrorArguments(aUncPath
),
721 "a file or directory could not be deleted",
724 else if( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
725 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
726 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
727 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
||
728 errorCode
== TASKHANDLING_TRANSFER_DESTFILETYPE
||
729 errorCode
== TASKHANDLING_FILETYPE_FOR_REMOVE
||
730 errorCode
== TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE
||
731 errorCode
== TASKHANDLING_TRANSFER_INVALIDURL
)
736 case FileBase::E_NOENT
: // No such file or directory
737 if ( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
738 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
739 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
740 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
)
742 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
743 aMsg
= "source file/folder does not exist";
748 ioErrorCode
= IOErrorCode_GENERAL
;
749 aMsg
= "a general error during transfer command";
753 ioErrorCode
= IOErrorCode_GENERAL
;
754 aMsg
= "a general error during transfer command";
757 cancelCommandExecution(
759 generateErrorArguments(aUncPath
),
764 else if( errorCode
== TASKHANDLING_TRANSFER_ACCESSINGROOT
)
766 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
767 cancelCommandExecution(
769 generateErrorArguments(aUncPath
),
771 "accessing the root during transfer",
774 else if( errorCode
== TASKHANDLING_TRANSFER_INVALIDSCHEME
)
776 aAny
<<= InteractiveBadTransferURLException(
779 cancelCommandExecution( aAny
,xEnv
);
781 else if( errorCode
== TASKHANDLING_OVERWRITE_FOR_MOVE
||
782 errorCode
== TASKHANDLING_OVERWRITE_FOR_COPY
||
783 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_MOVE
||
784 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_COPY
||
785 errorCode
== TASKHANDLING_KEEPERROR_FOR_MOVE
||
786 errorCode
== TASKHANDLING_KEEPERROR_FOR_COPY
||
787 errorCode
== TASKHANDLING_RENAME_FOR_MOVE
||
788 errorCode
== TASKHANDLING_RENAME_FOR_COPY
||
789 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_MOVE
||
790 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_COPY
)
793 "general error during transfer");
797 case FileBase::E_EXIST
:
798 ioErrorCode
= IOErrorCode_ALREADY_EXISTING
;
800 case FileBase::E_INVAL
: // the format of the parameters was not valid
801 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
803 case FileBase::E_NOMEM
: // not enough memory for allocating structures
804 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
806 case FileBase::E_ACCES
: // Permission denied
807 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
809 case FileBase::E_PERM
: // Operation not permitted
810 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
812 case FileBase::E_NAMETOOLONG
: // File name too long
813 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
815 case FileBase::E_NOENT
: // No such file or directory
816 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
817 aMsg
= "file/folder does not exist";
819 case FileBase::E_ROFS
: // Read-only file system<p>
820 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
823 ioErrorCode
= IOErrorCode_GENERAL
;
826 cancelCommandExecution(
828 generateErrorArguments(aUncPath
),
833 else if( errorCode
== TASKHANDLING_NAMECLASH_FOR_COPY
||
834 errorCode
== TASKHANDLING_NAMECLASH_FOR_MOVE
)
836 NameClashException excep
;
837 excep
.Name
= getTitle(aUncPath
);
838 excep
.Classification
= InteractionClassification_ERROR
;
839 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
840 excep
.Message
= "name clash during copy or move";
842 cancelCommandExecution(Any(excep
), xEnv
);
844 else if( errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE
||
845 errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY
)
847 UnsupportedNameClashException excep
;
848 excep
.NameClash
= minorCode
;
849 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
850 excep
.Message
= "name clash value not supported during copy or move";
852 cancelCommandExecution(Any(excep
), xEnv
);
856 // case TASKHANDLER_NO_ERROR:
862 } // end namespace fileaccess
864 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */