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 <o3tl/underlyingenumvalue.hxx>
45 #include <osl/diagnose.h>
46 #include <rtl/uri.hxx>
47 #include <rtl/ustring.hxx>
48 #include <sal/types.h>
50 using namespace ucbhelper
;
52 using namespace ::com::sun::star
;
53 using namespace com::sun::star::task
;
54 using namespace com::sun::star::beans
;
55 using namespace com::sun::star::lang
;
56 using namespace com::sun::star::uno
;
57 using namespace com::sun::star::ucb
;
61 Sequence
< Any
> generateErrorArguments(
62 OUString
const & rPhysicalUrl
)
64 OUString aResourceName
;
65 OUString aResourceType
;
66 bool bRemovable
= false;
67 bool bResourceName
= false;
68 bool bResourceType
= false;
69 bool bRemoveProperty
= false;
71 if (osl::FileBase::getSystemPathFromFileURL(
74 == osl::FileBase::E_None
)
77 // The resource types "folder" (i.e., directory) and
78 // "volume" seem to be
79 // the most interesting when producing meaningful error messages:
80 osl::DirectoryItem aItem
;
81 if (osl::DirectoryItem::get(rPhysicalUrl
, aItem
) ==
82 osl::FileBase::E_None
)
84 osl::FileStatus
aStatus( osl_FileStatus_Mask_Type
);
85 if (aItem
.getFileStatus(aStatus
) == osl::FileBase::E_None
)
86 switch (aStatus
.getFileType())
88 case osl::FileStatus::Directory
:
89 aResourceType
= "folder";
93 case osl::FileStatus::Volume
:
95 aResourceType
= "volume";
97 osl::VolumeInfo
aVolumeInfo(
98 osl_VolumeInfo_Mask_Attributes
);
99 if( osl::Directory::getVolumeInfo(
100 rPhysicalUrl
,aVolumeInfo
) ==
101 osl::FileBase::E_None
)
103 bRemovable
= aVolumeInfo
.getRemoveableFlag();
104 bRemoveProperty
= true;
108 case osl::FileStatus::Regular
:
109 case osl::FileStatus::Fifo
:
110 case osl::FileStatus::Socket
:
111 case osl::FileStatus::Link
:
112 case osl::FileStatus::Special
:
113 case osl::FileStatus::Unknown
:
114 // do nothing for now
119 Sequence
< Any
> aArguments( 1 +
120 (bResourceName
? 1 : 0) +
121 (bResourceType
? 1 : 0) +
122 (bRemoveProperty
? 1 : 0) );
123 auto pArguments
= aArguments
.getArray();
126 <<= PropertyValue(u
"Uri"_ustr
,
129 PropertyState_DIRECT_VALUE
);
132 <<= PropertyValue(u
"ResourceName"_ustr
,
135 PropertyState_DIRECT_VALUE
);
138 <<= PropertyValue(u
"ResourceType"_ustr
,
141 PropertyState_DIRECT_VALUE
);
144 <<= PropertyValue(u
"Removable"_ustr
,
147 PropertyState_DIRECT_VALUE
);
154 namespace fileaccess
{
157 bool isChild( std::u16string_view srcUnqPath
,
158 std::u16string_view dstUnqPath
)
160 static const sal_Unicode slash
= '/';
161 // Simple lexical comparison
162 size_t srcL
= srcUnqPath
.size();
163 size_t dstL
= dstUnqPath
.size();
166 ( srcUnqPath
== dstUnqPath
)
170 o3tl::starts_with(dstUnqPath
, srcUnqPath
)
172 ( dstUnqPath
[ srcL
] == slash
) )
178 std::u16string_view aNewPrefix
,
179 std::u16string_view aOldPrefix
,
180 std::u16string_view old_Name
)
182 size_t srcL
= aOldPrefix
.size();
184 return OUString::Concat(aNewPrefix
) + old_Name
.substr( srcL
);
188 std::u16string_view
getTitle( std::u16string_view aPath
)
190 size_t lastIndex
= aPath
.rfind( '/' );
191 return aPath
.substr((lastIndex
!= std::u16string_view::npos
) ? lastIndex
+ 1 : 0);
195 OUString
getParentName( std::u16string_view aFileName
)
197 size_t lastIndex
= aFileName
.rfind( '/' );
198 OUString
aParent( aFileName
.substr( 0,lastIndex
) );
200 if( aParent
.endsWith(":") && aParent
.getLength() == 6 )
203 if ( aParent
== "file://" )
204 aParent
= "file:///";
210 osl::FileBase::RC
osl_File_copy( const OUString
& strPath
,
211 const OUString
& strDestPath
,
216 osl::DirectoryItem aItem
;
217 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
218 return osl::FileBase::E_EXIST
;
221 return osl::File::copy( strPath
,strDestPath
);
225 osl::FileBase::RC
osl_File_move( const OUString
& strPath
,
226 const OUString
& strDestPath
,
231 osl::DirectoryItem aItem
;
232 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
233 return osl::FileBase::E_EXIST
;
236 return osl::File::move( strPath
,strDestPath
);
240 TaskHandlerErr errorCode
,
242 const Reference
< XCommandEnvironment
>& xEnv
,
243 const OUString
& aUncPath
,
244 BaseContent
* pContent
,
247 Reference
<XCommandProcessor
> xComProc(pContent
);
249 IOErrorCode ioErrorCode
;
251 if( errorCode
== TaskHandlerErr::UNSUPPORTED_COMMAND
)
253 aAny
<<= UnsupportedCommandException( OSL_LOG_PREFIX
);
254 cancelCommandExecution( aAny
,xEnv
);
256 else if( errorCode
== TaskHandlerErr::WRONG_SETPROPERTYVALUES_ARGUMENT
||
257 errorCode
== TaskHandlerErr::WRONG_GETPROPERTYVALUES_ARGUMENT
||
258 errorCode
== TaskHandlerErr::WRONG_OPEN_ARGUMENT
||
259 errorCode
== TaskHandlerErr::WRONG_DELETE_ARGUMENT
||
260 errorCode
== TaskHandlerErr::WRONG_TRANSFER_ARGUMENT
||
261 errorCode
== TaskHandlerErr::WRONG_INSERT_ARGUMENT
||
262 errorCode
== TaskHandlerErr::WRONG_CREATENEWCONTENT_ARGUMENT
)
264 IllegalArgumentException excep
;
265 excep
.ArgumentPosition
= 0;
266 cancelCommandExecution(Any(excep
), xEnv
);
268 else if( errorCode
== TaskHandlerErr::UNSUPPORTED_OPEN_MODE
)
270 UnsupportedOpenModeException excep
;
271 excep
.Mode
= sal::static_int_cast
< sal_Int16
>(minorCode
);
272 cancelCommandExecution( Any(excep
),xEnv
);
274 else if(errorCode
== TaskHandlerErr::DELETED_STATE_IN_OPEN_COMMAND
||
275 errorCode
== TaskHandlerErr::INSERTED_STATE_IN_OPEN_COMMAND
||
276 errorCode
== TaskHandlerErr::NOFRESHINSERT_IN_INSERT_COMMAND
)
281 // error in opening file
282 errorCode
== TaskHandlerErr::NO_OPEN_FILE_FOR_OVERWRITE
||
283 // error in opening file
284 errorCode
== TaskHandlerErr::NO_OPEN_FILE_FOR_WRITE
||
285 // error in opening file
286 errorCode
== TaskHandlerErr::OPEN_FOR_STREAM
||
287 // error in opening file
288 errorCode
== TaskHandlerErr::OPEN_FOR_INPUTSTREAM
||
289 // error in opening file
290 errorCode
== TaskHandlerErr::OPEN_FILE_FOR_PAGING
)
294 case FileBase::E_NAMETOOLONG
:
295 // pathname was too long
296 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
298 case FileBase::E_NXIO
:
299 // No such device or address
300 case FileBase::E_NODEV
:
302 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
304 case FileBase::E_NOTDIR
:
305 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
307 case FileBase::E_NOENT
:
308 // No such file or directory
309 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
311 case FileBase::E_ROFS
:
312 // #i4735# handle ROFS transparently as ACCESS_DENIED
313 case FileBase::E_ACCES
:
314 case FileBase::E_PERM
:
315 // permission denied<P>
316 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
318 case FileBase::E_ISDIR
:
320 ioErrorCode
= IOErrorCode_NO_FILE
;
322 case FileBase::E_NOTREADY
:
323 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
325 case FileBase::E_MFILE
:
326 // too many open files used by the process
327 case FileBase::E_NFILE
:
328 // too many open files in the system
329 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
331 case FileBase::E_INVAL
:
332 // the format of the parameters was not valid
333 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
335 case FileBase::E_NOMEM
:
336 // not enough memory for allocating structures
337 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
339 case FileBase::E_BUSY
: // Text file busy
340 case FileBase::E_AGAIN
: // Operation would block
341 case FileBase::E_NOLCK
: // No record locks available
342 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
344 case FileBase::E_NOSYS
:
345 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
347 case FileBase::E_FAULT
: // Bad address
348 case FileBase::E_LOOP
: // Too many symbolic links encountered
349 case FileBase::E_NOSPC
: // No space left on device
350 case FileBase::E_INTR
: // function call was interrupted
351 case FileBase::E_IO
: // I/O error
352 case FileBase::E_MULTIHOP
: // Multihop attempted
353 case FileBase::E_NOLINK
: // Link has been severed
355 ioErrorCode
= IOErrorCode_GENERAL
;
359 cancelCommandExecution(
361 generateErrorArguments(aUncPath
),
363 "an error occurred during file opening ("
364 + OUString::number(o3tl::to_underlying(errorCode
)) + "/"
365 + OUString::number(minorCode
) + ")",
368 else if( errorCode
== TaskHandlerErr::OPEN_FOR_DIRECTORYLISTING
||
369 errorCode
== TaskHandlerErr::OPENDIRECTORY_FOR_REMOVE
)
373 case FileBase::E_INVAL
:
374 // the format of the parameters was not valid
375 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
377 case FileBase::E_NOENT
:
378 // the specified path doesn't exist
379 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
381 case FileBase::E_NOTDIR
:
382 // the specified path is not a directory
383 ioErrorCode
= IOErrorCode_NO_DIRECTORY
;
385 case FileBase::E_NOMEM
:
386 // not enough memory for allocating structures
387 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
389 case FileBase::E_ROFS
:
390 // #i4735# handle ROFS transparently as ACCESS_DENIED
391 case FileBase::E_ACCES
: // permission denied
392 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
394 case FileBase::E_NOTREADY
:
395 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
397 case FileBase::E_MFILE
:
398 // too many open files used by the process
399 case FileBase::E_NFILE
:
400 // too many open files in the system
401 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
403 case FileBase::E_NAMETOOLONG
:
404 // File name too long
405 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
407 case FileBase::E_LOOP
:
408 // Too many symbolic links encountered<p>
410 ioErrorCode
= IOErrorCode_GENERAL
;
414 cancelCommandExecution(
416 generateErrorArguments(aUncPath
),
418 u
"an error occurred during opening a directory"_ustr
,
421 else if( errorCode
== TaskHandlerErr::NOTCONNECTED_FOR_WRITE
||
422 errorCode
== TaskHandlerErr::BUFFERSIZEEXCEEDED_FOR_WRITE
||
423 errorCode
== TaskHandlerErr::IOEXCEPTION_FOR_WRITE
||
424 errorCode
== TaskHandlerErr::NOTCONNECTED_FOR_PAGING
||
425 errorCode
== TaskHandlerErr::BUFFERSIZEEXCEEDED_FOR_PAGING
||
426 errorCode
== TaskHandlerErr::IOEXCEPTION_FOR_PAGING
)
428 ioErrorCode
= IOErrorCode_UNKNOWN
;
429 cancelCommandExecution(
431 generateErrorArguments(aUncPath
),
433 u
"an error occurred writing or reading from a file"_ustr
,
436 else if( errorCode
== TaskHandlerErr::FILEIOERROR_FOR_NO_SPACE
)
438 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
439 cancelCommandExecution(
441 generateErrorArguments(aUncPath
),
446 else if( errorCode
== TaskHandlerErr::FILEIOERROR_FOR_WRITE
||
447 errorCode
== TaskHandlerErr::READING_FILE_FOR_PAGING
)
451 case FileBase::E_INVAL
:
452 // the format of the parameters was not valid
453 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
455 case FileBase::E_FBIG
:
457 ioErrorCode
= IOErrorCode_CANT_WRITE
;
459 case FileBase::E_NOSPC
:
460 // No space left on device
461 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
463 case FileBase::E_NXIO
:
464 // No such device or address
465 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
467 case FileBase::E_NOLINK
:
468 // Link has been severed
469 case FileBase::E_ISDIR
:
471 ioErrorCode
= IOErrorCode_NO_FILE
;
473 case FileBase::E_AGAIN
: // Operation would block
474 case FileBase::E_NOLCK
: // No record locks available
475 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
477 case FileBase::E_TIMEDOUT
:
478 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
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 u
"an error occurred during opening a file"_ustr
,
495 else if( errorCode
== TaskHandlerErr::NONAMESET_INSERT_COMMAND
||
496 errorCode
== TaskHandlerErr::NOCONTENTTYPE_INSERT_COMMAND
)
498 static constexpr OUString sTitle
= u
"Title"_ustr
;
499 static constexpr OUString sContentType
= u
"ContentType"_ustr
;
500 Sequence
< OUString
> aSeq
{ (errorCode
== TaskHandlerErr::NONAMESET_INSERT_COMMAND
)
504 aAny
<<= MissingPropertiesException(
505 u
"a property is missing, necessary to create a content"_ustr
,
508 cancelCommandExecution(aAny
,xEnv
);
510 else if( errorCode
== TaskHandlerErr::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 u
"there were problems with the filesize"_ustr
,
532 else if(errorCode
== TaskHandlerErr::INPUTSTREAM_FOR_WRITE
)
535 MissingInputStreamException(
536 u
"the inputstream is missing, necessary to create a content"_ustr
,
538 cancelCommandExecution(aAny
,xEnv
);
540 else if( errorCode
== TaskHandlerErr::NOREPLACE_FOR_WRITE
)
541 // Overwrite = false and file exists
543 NameClashException
excep(u
"file exists and overwrite forbidden"_ustr
,
544 Reference
<XInterface
>(xComProc
, UNO_QUERY
),
545 InteractionClassification_ERROR
, OUString(getTitle(aUncPath
)));
546 cancelCommandExecution( Any(excep
), xEnv
);
548 else if( errorCode
== TaskHandlerErr::INVALID_NAME_MKDIR
)
551 prop
.Name
= "ResourceName";
553 OUString
aClashingName(
555 OUString(getTitle(aUncPath
)),
556 rtl_UriDecodeWithCharset
,
557 RTL_TEXTENCODING_UTF8
));
558 prop
.Value
<<= aClashingName
;
559 InteractiveAugmentedIOException
excep(
560 u
"the name contained invalid characters"_ustr
, Reference
<XInterface
>(xComProc
, UNO_QUERY
),
561 InteractionClassification_ERROR
, IOErrorCode_INVALID_CHARACTER
, { Any(prop
) });
564 cancelCommandExecution( Any(excep
), xEnv
);
565 // ioErrorCode = IOErrorCode_INVALID_CHARACTER;
566 // cancelCommandExecution(
568 // generateErrorArguments(aUncPath),
570 // OUString( "the name contained invalid characters"),
573 else if( errorCode
== TaskHandlerErr::FOLDER_EXISTS_MKDIR
)
575 NameClashException
excep(u
"folder exists and overwrite forbidden"_ustr
, xComProc
,
576 InteractionClassification_ERROR
, OUString(getTitle(aUncPath
)));
579 cancelCommandExecution( Any(excep
), xEnv
);
580 // ioErrorCode = IOErrorCode_ALREADY_EXISTING;
581 // cancelCommandExecution(
583 // generateErrorArguments(aUncPath),
585 // OUString( "the folder exists"),
588 else if( errorCode
== TaskHandlerErr::ENSUREDIR_FOR_WRITE
||
589 errorCode
== TaskHandlerErr::CREATEDIRECTORY_MKDIR
)
593 case FileBase::E_ACCES
:
594 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
596 case FileBase::E_ROFS
:
597 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
599 case FileBase::E_NAMETOOLONG
:
600 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
603 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
606 cancelCommandExecution(
608 generateErrorArguments(getParentName(aUncPath
)),
609 //TODO! ok to supply physical URL to getParentName()?
611 u
"a folder could not be created"_ustr
,
614 else if( errorCode
== TaskHandlerErr::VALIDFILESTATUSWHILE_FOR_REMOVE
||
615 errorCode
== TaskHandlerErr::VALIDFILESTATUS_FOR_REMOVE
||
616 errorCode
== TaskHandlerErr::NOSUCHFILEORDIR_FOR_REMOVE
)
620 case FileBase::E_INVAL
: // the format of the parameters was not valid
621 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
623 case FileBase::E_NOMEM
: // not enough memory for allocating structures
624 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
626 case FileBase::E_ROFS
: // #i4735# handle ROFS transparently as ACCESS_DENIED
627 case FileBase::E_ACCES
: // permission denied
628 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
630 case FileBase::E_MFILE
: // too many open files used by the process
631 case FileBase::E_NFILE
: // too many open files in the system
632 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
634 case FileBase::E_NOLINK
: // Link has been severed
635 case FileBase::E_NOENT
: // No such file or directory
636 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
638 case FileBase::E_NAMETOOLONG
: // File name too long
639 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
641 case FileBase::E_NOTDIR
: // A component of the path prefix of path is not a directory
642 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
644 case FileBase::E_LOOP
: // Too many symbolic links encountered
645 case FileBase::E_IO
: // I/O error
646 case FileBase::E_MULTIHOP
: // Multihop attempted
647 case FileBase::E_FAULT
: // Bad address
648 case FileBase::E_INTR
: // function call was interrupted
649 case FileBase::E_NOSYS
: // Function not implemented
650 case FileBase::E_NOSPC
: // No space left on device
651 case FileBase::E_NXIO
: // No such device or address
652 case FileBase::E_OVERFLOW
: // Value too large for defined data type
653 case FileBase::E_BADF
: // Invalid oslDirectoryItem parameter
655 ioErrorCode
= IOErrorCode_GENERAL
;
658 cancelCommandExecution(
660 generateErrorArguments(aUncPath
),
662 u
"a file status object could not be filled"_ustr
,
665 else if( errorCode
== TaskHandlerErr::DELETEFILE_FOR_REMOVE
||
666 errorCode
== TaskHandlerErr::DELETEDIRECTORY_FOR_REMOVE
)
670 case FileBase::E_INVAL
: // the format of the parameters was not valid
671 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
673 case FileBase::E_NOMEM
: // not enough memory for allocating structures
674 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
676 case FileBase::E_ACCES
: // Permission denied
677 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
679 case FileBase::E_PERM
: // Operation not permitted
680 case FileBase::E_ISDIR
: // Is a directory
681 case FileBase::E_ROFS
: // Read-only file system
682 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
684 case FileBase::E_NAMETOOLONG
: // File name too long
685 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
687 case FileBase::E_NOLINK
: // Link has been severed
688 case FileBase::E_NOENT
: // No such file or directory
689 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
691 case FileBase::E_BUSY
: // Device or resource busy
692 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
694 case FileBase::E_FAULT
: // Bad address
695 case FileBase::E_LOOP
: // Too many symbolic links encountered
696 case FileBase::E_IO
: // I/O error
697 case FileBase::E_INTR
: // function call was interrupted
698 case FileBase::E_MULTIHOP
: // Multihop attempted
700 ioErrorCode
= IOErrorCode_GENERAL
;
703 cancelCommandExecution(
705 generateErrorArguments(aUncPath
),
707 u
"a file or directory could not be deleted"_ustr
,
710 else if( errorCode
== TaskHandlerErr::TRANSFER_BY_COPY_SOURCE
||
711 errorCode
== TaskHandlerErr::TRANSFER_BY_COPY_SOURCESTAT
||
712 errorCode
== TaskHandlerErr::TRANSFER_BY_MOVE_SOURCE
||
713 errorCode
== TaskHandlerErr::TRANSFER_BY_MOVE_SOURCESTAT
||
714 errorCode
== TaskHandlerErr::TRANSFER_DESTFILETYPE
||
715 errorCode
== TaskHandlerErr::FILETYPE_FOR_REMOVE
||
716 errorCode
== TaskHandlerErr::DIRECTORYEXHAUSTED_FOR_REMOVE
||
717 errorCode
== TaskHandlerErr::TRANSFER_INVALIDURL
)
722 case FileBase::E_NOENT
: // No such file or directory
723 if ( errorCode
== TaskHandlerErr::TRANSFER_BY_COPY_SOURCE
||
724 errorCode
== TaskHandlerErr::TRANSFER_BY_COPY_SOURCESTAT
||
725 errorCode
== TaskHandlerErr::TRANSFER_BY_MOVE_SOURCE
||
726 errorCode
== TaskHandlerErr::TRANSFER_BY_MOVE_SOURCESTAT
)
728 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
729 aMsg
= "source file/folder does not exist";
734 ioErrorCode
= IOErrorCode_GENERAL
;
735 aMsg
= "a general error during transfer command";
739 ioErrorCode
= IOErrorCode_GENERAL
;
740 aMsg
= "a general error during transfer command";
743 cancelCommandExecution(
745 generateErrorArguments(aUncPath
),
750 else if( errorCode
== TaskHandlerErr::TRANSFER_INVALIDSCHEME
)
752 aAny
<<= InteractiveBadTransferURLException(
753 u
"bad transfer url"_ustr
,
755 cancelCommandExecution( aAny
,xEnv
);
757 else if( errorCode
== TaskHandlerErr::OVERWRITE_FOR_MOVE
||
758 errorCode
== TaskHandlerErr::OVERWRITE_FOR_COPY
||
759 errorCode
== TaskHandlerErr::NAMECLASHMOVE_FOR_MOVE
||
760 errorCode
== TaskHandlerErr::NAMECLASHMOVE_FOR_COPY
||
761 errorCode
== TaskHandlerErr::KEEPERROR_FOR_MOVE
||
762 errorCode
== TaskHandlerErr::KEEPERROR_FOR_COPY
||
763 errorCode
== TaskHandlerErr::RENAME_FOR_MOVE
||
764 errorCode
== TaskHandlerErr::RENAME_FOR_COPY
||
765 errorCode
== TaskHandlerErr::RENAMEMOVE_FOR_MOVE
||
766 errorCode
== TaskHandlerErr::RENAMEMOVE_FOR_COPY
)
769 u
"general error during transfer"_ustr
);
773 case FileBase::E_EXIST
:
774 ioErrorCode
= IOErrorCode_ALREADY_EXISTING
;
776 case FileBase::E_INVAL
: // the format of the parameters was not valid
777 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
779 case FileBase::E_NOMEM
: // not enough memory for allocating structures
780 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
782 case FileBase::E_ACCES
: // Permission denied
783 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
785 case FileBase::E_PERM
: // Operation not permitted
786 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
788 case FileBase::E_NAMETOOLONG
: // File name too long
789 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
791 case FileBase::E_NOENT
: // No such file or directory
792 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
793 aMsg
= "file/folder does not exist";
795 case FileBase::E_ROFS
: // Read-only file system<p>
796 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
799 ioErrorCode
= IOErrorCode_GENERAL
;
802 cancelCommandExecution(
804 generateErrorArguments(aUncPath
),
809 else if( errorCode
== TaskHandlerErr::NAMECLASH_FOR_COPY
||
810 errorCode
== TaskHandlerErr::NAMECLASH_FOR_MOVE
)
812 NameClashException
excep(u
"name clash during copy or move"_ustr
,
813 Reference
<XInterface
>(xComProc
, UNO_QUERY
),
814 InteractionClassification_ERROR
, OUString(getTitle(aUncPath
)));
816 cancelCommandExecution(Any(excep
), xEnv
);
818 else if( errorCode
== TaskHandlerErr::NAMECLASHSUPPORT_FOR_MOVE
||
819 errorCode
== TaskHandlerErr::NAMECLASHSUPPORT_FOR_COPY
)
821 UnsupportedNameClashException
excep(
822 u
"name clash value not supported during copy or move"_ustr
,
823 Reference
<XInterface
>(xComProc
, UNO_QUERY
), minorCode
);
825 cancelCommandExecution(Any(excep
), xEnv
);
829 // case TaskHandlerErr::NO_ERROR:
835 } // end namespace fileaccess
837 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */