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 <o3tl/string_view.hxx>
44 #include <osl/diagnose.h>
45 #include <rtl/uri.hxx>
46 #include <rtl/ustring.hxx>
47 #include <sal/types.h>
49 using namespace ucbhelper
;
51 using namespace ::com::sun::star
;
52 using namespace com::sun::star::task
;
53 using namespace com::sun::star::beans
;
54 using namespace com::sun::star::lang
;
55 using namespace com::sun::star::uno
;
56 using namespace com::sun::star::ucb
;
60 Sequence
< Any
> generateErrorArguments(
61 OUString
const & rPhysicalUrl
)
63 OUString aResourceName
;
64 OUString aResourceType
;
65 bool bRemovable
= false;
66 bool bResourceName
= false;
67 bool bResourceType
= false;
68 bool bRemoveProperty
= false;
70 if (osl::FileBase::getSystemPathFromFileURL(
73 == osl::FileBase::E_None
)
76 // The resource types "folder" (i.e., directory) and
77 // "volume" seem to be
78 // the most interesting when producing meaningful error messages:
79 osl::DirectoryItem aItem
;
80 if (osl::DirectoryItem::get(rPhysicalUrl
, aItem
) ==
81 osl::FileBase::E_None
)
83 osl::FileStatus
aStatus( osl_FileStatus_Mask_Type
);
84 if (aItem
.getFileStatus(aStatus
) == osl::FileBase::E_None
)
85 switch (aStatus
.getFileType())
87 case osl::FileStatus::Directory
:
88 aResourceType
= "folder";
92 case osl::FileStatus::Volume
:
94 aResourceType
= "volume";
96 osl::VolumeInfo
aVolumeInfo(
97 osl_VolumeInfo_Mask_Attributes
);
98 if( osl::Directory::getVolumeInfo(
99 rPhysicalUrl
,aVolumeInfo
) ==
100 osl::FileBase::E_None
)
102 bRemovable
= aVolumeInfo
.getRemoveableFlag();
103 bRemoveProperty
= true;
107 case osl::FileStatus::Regular
:
108 case osl::FileStatus::Fifo
:
109 case osl::FileStatus::Socket
:
110 case osl::FileStatus::Link
:
111 case osl::FileStatus::Special
:
112 case osl::FileStatus::Unknown
:
113 // do nothing for now
118 Sequence
< Any
> aArguments( 1 +
119 (bResourceName
? 1 : 0) +
120 (bResourceType
? 1 : 0) +
121 (bRemoveProperty
? 1 : 0) );
122 auto pArguments
= aArguments
.getArray();
125 <<= PropertyValue("Uri",
128 PropertyState_DIRECT_VALUE
);
131 <<= PropertyValue("ResourceName",
134 PropertyState_DIRECT_VALUE
);
137 <<= PropertyValue("ResourceType",
140 PropertyState_DIRECT_VALUE
);
143 <<= PropertyValue("Removable",
146 PropertyState_DIRECT_VALUE
);
153 namespace fileaccess
{
156 bool isChild( std::u16string_view srcUnqPath
,
157 std::u16string_view dstUnqPath
)
159 static const sal_Unicode slash
= '/';
160 // Simple lexical comparison
161 size_t srcL
= srcUnqPath
.size();
162 size_t dstL
= dstUnqPath
.size();
165 ( srcUnqPath
== dstUnqPath
)
169 o3tl::starts_with(dstUnqPath
, srcUnqPath
)
171 ( dstUnqPath
[ srcL
] == slash
) )
177 std::u16string_view aNewPrefix
,
178 std::u16string_view aOldPrefix
,
179 std::u16string_view old_Name
)
181 size_t srcL
= aOldPrefix
.size();
183 return OUString::Concat(aNewPrefix
) + old_Name
.substr( srcL
);
187 std::u16string_view
getTitle( std::u16string_view aPath
)
189 size_t lastIndex
= aPath
.rfind( '/' );
190 return aPath
.substr( lastIndex
+ 1 );
194 OUString
getParentName( std::u16string_view aFileName
)
196 size_t lastIndex
= aFileName
.rfind( '/' );
197 OUString
aParent( aFileName
.substr( 0,lastIndex
) );
199 if( aParent
.endsWith(":") && aParent
.getLength() == 6 )
202 if ( aParent
== "file://" )
203 aParent
= "file:///";
209 osl::FileBase::RC
osl_File_copy( const OUString
& strPath
,
210 const OUString
& strDestPath
,
215 osl::DirectoryItem aItem
;
216 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
217 return osl::FileBase::E_EXIST
;
220 return osl::File::copy( strPath
,strDestPath
);
224 osl::FileBase::RC
osl_File_move( const OUString
& strPath
,
225 const OUString
& strDestPath
,
230 osl::DirectoryItem aItem
;
231 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
232 return osl::FileBase::E_EXIST
;
235 return osl::File::move( strPath
,strDestPath
);
241 const Reference
< XCommandEnvironment
>& xEnv
,
242 const OUString
& aUncPath
,
243 BaseContent
* pContent
,
246 Reference
<XCommandProcessor
> xComProc(pContent
);
248 IOErrorCode ioErrorCode
;
250 if( errorCode
== TASKHANDLER_UNSUPPORTED_COMMAND
)
252 aAny
<<= UnsupportedCommandException( OSL_LOG_PREFIX
);
253 cancelCommandExecution( aAny
,xEnv
);
255 else if( errorCode
== TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT
||
256 errorCode
== TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT
||
257 errorCode
== TASKHANDLING_WRONG_OPEN_ARGUMENT
||
258 errorCode
== TASKHANDLING_WRONG_DELETE_ARGUMENT
||
259 errorCode
== TASKHANDLING_WRONG_TRANSFER_ARGUMENT
||
260 errorCode
== TASKHANDLING_WRONG_INSERT_ARGUMENT
||
261 errorCode
== TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT
)
263 IllegalArgumentException excep
;
264 excep
.ArgumentPosition
= 0;
265 cancelCommandExecution(Any(excep
), xEnv
);
267 else if( errorCode
== TASKHANDLING_UNSUPPORTED_OPEN_MODE
)
269 UnsupportedOpenModeException excep
;
270 excep
.Mode
= sal::static_int_cast
< sal_Int16
>(minorCode
);
271 cancelCommandExecution( Any(excep
),xEnv
);
273 else if(errorCode
== TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND
||
274 errorCode
== TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND
||
275 errorCode
== TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND
)
280 // error in opening file
281 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE
||
282 // error in opening file
283 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_WRITE
||
284 // error in opening file
285 errorCode
== TASKHANDLING_OPEN_FOR_STREAM
||
286 // error in opening file
287 errorCode
== TASKHANDLING_OPEN_FOR_INPUTSTREAM
||
288 // error in opening file
289 errorCode
== TASKHANDLING_OPEN_FILE_FOR_PAGING
)
293 case FileBase::E_NAMETOOLONG
:
294 // pathname was too long
295 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
297 case FileBase::E_NXIO
:
298 // No such device or address
299 case FileBase::E_NODEV
:
301 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
303 case FileBase::E_NOTDIR
:
304 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
306 case FileBase::E_NOENT
:
307 // No such file or directory
308 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
310 case FileBase::E_ROFS
:
311 // #i4735# handle ROFS transparently as ACCESS_DENIED
312 case FileBase::E_ACCES
:
313 case FileBase::E_PERM
:
314 // permission denied<P>
315 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
317 case FileBase::E_ISDIR
:
319 ioErrorCode
= IOErrorCode_NO_FILE
;
321 case FileBase::E_NOTREADY
:
322 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
324 case FileBase::E_MFILE
:
325 // too many open files used by the process
326 case FileBase::E_NFILE
:
327 // too many open files in the system
328 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
330 case FileBase::E_INVAL
:
331 // the format of the parameters was not valid
332 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
334 case FileBase::E_NOMEM
:
335 // not enough memory for allocating structures
336 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
338 case FileBase::E_BUSY
:
340 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
342 case FileBase::E_AGAIN
:
343 // Operation would block
344 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
346 case FileBase::E_NOLCK
: // No record locks available
347 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
349 case FileBase::E_NOSYS
:
350 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
352 case FileBase::E_FAULT
: // Bad address
353 case FileBase::E_LOOP
: // Too many symbolic links encountered
354 case FileBase::E_NOSPC
: // No space left on device
355 case FileBase::E_INTR
: // function call was interrupted
356 case FileBase::E_IO
: // I/O error
357 case FileBase::E_MULTIHOP
: // Multihop attempted
358 case FileBase::E_NOLINK
: // Link has been severed
360 ioErrorCode
= IOErrorCode_GENERAL
;
364 cancelCommandExecution(
366 generateErrorArguments(aUncPath
),
368 "an error occurred during file opening",
371 else if( errorCode
== TASKHANDLING_OPEN_FOR_DIRECTORYLISTING
||
372 errorCode
== TASKHANDLING_OPENDIRECTORY_FOR_REMOVE
)
376 case FileBase::E_INVAL
:
377 // the format of the parameters was not valid
378 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
380 case FileBase::E_NOENT
:
381 // the specified path doesn't exist
382 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
384 case FileBase::E_NOTDIR
:
385 // the specified path is not a directory
386 ioErrorCode
= IOErrorCode_NO_DIRECTORY
;
388 case FileBase::E_NOMEM
:
389 // not enough memory for allocating structures
390 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
392 case FileBase::E_ROFS
:
393 // #i4735# handle ROFS transparently as ACCESS_DENIED
394 case FileBase::E_ACCES
: // permission denied
395 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
397 case FileBase::E_NOTREADY
:
398 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
400 case FileBase::E_MFILE
:
401 // too many open files used by the process
402 case FileBase::E_NFILE
:
403 // too many open files in the system
404 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
406 case FileBase::E_NAMETOOLONG
:
407 // File name too long
408 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
410 case FileBase::E_LOOP
:
411 // Too many symbolic links encountered<p>
413 ioErrorCode
= IOErrorCode_GENERAL
;
417 cancelCommandExecution(
419 generateErrorArguments(aUncPath
),
421 "an error occurred during opening a directory",
424 else if( errorCode
== TASKHANDLING_NOTCONNECTED_FOR_WRITE
||
425 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE
||
426 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_WRITE
||
427 errorCode
== TASKHANDLING_NOTCONNECTED_FOR_PAGING
||
428 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING
||
429 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_PAGING
)
431 ioErrorCode
= IOErrorCode_UNKNOWN
;
432 cancelCommandExecution(
434 generateErrorArguments(aUncPath
),
436 "an error occurred writing or reading from a file",
439 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_NO_SPACE
)
441 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
442 cancelCommandExecution(
444 generateErrorArguments(aUncPath
),
449 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_WRITE
||
450 errorCode
== TASKHANDLING_READING_FILE_FOR_PAGING
)
454 case FileBase::E_INVAL
:
455 // the format of the parameters was not valid
456 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
458 case FileBase::E_FBIG
:
460 ioErrorCode
= IOErrorCode_CANT_WRITE
;
462 case FileBase::E_NOSPC
:
463 // No space left on device
464 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
466 case FileBase::E_NXIO
:
467 // No such device or address
468 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
470 case FileBase::E_NOLINK
:
471 // Link has been severed
472 case FileBase::E_ISDIR
:
474 ioErrorCode
= IOErrorCode_NO_FILE
;
476 case FileBase::E_AGAIN
:
477 // Operation would block
478 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
480 case FileBase::E_TIMEDOUT
:
481 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
483 case FileBase::E_NOLCK
: // No record locks available
484 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
486 case FileBase::E_IO
: // I/O error
487 case FileBase::E_BADF
: // Bad file
488 case FileBase::E_FAULT
: // Bad address
489 case FileBase::E_INTR
: // function call was interrupted
491 ioErrorCode
= IOErrorCode_GENERAL
;
494 cancelCommandExecution(
496 generateErrorArguments(aUncPath
),
498 "an error occurred during opening a file",
501 else if( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
||
502 errorCode
== TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND
)
504 static constexpr OUStringLiteral sTitle
= u
"Title";
505 static constexpr OUStringLiteral sContentType
= u
"ContentType";
506 Sequence
< OUString
> aSeq
{ (errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
)
508 : OUString(sContentType
) };
510 aAny
<<= MissingPropertiesException(
511 "a property is missing, necessary to create a content",
514 cancelCommandExecution(aAny
,xEnv
);
516 else if( errorCode
== TASKHANDLING_FILESIZE_FOR_WRITE
)
520 case FileBase::E_INVAL
:
521 // the format of the parameters was not valid
522 case FileBase::E_OVERFLOW
:
523 // The resulting file offset would be a value which cannot
524 // be represented correctly for regular files
525 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
528 ioErrorCode
= IOErrorCode_GENERAL
;
531 cancelCommandExecution(
533 generateErrorArguments(aUncPath
),
535 "there were problems with the filesize",
538 else if(errorCode
== TASKHANDLING_INPUTSTREAM_FOR_WRITE
)
541 MissingInputStreamException(
542 "the inputstream is missing, necessary to create a content",
544 cancelCommandExecution(aAny
,xEnv
);
546 else if( errorCode
== TASKHANDLING_NOREPLACE_FOR_WRITE
)
547 // Overwrite = false and file exists
549 NameClashException excep
;
550 excep
.Name
= getTitle(aUncPath
);
551 excep
.Classification
= InteractionClassification_ERROR
;
552 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
553 excep
.Message
= "file exists and overwrite forbidden";
554 cancelCommandExecution( Any(excep
), xEnv
);
556 else if( errorCode
== TASKHANDLING_INVALID_NAME_MKDIR
)
558 InteractiveAugmentedIOException excep
;
559 excep
.Code
= IOErrorCode_INVALID_CHARACTER
;
561 prop
.Name
= "ResourceName";
563 OUString
aClashingName(
565 OUString(getTitle(aUncPath
)),
566 rtl_UriDecodeWithCharset
,
567 RTL_TEXTENCODING_UTF8
));
568 prop
.Value
<<= aClashingName
;
569 excep
.Arguments
= { Any(prop
) };
570 excep
.Classification
= InteractionClassification_ERROR
;
571 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
572 excep
.Message
= "the name contained invalid characters";
575 cancelCommandExecution( Any(excep
), xEnv
);
576 // ioErrorCode = IOErrorCode_INVALID_CHARACTER;
577 // cancelCommandExecution(
579 // generateErrorArguments(aUncPath),
581 // OUString( "the name contained invalid characters"),
584 else if( errorCode
== TASKHANDLING_FOLDER_EXISTS_MKDIR
)
586 NameClashException excep
;
587 excep
.Name
= getTitle(aUncPath
);
588 excep
.Classification
= InteractionClassification_ERROR
;
589 excep
.Context
= xComProc
;
590 excep
.Message
= "folder exists and overwrite forbidden";
593 cancelCommandExecution( Any(excep
), xEnv
);
594 // ioErrorCode = IOErrorCode_ALREADY_EXISTING;
595 // cancelCommandExecution(
597 // generateErrorArguments(aUncPath),
599 // OUString( "the folder exists"),
602 else if( errorCode
== TASKHANDLING_ENSUREDIR_FOR_WRITE
||
603 errorCode
== TASKHANDLING_CREATEDIRECTORY_MKDIR
)
607 case FileBase::E_ACCES
:
608 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
610 case FileBase::E_ROFS
:
611 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
613 case FileBase::E_NAMETOOLONG
:
614 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
617 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
620 cancelCommandExecution(
622 generateErrorArguments(getParentName(aUncPath
)),
623 //TODO! ok to supply physical URL to getParentName()?
625 "a folder could not be created",
628 else if( errorCode
== TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE
||
629 errorCode
== TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE
||
630 errorCode
== TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE
)
634 case FileBase::E_INVAL
: // the format of the parameters was not valid
635 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
637 case FileBase::E_NOMEM
: // not enough memory for allocating structures
638 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
640 case FileBase::E_ROFS
: // #i4735# handle ROFS transparently as ACCESS_DENIED
641 case FileBase::E_ACCES
: // permission denied
642 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
644 case FileBase::E_MFILE
: // too many open files used by the process
645 case FileBase::E_NFILE
: // too many open files in the system
646 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
648 case FileBase::E_NOLINK
: // Link has been severed
649 case FileBase::E_NOENT
: // No such file or directory
650 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
652 case FileBase::E_NAMETOOLONG
: // File name too long
653 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
655 case FileBase::E_NOTDIR
: // A component of the path prefix of path is not a directory
656 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
658 case FileBase::E_LOOP
: // Too many symbolic links encountered
659 case FileBase::E_IO
: // I/O error
660 case FileBase::E_MULTIHOP
: // Multihop attempted
661 case FileBase::E_FAULT
: // Bad address
662 case FileBase::E_INTR
: // function call was interrupted
663 case FileBase::E_NOSYS
: // Function not implemented
664 case FileBase::E_NOSPC
: // No space left on device
665 case FileBase::E_NXIO
: // No such device or address
666 case FileBase::E_OVERFLOW
: // Value too large for defined data type
667 case FileBase::E_BADF
: // Invalid oslDirectoryItem parameter
669 ioErrorCode
= IOErrorCode_GENERAL
;
672 cancelCommandExecution(
674 generateErrorArguments(aUncPath
),
676 "a file status object could not be filled",
679 else if( errorCode
== TASKHANDLING_DELETEFILE_FOR_REMOVE
||
680 errorCode
== TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE
)
684 case FileBase::E_INVAL
: // the format of the parameters was not valid
685 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
687 case FileBase::E_NOMEM
: // not enough memory for allocating structures
688 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
690 case FileBase::E_ACCES
: // Permission denied
691 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
693 case FileBase::E_PERM
: // Operation not permitted
694 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
696 case FileBase::E_NAMETOOLONG
: // File name too long
697 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
699 case FileBase::E_NOLINK
: // Link has been severed
700 case FileBase::E_NOENT
: // No such file or directory
701 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
703 case FileBase::E_ISDIR
: // Is a directory
704 case FileBase::E_ROFS
: // Read-only file system
705 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
707 case FileBase::E_BUSY
: // Device or resource busy
708 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
710 case FileBase::E_FAULT
: // Bad address
711 case FileBase::E_LOOP
: // Too many symbolic links encountered
712 case FileBase::E_IO
: // I/O error
713 case FileBase::E_INTR
: // function call was interrupted
714 case FileBase::E_MULTIHOP
: // Multihop attempted
716 ioErrorCode
= IOErrorCode_GENERAL
;
719 cancelCommandExecution(
721 generateErrorArguments(aUncPath
),
723 "a file or directory could not be deleted",
726 else if( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
727 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
728 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
729 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
||
730 errorCode
== TASKHANDLING_TRANSFER_DESTFILETYPE
||
731 errorCode
== TASKHANDLING_FILETYPE_FOR_REMOVE
||
732 errorCode
== TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE
||
733 errorCode
== TASKHANDLING_TRANSFER_INVALIDURL
)
738 case FileBase::E_NOENT
: // No such file or directory
739 if ( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
740 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
741 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
742 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
)
744 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
745 aMsg
= "source file/folder does not exist";
750 ioErrorCode
= IOErrorCode_GENERAL
;
751 aMsg
= "a general error during transfer command";
755 ioErrorCode
= IOErrorCode_GENERAL
;
756 aMsg
= "a general error during transfer command";
759 cancelCommandExecution(
761 generateErrorArguments(aUncPath
),
766 else if( errorCode
== TASKHANDLING_TRANSFER_ACCESSINGROOT
)
768 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
769 cancelCommandExecution(
771 generateErrorArguments(aUncPath
),
773 "accessing the root during transfer",
776 else if( errorCode
== TASKHANDLING_TRANSFER_INVALIDSCHEME
)
778 aAny
<<= InteractiveBadTransferURLException(
781 cancelCommandExecution( aAny
,xEnv
);
783 else if( errorCode
== TASKHANDLING_OVERWRITE_FOR_MOVE
||
784 errorCode
== TASKHANDLING_OVERWRITE_FOR_COPY
||
785 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_MOVE
||
786 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_COPY
||
787 errorCode
== TASKHANDLING_KEEPERROR_FOR_MOVE
||
788 errorCode
== TASKHANDLING_KEEPERROR_FOR_COPY
||
789 errorCode
== TASKHANDLING_RENAME_FOR_MOVE
||
790 errorCode
== TASKHANDLING_RENAME_FOR_COPY
||
791 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_MOVE
||
792 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_COPY
)
795 "general error during transfer");
799 case FileBase::E_EXIST
:
800 ioErrorCode
= IOErrorCode_ALREADY_EXISTING
;
802 case FileBase::E_INVAL
: // the format of the parameters was not valid
803 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
805 case FileBase::E_NOMEM
: // not enough memory for allocating structures
806 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
808 case FileBase::E_ACCES
: // Permission denied
809 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
811 case FileBase::E_PERM
: // Operation not permitted
812 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
814 case FileBase::E_NAMETOOLONG
: // File name too long
815 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
817 case FileBase::E_NOENT
: // No such file or directory
818 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
819 aMsg
= "file/folder does not exist";
821 case FileBase::E_ROFS
: // Read-only file system<p>
822 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
825 ioErrorCode
= IOErrorCode_GENERAL
;
828 cancelCommandExecution(
830 generateErrorArguments(aUncPath
),
835 else if( errorCode
== TASKHANDLING_NAMECLASH_FOR_COPY
||
836 errorCode
== TASKHANDLING_NAMECLASH_FOR_MOVE
)
838 NameClashException excep
;
839 excep
.Name
= getTitle(aUncPath
);
840 excep
.Classification
= InteractionClassification_ERROR
;
841 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
842 excep
.Message
= "name clash during copy or move";
844 cancelCommandExecution(Any(excep
), xEnv
);
846 else if( errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE
||
847 errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY
)
849 UnsupportedNameClashException excep
;
850 excep
.NameClash
= minorCode
;
851 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
852 excep
.Message
= "name clash value not supported during copy or move";
854 cancelCommandExecution(Any(excep
), xEnv
);
858 // case TASKHANDLER_NO_ERROR:
864 } // end namespace fileaccess
866 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */