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"
24 #include <osl/file.hxx>
26 #include <ucbhelper/cancelcommandexecution.hxx>
27 #include <com/sun/star/ucb/CommandAbortedException.hpp>
28 #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
29 #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
30 #include <com/sun/star/lang/IllegalArgumentException.hpp>
31 #include <com/sun/star/ucb/IOErrorCode.hpp>
32 #include <com/sun/star/ucb/MissingPropertiesException.hpp>
33 #include <com/sun/star/ucb/MissingInputStreamException.hpp>
34 #include <com/sun/star/ucb/NameClashException.hpp>
35 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
36 #include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
37 #include "com/sun/star/beans/PropertyState.hpp"
38 #include "com/sun/star/beans/PropertyValue.hpp"
39 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
40 #include "com/sun/star/uno/Any.hxx"
41 #include "com/sun/star/uno/Sequence.hxx"
42 #include "osl/diagnose.h"
43 #include "rtl/ustrbuf.hxx"
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(OUString( "Uri"),
125 makeAny(rPhysicalUrl
),
126 PropertyState_DIRECT_VALUE
);
129 <<= PropertyValue(OUString( "ResourceName"),
131 makeAny(aResourceName
),
132 PropertyState_DIRECT_VALUE
);
135 <<= PropertyValue(OUString( "ResourceType"),
137 makeAny(aResourceType
),
138 PropertyState_DIRECT_VALUE
);
141 <<= PropertyValue(OUString( "Removable"),
144 PropertyState_DIRECT_VALUE
);
152 namespace fileaccess
{
155 bool isChild( const OUString
& srcUnqPath
,
156 const OUString
& dstUnqPath
)
158 static sal_Unicode slash
= '/';
159 // Simple lexical comparison
160 sal_Int32 srcL
= srcUnqPath
.getLength();
161 sal_Int32 dstL
= dstUnqPath
.getLength();
164 ( srcUnqPath
== dstUnqPath
)
168 dstUnqPath
.startsWith(srcUnqPath
)
170 ( dstUnqPath
[ srcL
] == slash
) )
176 const OUString
& aNewPrefix
,
177 const OUString
& aOldPrefix
,
178 const OUString
& old_Name
)
180 sal_Int32 srcL
= aOldPrefix
.getLength();
182 OUString new_Name
= old_Name
.copy( srcL
);
183 new_Name
= ( aNewPrefix
+ new_Name
);
188 OUString
getTitle( const OUString
& aPath
)
190 sal_Unicode slash
= '/';
191 sal_Int32 lastIndex
= aPath
.lastIndexOf( slash
);
192 return aPath
.copy( lastIndex
+ 1 );
196 OUString
getParentName( const OUString
& aFileName
)
198 sal_Int32 lastIndex
= aFileName
.lastIndexOf( '/' );
199 OUString aParent
= aFileName
.copy( 0,lastIndex
);
201 if( aParent
.endsWith(":") && aParent
.getLength() == 6 )
204 if ( aParent
== "file://" )
205 aParent
= "file:///";
211 osl::FileBase::RC
osl_File_copy( const OUString
& strPath
,
212 const OUString
& strDestPath
,
217 osl::DirectoryItem aItem
;
218 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
219 return osl::FileBase::E_EXIST
;
222 return osl::File::copy( strPath
,strDestPath
);
226 osl::FileBase::RC
osl_File_move( const OUString
& strPath
,
227 const OUString
& strDestPath
,
232 osl::DirectoryItem aItem
;
233 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
234 return osl::FileBase::E_EXIST
;
237 return osl::File::move( strPath
,strDestPath
);
243 const Reference
< XCommandEnvironment
>& xEnv
,
244 const OUString
& aUncPath
,
245 BaseContent
* pContent
,
248 Reference
<XCommandProcessor
> xComProc(pContent
);
250 IOErrorCode ioErrorCode
;
252 if( errorCode
== TASKHANDLER_UNSUPPORTED_COMMAND
)
254 aAny
<<= UnsupportedCommandException( OSL_LOG_PREFIX
);
255 cancelCommandExecution( aAny
,xEnv
);
257 else if( errorCode
== TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT
||
258 errorCode
== TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT
||
259 errorCode
== TASKHANDLING_WRONG_OPEN_ARGUMENT
||
260 errorCode
== TASKHANDLING_WRONG_DELETE_ARGUMENT
||
261 errorCode
== TASKHANDLING_WRONG_TRANSFER_ARGUMENT
||
262 errorCode
== TASKHANDLING_WRONG_INSERT_ARGUMENT
||
263 errorCode
== TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT
)
265 IllegalArgumentException excep
;
266 excep
.ArgumentPosition
= 0;
268 cancelCommandExecution(
271 else if( errorCode
== TASKHANDLING_UNSUPPORTED_OPEN_MODE
)
273 UnsupportedOpenModeException excep
;
274 excep
.Mode
= sal::static_int_cast
< sal_Int16
>(minorCode
);
276 cancelCommandExecution( aAny
,xEnv
);
278 else if(errorCode
== TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND
||
279 errorCode
== TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND
||
280 errorCode
== TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND
)
285 // error in opening file
286 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE
||
287 // error in opening file
288 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_WRITE
||
289 // error in opening file
290 errorCode
== TASKHANDLING_OPEN_FOR_STREAM
||
291 // error in opening file
292 errorCode
== TASKHANDLING_OPEN_FOR_INPUTSTREAM
||
293 // error in opening file
294 errorCode
== TASKHANDLING_OPEN_FILE_FOR_PAGING
)
298 case FileBase::E_NAMETOOLONG
:
299 // pathname was too long
300 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
302 case FileBase::E_NXIO
:
303 // No such device or address
304 case FileBase::E_NODEV
:
306 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
308 case FileBase::E_NOTDIR
:
309 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
311 case FileBase::E_NOENT
:
312 // No such file or directory
313 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
315 case FileBase::E_ROFS
:
316 // #i4735# handle ROFS transparently as ACCESS_DENIED
317 case FileBase::E_ACCES
:
318 // permission denied<P>
319 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
321 case FileBase::E_ISDIR
:
323 ioErrorCode
= IOErrorCode_NO_FILE
;
325 case FileBase::E_NOTREADY
:
326 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
328 case FileBase::E_MFILE
:
329 // too many open files used by the process
330 case FileBase::E_NFILE
:
331 // too many open files in the system
332 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
334 case FileBase::E_INVAL
:
335 // the format of the parameters was not valid
336 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
338 case FileBase::E_NOMEM
:
339 // not enough memory for allocating structures
340 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
342 case FileBase::E_BUSY
:
344 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
346 case FileBase::E_AGAIN
:
347 // Operation would block
348 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
350 case FileBase::E_NOLCK
: // No record locks available
351 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
354 case FileBase::E_FAULT
: // Bad address
355 case FileBase::E_LOOP
: // Too many symbolic links encountered
356 case FileBase::E_NOSPC
: // No space left on device
357 case FileBase::E_INTR
: // function call was interrupted
358 case FileBase::E_IO
: // I/O error
359 case FileBase::E_MULTIHOP
: // Multihop attempted
360 case FileBase::E_NOLINK
: // Link has been severed
362 ioErrorCode
= IOErrorCode_GENERAL
;
366 cancelCommandExecution(
368 generateErrorArguments(aUncPath
),
370 OUString( "an error occurred during file opening"),
373 else if( errorCode
== TASKHANDLING_OPEN_FOR_DIRECTORYLISTING
||
374 errorCode
== TASKHANDLING_OPENDIRECTORY_FOR_REMOVE
)
378 case FileBase::E_INVAL
:
379 // the format of the parameters was not valid
380 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
382 case FileBase::E_NOENT
:
383 // the specified path doesn't exist
384 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
386 case FileBase::E_NOTDIR
:
387 // the specified path is not an directory
388 ioErrorCode
= IOErrorCode_NO_DIRECTORY
;
390 case FileBase::E_NOMEM
:
391 // not enough memory for allocating structures
392 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
394 case FileBase::E_ROFS
:
395 // #i4735# handle ROFS transparently as ACCESS_DENIED
396 case FileBase::E_ACCES
: // permission denied
397 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
399 case FileBase::E_NOTREADY
:
400 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
402 case FileBase::E_MFILE
:
403 // too many open files used by the process
404 case FileBase::E_NFILE
:
405 // too many open files in the system
406 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
408 case FileBase::E_NAMETOOLONG
:
409 // File name too long
410 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
412 case FileBase::E_LOOP
:
413 // Too many symbolic links encountered<p>
415 ioErrorCode
= IOErrorCode_GENERAL
;
419 cancelCommandExecution(
421 generateErrorArguments(aUncPath
),
423 OUString( "an error occurred during opening a directory"),
426 else if( errorCode
== TASKHANDLING_NOTCONNECTED_FOR_WRITE
||
427 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE
||
428 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_WRITE
||
429 errorCode
== TASKHANDLING_NOTCONNECTED_FOR_PAGING
||
430 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING
||
431 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_PAGING
)
433 ioErrorCode
= IOErrorCode_UNKNOWN
;
434 cancelCommandExecution(
436 generateErrorArguments(aUncPath
),
438 OUString( "an error occurred writing or reading from a file"),
441 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_NO_SPACE
)
443 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
444 cancelCommandExecution(
446 generateErrorArguments(aUncPath
),
448 OUString( "device full"),
451 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_WRITE
||
452 errorCode
== TASKHANDLING_READING_FILE_FOR_PAGING
)
456 case FileBase::E_INVAL
:
457 // the format of the parameters was not valid
458 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
460 case FileBase::E_FBIG
:
462 ioErrorCode
= IOErrorCode_CANT_WRITE
;
464 case FileBase::E_NOSPC
:
465 // No space left on device
466 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
468 case FileBase::E_NXIO
:
469 // No such device or address
470 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
472 case FileBase::E_NOLINK
:
473 // Link has been severed
474 case FileBase::E_ISDIR
:
476 ioErrorCode
= IOErrorCode_NO_FILE
;
478 case FileBase::E_AGAIN
:
479 // Operation would block
480 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
482 case FileBase::E_TIMEDOUT
:
483 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
485 case FileBase::E_NOLCK
: // No record locks available
486 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
488 case FileBase::E_IO
: // I/O error
489 case FileBase::E_BADF
: // Bad file
490 case FileBase::E_FAULT
: // Bad address
491 case FileBase::E_INTR
: // function call was interrupted
493 ioErrorCode
= IOErrorCode_GENERAL
;
496 cancelCommandExecution(
498 generateErrorArguments(aUncPath
),
500 OUString( "an error occurred during opening a file"),
503 else if( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
||
504 errorCode
== TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND
)
506 Sequence
< OUString
> aSeq( 1 );
508 ( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
) ?
510 OUString("ContentType");
512 aAny
<<= MissingPropertiesException(
513 OUString( "a property is missing necessary"
514 "to create a content"),
517 cancelCommandExecution(aAny
,xEnv
);
519 else if( errorCode
== TASKHANDLING_FILESIZE_FOR_WRITE
)
523 case FileBase::E_INVAL
:
524 // the format of the parameters was not valid
525 case FileBase::E_OVERFLOW
:
526 // The resulting file offset would be a value which cannot
527 // be represented correctly for regular files
528 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
531 ioErrorCode
= IOErrorCode_GENERAL
;
534 cancelCommandExecution(
536 generateErrorArguments(aUncPath
),
538 OUString( "there were problems with the filesize"),
541 else if(errorCode
== TASKHANDLING_INPUTSTREAM_FOR_WRITE
)
544 MissingInputStreamException(
545 OUString( "the inputstream is missing necessary"
546 "to create a content"),
548 cancelCommandExecution(aAny
,xEnv
);
550 else if( errorCode
== TASKHANDLING_NOREPLACE_FOR_WRITE
)
551 // Overwrite = false and file exists
553 NameClashException excep
;
554 excep
.Name
= getTitle(aUncPath
);
555 excep
.Classification
= InteractionClassification_ERROR
;
556 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
557 excep
.Message
= "file exists and overwrite forbidden";
559 cancelCommandExecution( aAny
,xEnv
);
561 else if( errorCode
== TASKHANDLING_INVALID_NAME_MKDIR
)
563 InteractiveAugmentedIOException excep
;
564 excep
.Code
= IOErrorCode_INVALID_CHARACTER
;
566 prop
.Name
= "ResourceName";
568 OUString
m_aClashingName(
571 rtl_UriDecodeWithCharset
,
572 RTL_TEXTENCODING_UTF8
));
573 prop
.Value
<<= m_aClashingName
;
574 Sequence
<Any
> seq(1);
576 excep
.Arguments
= seq
;
577 excep
.Classification
= InteractionClassification_ERROR
;
578 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
579 excep
.Message
= "the name contained invalid characters";
584 cancelCommandExecution( aAny
,xEnv
);
586 // ioErrorCode = IOErrorCode_INVALID_CHARACTER;
587 // cancelCommandExecution(
589 // generateErrorArguments(aUncPath),
591 // OUString( "the name contained invalid characters"),
594 else if( errorCode
== TASKHANDLING_FOLDER_EXISTS_MKDIR
)
596 NameClashException excep
;
597 excep
.Name
= getTitle(aUncPath
);
598 excep
.Classification
= InteractionClassification_ERROR
;
599 excep
.Context
= xComProc
;
600 excep
.Message
= "folder exists and overwrite forbidden";
605 cancelCommandExecution( aAny
,xEnv
);
607 // ioErrorCode = IOErrorCode_ALREADY_EXISTING;
608 // cancelCommandExecution(
610 // generateErrorArguments(aUncPath),
612 // OUString( "the folder exists"),
615 else if( errorCode
== TASKHANDLING_ENSUREDIR_FOR_WRITE
||
616 errorCode
== TASKHANDLING_CREATEDIRECTORY_MKDIR
)
620 case FileBase::E_ACCES
:
621 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
623 case FileBase::E_ROFS
:
624 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
626 case FileBase::E_NAMETOOLONG
:
627 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
630 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
633 cancelCommandExecution(
635 generateErrorArguments(getParentName(aUncPath
)),
636 //TODO! ok to supply physical URL to getParentName()?
638 OUString( "a folder could not be created"),
641 else if( errorCode
== TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE
||
642 errorCode
== TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE
||
643 errorCode
== TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE
)
647 case FileBase::E_INVAL
: // the format of the parameters was not valid
648 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
650 case FileBase::E_NOMEM
: // not enough memory for allocating structures
651 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
653 case FileBase::E_ROFS
: // #i4735# handle ROFS transparently as ACCESS_DENIED
654 case FileBase::E_ACCES
: // permission denied
655 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
657 case FileBase::E_MFILE
: // too many open files used by the process
658 case FileBase::E_NFILE
: // too many open files in the system
659 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
661 case FileBase::E_NOLINK
: // Link has been severed
662 case FileBase::E_NOENT
: // No such file or directory
663 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
665 case FileBase::E_NAMETOOLONG
: // File name too long
666 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
668 case FileBase::E_NOTDIR
: // A component of the path prefix of path is not a directory
669 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
671 case FileBase::E_LOOP
: // Too many symbolic links encountered
672 case FileBase::E_IO
: // I/O error
673 case FileBase::E_MULTIHOP
: // Multihop attempted
674 case FileBase::E_FAULT
: // Bad address
675 case FileBase::E_INTR
: // function call was interrupted
676 case FileBase::E_NOSYS
: // Function not implemented
677 case FileBase::E_NOSPC
: // No space left on device
678 case FileBase::E_NXIO
: // No such device or address
679 case FileBase::E_OVERFLOW
: // Value too large for defined data type
680 case FileBase::E_BADF
: // Invalid oslDirectoryItem parameter
682 ioErrorCode
= IOErrorCode_GENERAL
;
685 cancelCommandExecution(
687 generateErrorArguments(aUncPath
),
689 OUString( "a file status object could not be filled"),
692 else if( errorCode
== TASKHANDLING_DELETEFILE_FOR_REMOVE
||
693 errorCode
== TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE
)
697 case FileBase::E_INVAL
: // the format of the parameters was not valid
698 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
700 case FileBase::E_NOMEM
: // not enough memory for allocating structures
701 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
703 case FileBase::E_ACCES
: // Permission denied
704 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
706 case FileBase::E_PERM
: // Operation not permitted
707 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
709 case FileBase::E_NAMETOOLONG
: // File name too long
710 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
712 case FileBase::E_NOLINK
: // Link has been severed
713 case FileBase::E_NOENT
: // No such file or directory
714 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
716 case FileBase::E_ISDIR
: // Is a directory
717 case FileBase::E_ROFS
: // Read-only file system
718 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
720 case FileBase::E_BUSY
: // Device or resource busy
721 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
723 case FileBase::E_FAULT
: // Bad address
724 case FileBase::E_LOOP
: // Too many symbolic links encountered
725 case FileBase::E_IO
: // I/O error
726 case FileBase::E_INTR
: // function call was interrupted
727 case FileBase::E_MULTIHOP
: // Multihop attempted
729 ioErrorCode
= IOErrorCode_GENERAL
;
732 cancelCommandExecution(
734 generateErrorArguments(aUncPath
),
736 OUString( "a file or directory could not be deleted"),
739 else 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
||
743 errorCode
== TASKHANDLING_TRANSFER_DESTFILETYPE
||
744 errorCode
== TASKHANDLING_FILETYPE_FOR_REMOVE
||
745 errorCode
== TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE
||
746 errorCode
== TASKHANDLING_TRANSFER_INVALIDURL
)
751 case FileBase::E_NOENT
: // No such file or directory
752 if ( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
753 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
754 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
755 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
)
757 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
758 aMsg
= "source file/folder does not exist";
763 ioErrorCode
= IOErrorCode_GENERAL
;
764 aMsg
= "a general error during transfer command";
768 ioErrorCode
= IOErrorCode_GENERAL
;
769 aMsg
= "a general error during transfer command";
772 cancelCommandExecution(
774 generateErrorArguments(aUncPath
),
779 else if( errorCode
== TASKHANDLING_TRANSFER_ACCESSINGROOT
)
781 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
782 cancelCommandExecution(
784 generateErrorArguments(aUncPath
),
786 OUString( "accessing the root during transfer"),
789 else if( errorCode
== TASKHANDLING_TRANSFER_INVALIDSCHEME
)
792 InteractiveBadTransferURLException(
793 OUString( "bad transfer url"),
795 cancelCommandExecution( aAny
,xEnv
);
797 else if( errorCode
== TASKHANDLING_OVERWRITE_FOR_MOVE
||
798 errorCode
== TASKHANDLING_OVERWRITE_FOR_COPY
||
799 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_MOVE
||
800 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_COPY
||
801 errorCode
== TASKHANDLING_KEEPERROR_FOR_MOVE
||
802 errorCode
== TASKHANDLING_KEEPERROR_FOR_COPY
||
803 errorCode
== TASKHANDLING_RENAME_FOR_MOVE
||
804 errorCode
== TASKHANDLING_RENAME_FOR_COPY
||
805 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_MOVE
||
806 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_COPY
)
809 "general error during transfer");
813 case FileBase::E_EXIST
:
814 ioErrorCode
= IOErrorCode_ALREADY_EXISTING
;
816 case FileBase::E_INVAL
: // the format of the parameters was not valid
817 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
819 case FileBase::E_NOMEM
: // not enough memory for allocating structures
820 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
822 case FileBase::E_ACCES
: // Permission denied
823 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
825 case FileBase::E_PERM
: // Operation not permitted
826 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
828 case FileBase::E_NAMETOOLONG
: // File name too long
829 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
831 case FileBase::E_NOENT
: // No such file or directory
832 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
833 aMsg
= "file/folder does not exist";
835 case FileBase::E_ROFS
: // Read-only file system<p>
836 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
839 ioErrorCode
= IOErrorCode_GENERAL
;
842 cancelCommandExecution(
844 generateErrorArguments(aUncPath
),
849 else if( errorCode
== TASKHANDLING_NAMECLASH_FOR_COPY
||
850 errorCode
== TASKHANDLING_NAMECLASH_FOR_MOVE
)
852 NameClashException excep
;
853 excep
.Name
= getTitle(aUncPath
);
854 excep
.Classification
= InteractionClassification_ERROR
;
855 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
856 excep
.Message
= "name clash during copy or move";
859 cancelCommandExecution(aAny
,xEnv
);
861 else if( errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE
||
862 errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY
)
864 UnsupportedNameClashException excep
;
865 excep
.NameClash
= minorCode
;
866 excep
.Context
= Reference
<XInterface
>( xComProc
, UNO_QUERY
);
867 excep
.Message
= "name clash value not supported during copy or move";
870 cancelCommandExecution(aAny
,xEnv
);
874 // case TASKHANDLER_NO_ERROR:
880 } // end namespace fileaccess
882 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */