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 .
21 #include "filglob.hxx"
22 #include "filerror.hxx"
25 #include <osl/file.hxx>
27 #include <ucbhelper/cancelcommandexecution.hxx>
28 #include <com/sun/star/ucb/CommandAbortedException.hpp>
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/ustrbuf.hxx"
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 rtl::OUString
const & rPhysicalUrl
)
63 rtl::OUString aResourceName
;
64 rtl::OUString aResourceType
;
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
= rtl::OUString( "folder");
92 case osl::FileStatus::Volume
:
94 aResourceType
= rtl::OUString( "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) );
124 <<= PropertyValue(rtl::OUString( "Uri"),
126 makeAny(rPhysicalUrl
),
127 PropertyState_DIRECT_VALUE
);
130 <<= PropertyValue(rtl::OUString( "ResourceName"),
132 makeAny(aResourceName
),
133 PropertyState_DIRECT_VALUE
);
136 <<= PropertyValue(rtl::OUString( "ResourceType"),
138 makeAny(aResourceType
),
139 PropertyState_DIRECT_VALUE
);
142 <<= PropertyValue(rtl::OUString( "Removable"),
145 PropertyState_DIRECT_VALUE
);
153 namespace fileaccess
{
156 sal_Bool
isChild( const rtl::OUString
& srcUnqPath
,
157 const rtl::OUString
& dstUnqPath
)
159 static sal_Unicode slash
= '/';
160 // Simple lexical comparison
161 sal_Int32 srcL
= srcUnqPath
.getLength();
162 sal_Int32 dstL
= dstUnqPath
.getLength();
165 ( srcUnqPath
== dstUnqPath
)
169 ( srcUnqPath
.compareTo( dstUnqPath
, srcL
) == 0 )
171 ( dstUnqPath
[ srcL
] == slash
) )
176 rtl::OUString
newName(
177 const rtl::OUString
& aNewPrefix
,
178 const rtl::OUString
& aOldPrefix
,
179 const rtl::OUString
& old_Name
)
181 sal_Int32 srcL
= aOldPrefix
.getLength();
183 rtl::OUString new_Name
= old_Name
.copy( srcL
);
184 new_Name
= ( aNewPrefix
+ new_Name
);
189 rtl::OUString
getTitle( const rtl::OUString
& aPath
)
191 sal_Unicode slash
= '/';
192 sal_Int32 lastIndex
= aPath
.lastIndexOf( slash
);
193 return aPath
.copy( lastIndex
+ 1 );
197 rtl::OUString
getParentName( const rtl::OUString
& aFileName
)
199 sal_Int32 lastIndex
= aFileName
.lastIndexOf( sal_Unicode('/') );
200 rtl::OUString aParent
= aFileName
.copy( 0,lastIndex
);
202 if( aParent
[ aParent
.getLength()-1] == sal_Unicode(':') && aParent
.getLength() == 6 )
203 aParent
+= rtl::OUString("/");
205 if ( aParent
== "file://" )
206 aParent
= rtl::OUString("file:///");
212 osl::FileBase::RC
osl_File_copy( const rtl::OUString
& strPath
,
213 const rtl::OUString
& strDestPath
,
218 osl::DirectoryItem aItem
;
219 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
220 return osl::FileBase::E_EXIST
;
223 return osl::File::copy( strPath
,strDestPath
);
227 osl::FileBase::RC
osl_File_move( const rtl::OUString
& strPath
,
228 const rtl::OUString
& strDestPath
,
233 osl::DirectoryItem aItem
;
234 if( osl::DirectoryItem::get( strDestPath
,aItem
) != osl::FileBase:: E_NOENT
)
235 return osl::FileBase::E_EXIST
;
238 return osl::File::move( strPath
,strDestPath
);
244 const Reference
< XCommandEnvironment
>& xEnv
,
245 const rtl::OUString
& aUncPath
,
246 BaseContent
* pContent
,
249 Reference
<XCommandProcessor
> xComProc(pContent
);
251 IOErrorCode ioErrorCode
;
253 if( errorCode
== TASKHANDLER_UNSUPPORTED_COMMAND
)
255 aAny
<<= UnsupportedCommandException( ::rtl::OUString( OSL_LOG_PREFIX
), uno::Reference
< uno::XInterface
>() );
256 cancelCommandExecution( aAny
,xEnv
);
258 else if( errorCode
== TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT
||
259 errorCode
== TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT
||
260 errorCode
== TASKHANDLING_WRONG_OPEN_ARGUMENT
||
261 errorCode
== TASKHANDLING_WRONG_DELETE_ARGUMENT
||
262 errorCode
== TASKHANDLING_WRONG_TRANSFER_ARGUMENT
||
263 errorCode
== TASKHANDLING_WRONG_INSERT_ARGUMENT
||
264 errorCode
== TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT
)
266 IllegalArgumentException excep
;
267 excep
.ArgumentPosition
= 0;
269 cancelCommandExecution(
272 else if( errorCode
== TASKHANDLING_UNSUPPORTED_OPEN_MODE
)
274 UnsupportedOpenModeException excep
;
275 excep
.Mode
= sal::static_int_cast
< sal_Int16
>(minorCode
);
277 cancelCommandExecution( aAny
,xEnv
);
279 else if(errorCode
== TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND
||
280 errorCode
== TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND
||
281 errorCode
== TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND
)
286 // error in opening file
287 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE
||
288 // error in opening file
289 errorCode
== TASKHANDLING_NO_OPEN_FILE_FOR_WRITE
||
290 // error in opening file
291 errorCode
== TASKHANDLING_OPEN_FOR_STREAM
||
292 // error in opening file
293 errorCode
== TASKHANDLING_OPEN_FOR_INPUTSTREAM
||
294 // error in opening file
295 errorCode
== TASKHANDLING_OPEN_FILE_FOR_PAGING
)
299 case FileBase::E_NAMETOOLONG
:
300 // pathname was too long
301 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
303 case FileBase::E_NXIO
:
304 // No such device or address
305 case FileBase::E_NODEV
:
307 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
309 case FileBase::E_NOTDIR
:
310 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
312 case FileBase::E_NOENT
:
313 // No such file or directory
314 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
316 case FileBase::E_ROFS
:
317 // #i4735# handle ROFS transparently as ACCESS_DENIED
318 case FileBase::E_ACCES
:
319 // permission denied<P>
320 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
322 case FileBase::E_ISDIR
:
324 ioErrorCode
= IOErrorCode_NO_FILE
;
326 case FileBase::E_NOTREADY
:
327 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
329 case FileBase::E_MFILE
:
330 // too many open files used by the process
331 case FileBase::E_NFILE
:
332 // too many open files in the system
333 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
335 case FileBase::E_INVAL
:
336 // the format of the parameters was not valid
337 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
339 case FileBase::E_NOMEM
:
340 // not enough memory for allocating structures
341 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
343 case FileBase::E_BUSY
:
345 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
347 case FileBase::E_AGAIN
:
348 // Operation would block
349 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
351 case FileBase::E_NOLCK
: // No record locks available
352 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
355 case FileBase::E_FAULT
: // Bad address
356 case FileBase::E_LOOP
: // Too many symbolic links encountered
357 case FileBase::E_NOSPC
: // No space left on device
358 case FileBase::E_INTR
: // function call was interrupted
359 case FileBase::E_IO
: // I/O error
360 case FileBase::E_MULTIHOP
: // Multihop attempted
361 case FileBase::E_NOLINK
: // Link has been severed
363 ioErrorCode
= IOErrorCode_GENERAL
;
367 cancelCommandExecution(
369 generateErrorArguments(aUncPath
),
371 rtl::OUString( "an error occurred during file opening"),
374 else if( errorCode
== TASKHANDLING_OPEN_FOR_DIRECTORYLISTING
||
375 errorCode
== TASKHANDLING_OPENDIRECTORY_FOR_REMOVE
)
379 case FileBase::E_INVAL
:
380 // the format of the parameters was not valid
381 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
383 case FileBase::E_NOENT
:
384 // the specified path doesn't exist
385 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
387 case FileBase::E_NOTDIR
:
388 // the specified path is not an directory
389 ioErrorCode
= IOErrorCode_NO_DIRECTORY
;
391 case FileBase::E_NOMEM
:
392 // not enough memory for allocating structures
393 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
395 case FileBase::E_ROFS
:
396 // #i4735# handle ROFS transparently as ACCESS_DENIED
397 case FileBase::E_ACCES
: // permission denied
398 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
400 case FileBase::E_NOTREADY
:
401 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
403 case FileBase::E_MFILE
:
404 // too many open files used by the process
405 case FileBase::E_NFILE
:
406 // too many open files in the system
407 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
409 case FileBase::E_NAMETOOLONG
:
410 // File name too long
411 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
413 case FileBase::E_LOOP
:
414 // Too many symbolic links encountered<p>
416 ioErrorCode
= IOErrorCode_GENERAL
;
420 cancelCommandExecution(
422 generateErrorArguments(aUncPath
),
424 rtl::OUString( "an error occurred during opening a directory"),
427 else if( errorCode
== TASKHANDLING_NOTCONNECTED_FOR_WRITE
||
428 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE
||
429 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_WRITE
||
430 errorCode
== TASKHANDLING_NOTCONNECTED_FOR_PAGING
||
431 errorCode
== TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING
||
432 errorCode
== TASKHANDLING_IOEXCEPTION_FOR_PAGING
)
434 ioErrorCode
= IOErrorCode_UNKNOWN
;
435 cancelCommandExecution(
437 generateErrorArguments(aUncPath
),
439 rtl::OUString( "an error occurred writing or reading from a file"),
442 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_NO_SPACE
)
444 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
445 cancelCommandExecution(
447 generateErrorArguments(aUncPath
),
449 rtl::OUString( "device full"),
452 else if( errorCode
== TASKHANDLING_FILEIOERROR_FOR_WRITE
||
453 errorCode
== TASKHANDLING_READING_FILE_FOR_PAGING
)
457 case FileBase::E_INVAL
:
458 // the format of the parameters was not valid
459 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
461 case FileBase::E_FBIG
:
463 ioErrorCode
= IOErrorCode_CANT_WRITE
;
465 case FileBase::E_NOSPC
:
466 // No space left on device
467 ioErrorCode
= IOErrorCode_OUT_OF_DISK_SPACE
;
469 case FileBase::E_NXIO
:
470 // No such device or address
471 ioErrorCode
= IOErrorCode_INVALID_DEVICE
;
473 case FileBase::E_NOLINK
:
474 // Link has been severed
475 case FileBase::E_ISDIR
:
477 ioErrorCode
= IOErrorCode_NO_FILE
;
479 case FileBase::E_AGAIN
:
480 // Operation would block
481 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
483 case FileBase::E_TIMEDOUT
:
484 ioErrorCode
= IOErrorCode_DEVICE_NOT_READY
;
486 case FileBase::E_NOLCK
: // No record locks available
487 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
489 case FileBase::E_IO
: // I/O error
490 case FileBase::E_BADF
: // Bad file
491 case FileBase::E_FAULT
: // Bad address
492 case FileBase::E_INTR
: // function call was interrupted
494 ioErrorCode
= IOErrorCode_GENERAL
;
497 cancelCommandExecution(
499 generateErrorArguments(aUncPath
),
501 rtl::OUString( "an error occurred during opening a file"),
504 else if( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
||
505 errorCode
== TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND
)
507 Sequence
< ::rtl::OUString
> aSeq( 1 );
509 ( errorCode
== TASKHANDLING_NONAMESET_INSERT_COMMAND
) ?
510 rtl::OUString("Title") :
511 rtl::OUString("ContentType");
513 aAny
<<= MissingPropertiesException(
514 rtl::OUString( "a property is missing necessary"
515 "to create a content"),
518 cancelCommandExecution(aAny
,xEnv
);
520 else if( errorCode
== TASKHANDLING_FILESIZE_FOR_WRITE
)
524 case FileBase::E_INVAL
:
525 // the format of the parameters was not valid
526 case FileBase::E_OVERFLOW
:
527 // The resulting file offset would be a value which cannot
528 // be represented correctly for regular files
529 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
532 ioErrorCode
= IOErrorCode_GENERAL
;
535 cancelCommandExecution(
537 generateErrorArguments(aUncPath
),
539 rtl::OUString( "there were problems with the filesize"),
542 else if(errorCode
== TASKHANDLING_INPUTSTREAM_FOR_WRITE
)
544 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
546 MissingInputStreamException(
547 rtl::OUString( "the inputstream is missing necessary"
548 "to create a content"),
550 cancelCommandExecution(aAny
,xEnv
);
552 else if( errorCode
== TASKHANDLING_NOREPLACE_FOR_WRITE
)
553 // Overwrite = false and file exists
555 NameClashException excep
;
556 excep
.Name
= getTitle(aUncPath
);
557 excep
.Classification
= InteractionClassification_ERROR
;
558 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
559 excep
.Context
= xContext
;
560 excep
.Message
= rtl::OUString( "file exists and overwrite forbidden");
562 cancelCommandExecution( aAny
,xEnv
);
564 else if( errorCode
== TASKHANDLING_INVALID_NAME_MKDIR
)
566 InteractiveAugmentedIOException excep
;
567 excep
.Code
= IOErrorCode_INVALID_CHARACTER
;
569 prop
.Name
= rtl::OUString("ResourceName");
571 rtl::OUString
m_aClashingName(
574 rtl_UriDecodeWithCharset
,
575 RTL_TEXTENCODING_UTF8
));
576 prop
.Value
<<= m_aClashingName
;
577 Sequence
<Any
> seq(1);
579 excep
.Arguments
= seq
;
580 excep
.Classification
= InteractionClassification_ERROR
;
581 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
582 excep
.Context
= xContext
;
583 excep
.Message
= rtl::OUString( "the name contained invalid characters");
588 cancelCommandExecution( aAny
,xEnv
);
590 // ioErrorCode = IOErrorCode_INVALID_CHARACTER;
591 // cancelCommandExecution(
593 // generateErrorArguments(aUncPath),
595 // rtl::OUString( "the name contained invalid characters"),
598 else if( errorCode
== TASKHANDLING_FOLDER_EXISTS_MKDIR
)
600 NameClashException excep
;
601 excep
.Name
= getTitle(aUncPath
);
602 excep
.Classification
= InteractionClassification_ERROR
;
603 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
604 excep
.Context
= xContext
;
605 excep
.Message
= rtl::OUString( "folder exists and overwrite forbidden");
610 cancelCommandExecution( aAny
,xEnv
);
612 // ioErrorCode = IOErrorCode_ALREADY_EXISTING;
613 // cancelCommandExecution(
615 // generateErrorArguments(aUncPath),
617 // rtl::OUString( "the folder exists"),
620 else if( errorCode
== TASKHANDLING_ENSUREDIR_FOR_WRITE
||
621 errorCode
== TASKHANDLING_CREATEDIRECTORY_MKDIR
)
625 case FileBase::E_ACCES
:
626 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
628 case FileBase::E_ROFS
:
629 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
631 case FileBase::E_NAMETOOLONG
:
632 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
635 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
638 cancelCommandExecution(
640 generateErrorArguments(getParentName(aUncPath
)),
641 //TODO! ok to supply physical URL to getParentName()?
643 rtl::OUString( "a folder could not be created"),
646 else if( errorCode
== TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE
||
647 errorCode
== TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE
||
648 errorCode
== TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE
)
652 case FileBase::E_INVAL
: // the format of the parameters was not valid
653 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
655 case FileBase::E_NOMEM
: // not enough memory for allocating structures
656 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
658 case FileBase::E_ROFS
: // #i4735# handle ROFS transparently as ACCESS_DENIED
659 case FileBase::E_ACCES
: // permission denied
660 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
662 case FileBase::E_MFILE
: // too many open files used by the process
663 case FileBase::E_NFILE
: // too many open files in the system
664 ioErrorCode
= IOErrorCode_OUT_OF_FILE_HANDLES
;
666 case FileBase::E_NOLINK
: // Link has been severed
667 case FileBase::E_NOENT
: // No such file or directory
668 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
670 case FileBase::E_NAMETOOLONG
: // File name too long
671 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
673 case FileBase::E_NOTDIR
: // A component of the path prefix of path is not a directory
674 ioErrorCode
= IOErrorCode_NOT_EXISTING_PATH
;
676 case FileBase::E_LOOP
: // Too many symbolic links encountered
677 case FileBase::E_IO
: // I/O error
678 case FileBase::E_MULTIHOP
: // Multihop attempted
679 case FileBase::E_FAULT
: // Bad address
680 case FileBase::E_INTR
: // function call was interrupted
681 case FileBase::E_NOSYS
: // Function not implemented
682 case FileBase::E_NOSPC
: // No space left on device
683 case FileBase::E_NXIO
: // No such device or address
684 case FileBase::E_OVERFLOW
: // Value too large for defined data type
685 case FileBase::E_BADF
: // Invalid oslDirectoryItem parameter
687 ioErrorCode
= IOErrorCode_GENERAL
;
690 cancelCommandExecution(
692 generateErrorArguments(aUncPath
),
694 rtl::OUString( "a file status object could not be filled"),
697 else if( errorCode
== TASKHANDLING_DELETEFILE_FOR_REMOVE
||
698 errorCode
== TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE
)
702 case FileBase::E_INVAL
: // the format of the parameters was not valid
703 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
705 case FileBase::E_NOMEM
: // not enough memory for allocating structures
706 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
708 case FileBase::E_ACCES
: // Permission denied
709 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
711 case FileBase::E_PERM
: // Operation not permitted
712 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
714 case FileBase::E_NAMETOOLONG
: // File name too long
715 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
717 case FileBase::E_NOLINK
: // Link has been severed
718 case FileBase::E_NOENT
: // No such file or directory
719 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
721 case FileBase::E_ISDIR
: // Is a directory
722 case FileBase::E_ROFS
: // Read-only file system
723 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
725 case FileBase::E_BUSY
: // Device or resource busy
726 ioErrorCode
= IOErrorCode_LOCKING_VIOLATION
;
728 case FileBase::E_FAULT
: // Bad address
729 case FileBase::E_LOOP
: // Too many symbolic links encountered
730 case FileBase::E_IO
: // I/O error
731 case FileBase::E_INTR
: // function call was interrupted
732 case FileBase::E_MULTIHOP
: // Multihop attempted
734 ioErrorCode
= IOErrorCode_GENERAL
;
737 cancelCommandExecution(
739 generateErrorArguments(aUncPath
),
741 rtl::OUString( "a file or directory could not be deleted"),
744 else if( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
745 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
746 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
747 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
||
748 errorCode
== TASKHANDLING_TRANSFER_DESTFILETYPE
||
749 errorCode
== TASKHANDLING_FILETYPE_FOR_REMOVE
||
750 errorCode
== TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE
||
751 errorCode
== TASKHANDLING_TRANSFER_INVALIDURL
)
756 case FileBase::E_NOENT
: // No such file or directory
757 if ( errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCE
||
758 errorCode
== TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
||
759 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
||
760 errorCode
== TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
)
762 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
763 aMsg
= rtl::OUString( "source file/folder does not exist");
768 ioErrorCode
= IOErrorCode_GENERAL
;
769 aMsg
= rtl::OUString( "a general error during transfer command");
773 ioErrorCode
= IOErrorCode_GENERAL
;
774 aMsg
= rtl::OUString( "a general error during transfer command");
777 cancelCommandExecution(
779 generateErrorArguments(aUncPath
),
784 else if( errorCode
== TASKHANDLING_TRANSFER_ACCESSINGROOT
)
786 ioErrorCode
= IOErrorCode_WRITE_PROTECTED
;
787 cancelCommandExecution(
789 generateErrorArguments(aUncPath
),
791 rtl::OUString( "accessing the root during transfer"),
794 else if( errorCode
== TASKHANDLING_TRANSFER_INVALIDSCHEME
)
796 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
799 InteractiveBadTransferURLException(
800 rtl::OUString( "bad tranfer url"),
802 cancelCommandExecution( aAny
,xEnv
);
804 else if( errorCode
== TASKHANDLING_OVERWRITE_FOR_MOVE
||
805 errorCode
== TASKHANDLING_OVERWRITE_FOR_COPY
||
806 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_MOVE
||
807 errorCode
== TASKHANDLING_NAMECLASHMOVE_FOR_COPY
||
808 errorCode
== TASKHANDLING_KEEPERROR_FOR_MOVE
||
809 errorCode
== TASKHANDLING_KEEPERROR_FOR_COPY
||
810 errorCode
== TASKHANDLING_RENAME_FOR_MOVE
||
811 errorCode
== TASKHANDLING_RENAME_FOR_COPY
||
812 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_MOVE
||
813 errorCode
== TASKHANDLING_RENAMEMOVE_FOR_COPY
)
816 "general error during transfer");
820 case FileBase::E_EXIST
:
821 ioErrorCode
= IOErrorCode_ALREADY_EXISTING
;
823 case FileBase::E_INVAL
: // the format of the parameters was not valid
824 ioErrorCode
= IOErrorCode_INVALID_PARAMETER
;
826 case FileBase::E_NOMEM
: // not enough memory for allocating structures
827 ioErrorCode
= IOErrorCode_OUT_OF_MEMORY
;
829 case FileBase::E_ACCES
: // Permission denied
830 ioErrorCode
= IOErrorCode_ACCESS_DENIED
;
832 case FileBase::E_PERM
: // Operation not permitted
833 ioErrorCode
= IOErrorCode_NOT_SUPPORTED
;
835 case FileBase::E_NAMETOOLONG
: // File name too long
836 ioErrorCode
= IOErrorCode_NAME_TOO_LONG
;
838 case FileBase::E_NOENT
: // No such file or directory
839 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
840 aMsg
= rtl::OUString( "file/folder does not exist");
842 case FileBase::E_ROFS
: // Read-only file system<p>
843 ioErrorCode
= IOErrorCode_NOT_EXISTING
;
846 ioErrorCode
= IOErrorCode_GENERAL
;
849 cancelCommandExecution(
851 generateErrorArguments(aUncPath
),
856 else if( errorCode
== TASKHANDLING_NAMECLASH_FOR_COPY
||
857 errorCode
== TASKHANDLING_NAMECLASH_FOR_MOVE
)
859 NameClashException excep
;
860 excep
.Name
= getTitle(aUncPath
);
861 excep
.Classification
= InteractionClassification_ERROR
;
862 Reference
<XInterface
> xContext(xComProc
,UNO_QUERY
);
863 excep
.Context
= xContext
;
864 excep
.Message
= rtl::OUString( "name clash during copy or move");
867 cancelCommandExecution(aAny
,xEnv
);
869 else if( errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE
||
870 errorCode
== TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY
)
872 Reference
<XInterface
> xContext(
874 UnsupportedNameClashException excep
;
875 excep
.NameClash
= minorCode
;
876 excep
.Context
= xContext
;
877 excep
.Message
= rtl::OUString( "name clash value not supported during copy or move");
880 cancelCommandExecution(aAny
,xEnv
);
884 // case TASKHANDLER_NO_ERROR:
890 } // end namespace fileaccess
892 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */