xref: /aoo42x/main/ucb/source/ucp/file/filglob.cxx (revision 86e1cf34)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_ucb.hxx"
26 #include <stdio.h>
27 #include "filglob.hxx"
28 #ifndef _FILERROR_HXX_
29 #include "filerror.hxx"
30 #endif
31 #include "shell.hxx"
32 #include "bc.hxx"
33 #include <osl/file.hxx>
34 #ifndef INCLUDED_STL_VECTOR
35 #include <vector>
36 #define INCLUDED_STL_VECTOR
37 #endif
38 #include <ucbhelper/cancelcommandexecution.hxx>
39 #include <com/sun/star/ucb/CommandAbortedException.hpp>
40 #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
41 #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
42 #include <com/sun/star/lang/IllegalArgumentException.hpp>
43 #include <com/sun/star/ucb/IOErrorCode.hpp>
44 #include <com/sun/star/ucb/MissingPropertiesException.hpp>
45 #include <com/sun/star/ucb/MissingInputStreamException.hpp>
46 #include <com/sun/star/ucb/NameClashException.hpp>
47 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
48 #include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
49 #include "com/sun/star/beans/PropertyState.hpp"
50 #include "com/sun/star/beans/PropertyValue.hpp"
51 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
52 #include "com/sun/star/uno/Any.hxx"
53 #include "com/sun/star/uno/Sequence.hxx"
54 #include "osl/diagnose.h"
55 #include "rtl/ustrbuf.hxx"
56 #include <rtl/uri.hxx>
57 #include <rtl/ustring.hxx>
58 #include "sal/types.h"
59 
60 using namespace ucbhelper;
61 using namespace osl;
62 using namespace ::com::sun::star;
63 using namespace com::sun::star::task;
64 using namespace com::sun::star::beans;
65 using namespace com::sun::star::lang;
66 using namespace com::sun::star::uno;
67 using namespace com::sun::star::ucb;
68 
69 namespace {
70 
71     Sequence< Any > generateErrorArguments(
72         rtl::OUString const & rPhysicalUrl)
73     {
74         rtl::OUString aResourceName;
75         rtl::OUString aResourceType;
76         sal_Bool      bRemovable;
77         bool bResourceName = false;
78         bool bResourceType = false;
79         bool bRemoveProperty = false;
80 
81         if (osl::FileBase::getSystemPathFromFileURL(
82                 rPhysicalUrl,
83                 aResourceName)
84             == osl::FileBase::E_None)
85             bResourceName = true;
86 
87         // The resource types "folder" (i.e., directory) and
88         // "volume" seem to be
89         // the most interesting when producing meaningful error messages:
90         osl::DirectoryItem aItem;
91         if (osl::DirectoryItem::get(rPhysicalUrl, aItem) ==
92             osl::FileBase::E_None)
93         {
94             osl::FileStatus aStatus( FileStatusMask_Type );
95             if (aItem.getFileStatus(aStatus) == osl::FileBase::E_None)
96                 switch (aStatus.getFileType())
97                 {
98                     case osl::FileStatus::Directory:
99                         aResourceType
100                             = rtl::OUString(
101                                 RTL_CONSTASCII_USTRINGPARAM("folder"));
102                         bResourceType = true;
103                         break;
104 
105                     case osl::FileStatus::Volume:
106                     {
107                         aResourceType
108                             = rtl::OUString(
109                                 RTL_CONSTASCII_USTRINGPARAM("volume"));
110                         bResourceType = true;
111                         osl::VolumeInfo aVolumeInfo(
112                             VolumeInfoMask_Attributes );
113                         if( osl::Directory::getVolumeInfo(
114                             rPhysicalUrl,aVolumeInfo ) ==
115                             osl::FileBase::E_None )
116                         {
117                             bRemovable = aVolumeInfo.getRemoveableFlag();
118                             bRemoveProperty = true;
119                         }
120                     }
121                     break;
122                     case osl::FileStatus::Regular:
123                     case osl::FileStatus::Fifo:
124                     case osl::FileStatus::Socket:
125                     case osl::FileStatus::Link:
126                     case osl::FileStatus::Special:
127                     case osl::FileStatus::Unknown:
128                         // do nothing for now
129                         break;
130                 }
131         }
132 
133         Sequence< Any > aArguments( 1              +
134                                     (bResourceName ? 1 : 0)     +
135                                     (bResourceType ? 1 : 0)     +
136                                     (bRemoveProperty ? 1 : 0) );
137         sal_Int32 i = 0;
138         aArguments[i++]
139             <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
140                 "Uri")),
141                               -1,
142                               makeAny(rPhysicalUrl),
143                               PropertyState_DIRECT_VALUE);
144         if (bResourceName)
145             aArguments[i++]
146                 <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
147                     "ResourceName")),
148                                   -1,
149                                   makeAny(aResourceName),
150                                   PropertyState_DIRECT_VALUE);
151         if (bResourceType)
152             aArguments[i++]
153                 <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
154                     "ResourceType")),
155                                   -1,
156                                   makeAny(aResourceType),
157                                   PropertyState_DIRECT_VALUE);
158         if (bRemoveProperty)
159             aArguments[i++]
160                 <<= PropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
161                     "Removable")),
162                                   -1,
163                                   makeAny(bRemovable),
164                                   PropertyState_DIRECT_VALUE);
165 
166         return aArguments;
167     }
168 }
169 
170 
171 
172 namespace fileaccess {
173 
174 
175     sal_Bool isChild( const rtl::OUString& srcUnqPath,
176                       const rtl::OUString& dstUnqPath )
177     {
178         static sal_Unicode slash = '/';
179         // Simple lexical comparison
180         sal_Int32 srcL = srcUnqPath.getLength();
181         sal_Int32 dstL = dstUnqPath.getLength();
182 
183         return (
184             ( srcUnqPath == dstUnqPath )
185             ||
186             ( ( dstL > srcL )
187               &&
188               ( srcUnqPath.compareTo( dstUnqPath, srcL ) == 0 )
189               &&
190               ( dstUnqPath[ srcL ] == slash ) )
191         );
192     }
193 
194 
195     rtl::OUString newName(
196         const rtl::OUString& aNewPrefix,
197         const rtl::OUString& aOldPrefix,
198         const rtl::OUString& old_Name )
199     {
200         sal_Int32 srcL = aOldPrefix.getLength();
201 
202         rtl::OUString new_Name = old_Name.copy( srcL );
203         new_Name = ( aNewPrefix + new_Name );
204         return new_Name;
205     }
206 
207 
208     rtl::OUString getTitle( const rtl::OUString& aPath )
209     {
210         sal_Unicode slash = '/';
211         sal_Int32 lastIndex = aPath.lastIndexOf( slash );
212         return aPath.copy( lastIndex + 1 );
213     }
214 
215 
216     rtl::OUString getParentName( const rtl::OUString& aFileName )
217     {
218         sal_Int32 lastIndex = aFileName.lastIndexOf( sal_Unicode('/') );
219         rtl::OUString aParent = aFileName.copy( 0,lastIndex );
220 
221         if( aParent[ aParent.getLength()-1] == sal_Unicode(':') && aParent.getLength() == 6 )
222             aParent += rtl::OUString::createFromAscii( "/" );
223 
224         if( 0 == aParent.compareToAscii( "file://" ) )
225             aParent = rtl::OUString::createFromAscii( "file:///" );
226 
227         return aParent;
228     }
229 
230 
231     osl::FileBase::RC osl_File_copy( const rtl::OUString& strPath,
232                                      const rtl::OUString& strDestPath,
233                                      sal_Bool test )
234     {
235         if( test )
236         {
237             osl::DirectoryItem aItem;
238             if( osl::DirectoryItem::get( strDestPath,aItem ) != osl::FileBase:: E_NOENT )
239                 return osl::FileBase::E_EXIST;
240         }
241 
242         return osl::File::copy( strPath,strDestPath );
243     }
244 
245 
246     osl::FileBase::RC osl_File_move( const rtl::OUString& strPath,
247                                      const rtl::OUString& strDestPath,
248                                      sal_Bool test )
249     {
250         if( test )
251         {
252             osl::DirectoryItem aItem;
253             if( osl::DirectoryItem::get( strDestPath,aItem ) != osl::FileBase:: E_NOENT )
254                 return osl::FileBase::E_EXIST;
255         }
256 
257         return osl::File::move( strPath,strDestPath );
258     }
259 
260     void throw_handler(
261         sal_Int32 errorCode,
262         sal_Int32 minorCode,
263         const Reference< XCommandEnvironment >& xEnv,
264         const rtl::OUString& aUncPath,
265         BaseContent* pContent,
266         bool isHandled )
267     {
268         Reference<XCommandProcessor> xComProc(pContent);
269         Any aAny;
270         IOErrorCode ioErrorCode;
271 
272         if( errorCode ==  TASKHANDLER_UNSUPPORTED_COMMAND )
273         {
274             aAny <<= UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
275             cancelCommandExecution( aAny,xEnv );
276         }
277         else if( errorCode == TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT ||
278                  errorCode == TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT ||
279                  errorCode == TASKHANDLING_WRONG_OPEN_ARGUMENT              ||
280                  errorCode == TASKHANDLING_WRONG_DELETE_ARGUMENT            ||
281                  errorCode == TASKHANDLING_WRONG_TRANSFER_ARGUMENT          ||
282                  errorCode == TASKHANDLING_WRONG_INSERT_ARGUMENT            ||
283                  errorCode == TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT )
284         {
285             IllegalArgumentException excep;
286             excep.ArgumentPosition = 0;
287             aAny <<= excep;
288             cancelCommandExecution(
289                 aAny,xEnv);
290         }
291         else if( errorCode == TASKHANDLING_UNSUPPORTED_OPEN_MODE )
292         {
293             UnsupportedOpenModeException excep;
294             excep.Mode = sal::static_int_cast< sal_Int16 >(minorCode);
295             aAny <<= excep;
296                 cancelCommandExecution( aAny,xEnv );
297         }
298         else if(errorCode == TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND  ||
299                 errorCode == TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND ||
300                 errorCode == TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND )
301         {
302             // What to do here?
303         }
304         else if(
305             // error in opening file
306             errorCode == TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE ||
307             // error in opening file
308             errorCode == TASKHANDLING_NO_OPEN_FILE_FOR_WRITE     ||
309             // error in opening file
310             errorCode == TASKHANDLING_OPEN_FOR_STREAM            ||
311             // error in opening file
312             errorCode == TASKHANDLING_OPEN_FOR_INPUTSTREAM       ||
313             // error in opening file
314             errorCode == TASKHANDLING_OPEN_FILE_FOR_PAGING )
315         {
316             switch( minorCode )
317             {
318                 case FileBase::E_NAMETOOLONG:
319                     // pathname was too long
320                     ioErrorCode = IOErrorCode_NAME_TOO_LONG;
321                     break;
322                 case FileBase::E_NXIO:
323                     // No such device or address
324                 case FileBase::E_NODEV:
325                     // No such device
326                     ioErrorCode = IOErrorCode_INVALID_DEVICE;
327                     break;
328                 case FileBase::E_NOENT:
329                     // No such file or directory
330                     ioErrorCode = IOErrorCode_NOT_EXISTING;
331                     break;
332                 case FileBase::E_ROFS:
333                     // #i4735# handle ROFS transparently as ACCESS_DENIED
334                 case FileBase::E_ACCES:
335                     // permission denied<P>
336                     ioErrorCode = IOErrorCode_ACCESS_DENIED;
337                     break;
338                 case FileBase::E_ISDIR:
339                     // Is a directory<p>
340                     ioErrorCode = IOErrorCode_NO_FILE;
341                     break;
342                 case FileBase::E_NOTREADY:
343                     ioErrorCode = IOErrorCode_DEVICE_NOT_READY;
344                     break;
345                 case FileBase::E_MFILE:
346                     // too many open files used by the process
347                 case FileBase::E_NFILE:
348                     // too many open files in the system
349                     ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES;
350                     break;
351                 case FileBase::E_INVAL:
352                     // the format of the parameters was not valid
353                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
354                     break;
355                 case FileBase::E_NOMEM:
356                     // not enough memory for allocating structures
357                     ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
358                     break;
359                 case FileBase::E_BUSY:
360                     // Text file busy
361                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
362                     break;
363                 case FileBase::E_AGAIN:
364                     // Operation would block
365                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
366                     break;
367                 case FileBase::E_NOLCK:  // No record locks available
368                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
369                     break;
370 
371                 case FileBase::E_FAULT: // Bad address
372                 case FileBase::E_LOOP:	// Too many symbolic links encountered
373                 case FileBase::E_NOSPC:	// No space left on device
374                 case FileBase::E_INTR:	// function call was interrupted
375                 case FileBase::E_IO:	// I/O error
376                 case FileBase::E_MULTIHOP:		// Multihop attempted
377                 case FileBase::E_NOLINK:	    // Link has been severed
378                 default:
379                     ioErrorCode = IOErrorCode_GENERAL;
380                     break;
381             }
382 
383             cancelCommandExecution(
384                 ioErrorCode,
385                 generateErrorArguments(aUncPath),
386                 xEnv,
387                 rtl::OUString(
388                     RTL_CONSTASCII_USTRINGPARAM(
389                         "an error occurred during file opening")),
390                 xComProc);
391         }
392         else if( errorCode == TASKHANDLING_OPEN_FOR_DIRECTORYLISTING  ||
393                  errorCode == TASKHANDLING_OPENDIRECTORY_FOR_REMOVE )
394         {
395             switch( minorCode )
396             {
397                 case FileBase::E_INVAL:
398                     // the format of the parameters was not valid
399                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
400                     break;
401                 case FileBase::E_NOENT:
402                     // the specified path doesn't exist
403                     ioErrorCode = IOErrorCode_NOT_EXISTING;
404                     break;
405                 case FileBase::E_NOTDIR:
406                     // the specified path is not an directory
407                     ioErrorCode = IOErrorCode_NO_DIRECTORY;
408                     break;
409                 case FileBase::E_NOMEM:
410                     // not enough memory for allocating structures
411                     ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
412                     break;
413                 case FileBase::E_ROFS:
414                     // #i4735# handle ROFS transparently as ACCESS_DENIED
415                 case FileBase::E_ACCES:		     // permission denied
416                     ioErrorCode = IOErrorCode_ACCESS_DENIED;
417                     break;
418                 case FileBase::E_NOTREADY:
419                     ioErrorCode = IOErrorCode_DEVICE_NOT_READY;
420                     break;
421                 case FileBase::E_MFILE:
422                     // too many open files used by the process
423                 case FileBase::E_NFILE:
424                     // too many open files in the system
425                     ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES;
426                     break;
427                 case FileBase::E_NAMETOOLONG:
428                     // File name too long
429                     ioErrorCode = IOErrorCode_NAME_TOO_LONG;
430                     break;
431                 case FileBase::E_LOOP:
432                     // Too many symbolic links encountered<p>
433                 default:
434                     ioErrorCode = IOErrorCode_GENERAL;
435                     break;
436             }
437 
438             cancelCommandExecution(
439                 ioErrorCode,
440                 generateErrorArguments(aUncPath),
441                 xEnv,
442                 rtl::OUString(
443                     RTL_CONSTASCII_USTRINGPARAM(
444                         "an error occurred during opening a directory")),
445                 xComProc);
446         }
447         else if( errorCode == TASKHANDLING_NOTCONNECTED_FOR_WRITE          ||
448                  errorCode == TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE    ||
449                  errorCode == TASKHANDLING_IOEXCEPTION_FOR_WRITE           ||
450                  errorCode == TASKHANDLING_NOTCONNECTED_FOR_PAGING         ||
451                  errorCode == TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING   ||
452                  errorCode == TASKHANDLING_IOEXCEPTION_FOR_PAGING         )
453         {
454             ioErrorCode = IOErrorCode_UNKNOWN;
455             cancelCommandExecution(
456                 ioErrorCode,
457                 generateErrorArguments(aUncPath),
458                 xEnv,
459                 rtl::OUString(
460                     RTL_CONSTASCII_USTRINGPARAM(
461                         "an error occurred writing or reading from a file")),
462                 xComProc );
463         }
464         else if( errorCode == TASKHANDLING_FILEIOERROR_FOR_NO_SPACE )
465         {
466             ioErrorCode = IOErrorCode_OUT_OF_DISK_SPACE;
467             cancelCommandExecution(
468                 ioErrorCode,
469                 generateErrorArguments(aUncPath),
470                 xEnv,
471                 rtl::OUString(
472                     RTL_CONSTASCII_USTRINGPARAM(
473                         "device full")),
474                 xComProc);
475         }
476         else if( errorCode == TASKHANDLING_FILEIOERROR_FOR_WRITE ||
477                  errorCode == TASKHANDLING_READING_FILE_FOR_PAGING )
478         {
479             switch( minorCode )
480             {
481                 case FileBase::E_INVAL:
482                     // the format of the parameters was not valid
483                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
484                     break;
485                 case FileBase::E_FBIG:
486                     // File too large
487                     ioErrorCode = IOErrorCode_CANT_WRITE;
488                     break;
489                 case FileBase::E_NOSPC:
490                     // No space left on device
491                     ioErrorCode = IOErrorCode_OUT_OF_DISK_SPACE;
492                     break;
493                 case FileBase::E_NXIO:
494                     // No such device or address
495                     ioErrorCode = IOErrorCode_INVALID_DEVICE;
496                     break;
497                 case FileBase::E_NOLINK:
498                     // Link has been severed
499                 case FileBase::E_ISDIR:
500                     // Is a directory
501                     ioErrorCode = IOErrorCode_NO_FILE;
502                     break;
503                 case FileBase::E_AGAIN:
504                     // Operation would block
505                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
506                     break;
507                 case FileBase::E_TIMEDOUT:
508                     ioErrorCode = IOErrorCode_DEVICE_NOT_READY;
509                     break;
510                 case FileBase::E_NOLCK:  // No record locks available
511                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
512                     break;
513                 case FileBase::E_IO:	 // I/O error
514                 case FileBase::E_BADF:	 // Bad file
515                 case FileBase::E_FAULT:	 // Bad address
516                 case FileBase::E_INTR:	 // function call was interrupted
517                 default:
518                     ioErrorCode = IOErrorCode_GENERAL;
519                     break;
520             }
521             cancelCommandExecution(
522                 ioErrorCode,
523                 generateErrorArguments(aUncPath),
524                 xEnv,
525                 rtl::OUString(
526                     RTL_CONSTASCII_USTRINGPARAM(
527                         "an error occurred during opening a file")),
528                 xComProc);
529         }
530         else if( errorCode == TASKHANDLING_NONAMESET_INSERT_COMMAND ||
531                  errorCode == TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND )
532         {
533             Sequence< ::rtl::OUString > aSeq( 1 );
534             aSeq[0] =
535                 ( errorCode == TASKHANDLING_NONAMESET_INSERT_COMMAND )  ?
536                 rtl::OUString::createFromAscii( "Title" )               :
537                 rtl::OUString::createFromAscii( "ContentType" );
538 
539             aAny <<= MissingPropertiesException(
540                 rtl::OUString(
541                     RTL_CONSTASCII_USTRINGPARAM(
542                         "a property is missing necessary"
543                         "to create a content")),
544                 xComProc,
545                 aSeq);
546             cancelCommandExecution(aAny,xEnv);
547         }
548         else if( errorCode == TASKHANDLING_FILESIZE_FOR_WRITE )
549         {
550             switch( minorCode )
551             {
552                 case FileBase::E_INVAL:
553                     // the format of the parameters was not valid
554                 case FileBase::E_OVERFLOW:
555                     // The resulting file offset would be a value which cannot
556                     // be represented correctly for regular files
557                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
558                     break;
559                 default:
560                     ioErrorCode = IOErrorCode_GENERAL;
561                     break;
562             }
563             cancelCommandExecution(
564                 ioErrorCode,
565                 generateErrorArguments(aUncPath),
566                 xEnv,
567                 rtl::OUString(
568                     RTL_CONSTASCII_USTRINGPARAM(
569                         "there were problems with the filesize")),
570                 xComProc);
571         }
572         else if(errorCode == TASKHANDLING_INPUTSTREAM_FOR_WRITE)
573         {
574             Reference<XInterface> xContext(xComProc,UNO_QUERY);
575             aAny <<=
576                 MissingInputStreamException(
577                     rtl::OUString(
578                         RTL_CONSTASCII_USTRINGPARAM(
579                             "the inputstream is missing necessary"
580                             "to create a content")),
581                     xContext);
582             cancelCommandExecution(aAny,xEnv);
583         }
584         else if( errorCode == TASKHANDLING_NOREPLACE_FOR_WRITE )
585             // Overwrite = false and file exists
586         {
587             NameClashException excep;
588             excep.Name = getTitle(aUncPath);
589             excep.Classification = InteractionClassification_ERROR;
590             Reference<XInterface> xContext(xComProc,UNO_QUERY);
591             excep.Context = xContext;
592             excep.Message = rtl::OUString(
593                 RTL_CONSTASCII_USTRINGPARAM(
594                     "file exists and overwrite forbidden"));
595             aAny <<= excep;
596             cancelCommandExecution( aAny,xEnv );
597         }
598         else if( errorCode == TASKHANDLING_INVALID_NAME_MKDIR )
599         {
600             InteractiveAugmentedIOException excep;
601             excep.Code = IOErrorCode_INVALID_CHARACTER;
602             PropertyValue prop;
603             prop.Name = rtl::OUString::createFromAscii("ResourceName");
604             prop.Handle = -1;
605             rtl::OUString m_aClashingName(
606                 rtl::Uri::decode(
607                     getTitle(aUncPath),
608                     rtl_UriDecodeWithCharset,
609                     RTL_TEXTENCODING_UTF8));
610             prop.Value <<= m_aClashingName;
611             Sequence<Any> seq(1);
612             seq[0] <<= prop;
613             excep.Arguments = seq;
614             excep.Classification = InteractionClassification_ERROR;
615             Reference<XInterface> xContext(xComProc,UNO_QUERY);
616             excep.Context = xContext;
617             excep.Message = rtl::OUString(
618                 RTL_CONSTASCII_USTRINGPARAM(
619                     "the name contained invalid characters"));
620             if(isHandled)
621                 throw excep;
622             else {
623                 aAny <<= excep;
624                 cancelCommandExecution( aAny,xEnv );
625             }
626 //              ioErrorCode = IOErrorCode_INVALID_CHARACTER;
627 //              cancelCommandExecution(
628 //                  ioErrorCode,
629 //                  generateErrorArguments(aUncPath),
630 //                  xEnv,
631 //                  rtl::OUString(
632 //                      RTL_CONSTASCII_USTRINGPARAM(
633 //                          "the name contained invalid characters")),
634 //                  xComProc );
635         }
636         else if( errorCode == TASKHANDLING_FOLDER_EXISTS_MKDIR )
637         {
638             NameClashException excep;
639             excep.Name = getTitle(aUncPath);
640             excep.Classification = InteractionClassification_ERROR;
641             Reference<XInterface> xContext(xComProc,UNO_QUERY);
642             excep.Context = xContext;
643             excep.Message = rtl::OUString(
644                 RTL_CONSTASCII_USTRINGPARAM(
645                     "folder exists and overwrite forbidden"));
646             if(isHandled)
647                 throw excep;
648             else {
649                 aAny <<= excep;
650                 cancelCommandExecution( aAny,xEnv );
651             }
652 //              ioErrorCode = IOErrorCode_ALREADY_EXISTING;
653 //              cancelCommandExecution(
654 //                  ioErrorCode,
655 //                  generateErrorArguments(aUncPath),
656 //                  xEnv,
657 //                  rtl::OUString(
658 //                      RTL_CONSTASCII_USTRINGPARAM(
659 //                          "the folder exists")),
660 //                  xComProc );
661         }
662         else if( errorCode == TASKHANDLING_ENSUREDIR_FOR_WRITE  ||
663                  errorCode == TASKHANDLING_CREATEDIRECTORY_MKDIR )
664         {
665             switch( minorCode )
666             {
667             case FileBase::E_ACCES:
668                 ioErrorCode = IOErrorCode_ACCESS_DENIED;
669                 break;
670             case FileBase::E_ROFS:
671                 ioErrorCode = IOErrorCode_WRITE_PROTECTED;
672                 break;
673             case FileBase::E_NAMETOOLONG:
674                 ioErrorCode = IOErrorCode_NAME_TOO_LONG;
675                 break;
676             default:
677                 ioErrorCode = IOErrorCode_NOT_EXISTING_PATH;
678                 break;
679             }
680             cancelCommandExecution(
681                 ioErrorCode,
682                 generateErrorArguments(getParentName(aUncPath)),
683                 //TODO! ok to supply physical URL to getParentName()?
684                 xEnv,
685                 rtl::OUString(
686                     RTL_CONSTASCII_USTRINGPARAM(
687                         "a folder could not be created")),
688                 xComProc  );
689         }
690         else if( errorCode == TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE  ||
691                  errorCode == TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE       ||
692                  errorCode == TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE )
693         {
694             switch( minorCode )
695             {
696                 case FileBase::E_INVAL:		    // the format of the parameters was not valid
697                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
698                     break;
699                 case FileBase::E_NOMEM:		    // not enough memory for allocating structures
700                     ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
701                     break;
702                 case FileBase::E_ROFS: // #i4735# handle ROFS transparently as ACCESS_DENIED
703                 case FileBase::E_ACCES:		    // permission denied
704                     ioErrorCode = IOErrorCode_ACCESS_DENIED;
705                     break;
706                 case FileBase::E_MFILE:		    // too many open files used by the process
707                 case FileBase::E_NFILE:		    // too many open files in the system
708                     ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES;
709                     break;
710                 case FileBase::E_NOLINK:		// Link has been severed
711                 case FileBase::E_NOENT:		    // No such file or directory
712                     ioErrorCode = IOErrorCode_NOT_EXISTING;
713                     break;
714                 case FileBase::E_NAMETOOLONG:	// File name too long
715                     ioErrorCode = IOErrorCode_NAME_TOO_LONG;
716                     break;
717                 case FileBase::E_NOTDIR:	 // A component of the path prefix of path is not a directory
718                     ioErrorCode = IOErrorCode_NOT_EXISTING_PATH;
719                     break;
720                 case FileBase::E_LOOP:			// Too many symbolic links encountered
721                 case FileBase::E_IO:			// I/O error
722                 case FileBase::E_MULTIHOP:		// Multihop attempted
723                 case FileBase::E_FAULT:		    // Bad address
724                 case FileBase::E_INTR:			// function call was interrupted
725                 case FileBase::E_NOSYS:         // Function not implemented
726                 case FileBase::E_NOSPC:		    // No space left on device
727                 case FileBase::E_NXIO:			// No such device or address
728                 case FileBase::E_OVERFLOW:		// Value too large for defined data type
729                 case FileBase::E_BADF:			// Invalid oslDirectoryItem parameter
730                 default:
731                     ioErrorCode = IOErrorCode_GENERAL;
732                     break;
733             }
734             cancelCommandExecution(
735                 ioErrorCode,
736                 generateErrorArguments(aUncPath),
737                 xEnv,
738                 rtl::OUString(
739                     RTL_CONSTASCII_USTRINGPARAM(
740                         "a file status object could not be filled")),
741                 xComProc  );
742         }
743         else if( errorCode == TASKHANDLING_DELETEFILE_FOR_REMOVE  ||
744                  errorCode == TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE )
745         {
746             switch( minorCode )
747             {
748                 case FileBase::E_INVAL:		    // the format of the parameters was not valid
749                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
750                     break;
751                 case FileBase::E_NOMEM:		    // not enough memory for allocating structures
752                     ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
753                     break;
754                 case FileBase::E_ACCES:		    // Permission denied
755                     ioErrorCode = IOErrorCode_ACCESS_DENIED;
756                     break;
757                 case FileBase::E_PERM:			// Operation not permitted
758                     ioErrorCode = IOErrorCode_NOT_SUPPORTED;
759                     break;
760                 case FileBase::E_NAMETOOLONG:	// File name too long
761                     ioErrorCode = IOErrorCode_NAME_TOO_LONG;
762                     break;
763                 case FileBase::E_NOLINK:		// Link has been severed
764                 case FileBase::E_NOENT:	        // No such file or directory
765                     ioErrorCode = IOErrorCode_NOT_EXISTING;
766                     break;
767                 case FileBase::E_ISDIR:		    // Is a directory
768                 case FileBase::E_ROFS:			// Read-only file system
769                     ioErrorCode = IOErrorCode_NOT_SUPPORTED;
770                     break;
771                 case FileBase::E_BUSY:			// Device or resource busy
772                     ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
773                     break;
774                 case FileBase::E_FAULT:		    // Bad address
775                 case FileBase::E_LOOP:			// Too many symbolic links encountered
776                 case FileBase::E_IO:			// I/O error
777                 case FileBase::E_INTR:			// function call was interrupted
778                 case FileBase::E_MULTIHOP:		// Multihop attempted
779                 default:
780                     ioErrorCode = IOErrorCode_GENERAL;
781                     break;
782             }
783             cancelCommandExecution(
784                 ioErrorCode,
785                 generateErrorArguments(aUncPath),
786                 xEnv,
787                 rtl::OUString(
788                     RTL_CONSTASCII_USTRINGPARAM(
789                         "a file or directory could not be deleted")),
790                 xComProc );
791         }
792         else if( errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCE         ||
793                  errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT     ||
794                  errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCE         ||
795                  errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT     ||
796                  errorCode == TASKHANDLING_TRANSFER_DESTFILETYPE           ||
797                  errorCode == TASKHANDLING_FILETYPE_FOR_REMOVE             ||
798                  errorCode == TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE   ||
799                  errorCode == TASKHANDLING_TRANSFER_INVALIDURL )
800         {
801             rtl::OUString aMsg;
802             switch( minorCode )
803             {
804                 case FileBase::E_NOENT:	        // No such file or directory
805                     if ( errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCE         ||
806                          errorCode == TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT     ||
807                          errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCE         ||
808                          errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT )
809                     {
810                         ioErrorCode = IOErrorCode_NOT_EXISTING;
811                         aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
812                             "source file/folder does not exist"));
813                         break;
814                     }
815                     else
816                     {
817                         ioErrorCode = IOErrorCode_GENERAL;
818                         aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
819                             "a general error during transfer command"));
820                     break;
821                     }
822                 default:
823                     ioErrorCode = IOErrorCode_GENERAL;
824                     aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
825                         "a general error during transfer command"));
826                     break;
827             }
828             cancelCommandExecution(
829                 ioErrorCode,
830                 generateErrorArguments(aUncPath),
831                 xEnv,
832                 aMsg,
833                 xComProc );
834         }
835         else if( errorCode == TASKHANDLING_TRANSFER_ACCESSINGROOT )
836         {
837             ioErrorCode = IOErrorCode_WRITE_PROTECTED;
838             cancelCommandExecution(
839                 ioErrorCode,
840                 generateErrorArguments(aUncPath),
841                 xEnv,
842                 rtl::OUString(
843                     RTL_CONSTASCII_USTRINGPARAM(
844                         "accessing the root during transfer")),
845                 xComProc );
846         }
847         else if( errorCode == TASKHANDLING_TRANSFER_INVALIDSCHEME )
848         {
849             Reference<XInterface> xContext(xComProc,UNO_QUERY);
850 
851             aAny <<=
852                 InteractiveBadTransferURLException(
853                     rtl::OUString(
854                         RTL_CONSTASCII_USTRINGPARAM(
855                             "bad transfer url")),
856                     xContext);
857             cancelCommandExecution( aAny,xEnv );
858         }
859         else if( errorCode == TASKHANDLING_OVERWRITE_FOR_MOVE      ||
860                  errorCode == TASKHANDLING_OVERWRITE_FOR_COPY      ||
861                  errorCode == TASKHANDLING_NAMECLASHMOVE_FOR_MOVE  ||
862                  errorCode == TASKHANDLING_NAMECLASHMOVE_FOR_COPY  ||
863                  errorCode == TASKHANDLING_KEEPERROR_FOR_MOVE      ||
864                  errorCode == TASKHANDLING_KEEPERROR_FOR_COPY      ||
865                  errorCode == TASKHANDLING_RENAME_FOR_MOVE         ||
866                  errorCode == TASKHANDLING_RENAME_FOR_COPY         ||
867                  errorCode == TASKHANDLING_RENAMEMOVE_FOR_MOVE     ||
868                  errorCode == TASKHANDLING_RENAMEMOVE_FOR_COPY    )
869         {
870             rtl::OUString aMsg(RTL_CONSTASCII_USTRINGPARAM(
871                         "general error during transfer"));
872 
873             switch( minorCode )
874             {
875                 case FileBase::E_EXIST:
876                     ioErrorCode = IOErrorCode_ALREADY_EXISTING;
877                     break;
878                 case FileBase::E_INVAL:		    // the format of the parameters was not valid
879                     ioErrorCode = IOErrorCode_INVALID_PARAMETER;
880                     break;
881                 case FileBase::E_NOMEM:		    // not enough memory for allocating structures
882                     ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
883                     break;
884                 case FileBase::E_ACCES:		    // Permission denied
885                     ioErrorCode = IOErrorCode_ACCESS_DENIED;
886                     break;
887                 case FileBase::E_PERM:		    // Operation not permitted
888                     ioErrorCode = IOErrorCode_NOT_SUPPORTED;
889                     break;
890                 case FileBase::E_NAMETOOLONG:	// File name too long
891                     ioErrorCode = IOErrorCode_NAME_TOO_LONG;
892                     break;
893                 case FileBase::E_NOENT:         // No such file or directory
894                     ioErrorCode = IOErrorCode_NOT_EXISTING;
895                     aMsg = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
896                         "file/folder does not exist"));
897                     break;
898                 case FileBase::E_ROFS:			// Read-only file system<p>
899                     ioErrorCode = IOErrorCode_NOT_EXISTING;
900                     break;
901                 default:
902                     ioErrorCode = IOErrorCode_GENERAL;
903                     break;
904             }
905             cancelCommandExecution(
906                 ioErrorCode,
907                 generateErrorArguments(aUncPath),
908                 xEnv,
909                 aMsg,
910                 xComProc );
911         }
912         else if( errorCode == TASKHANDLING_NAMECLASH_FOR_COPY   ||
913                  errorCode == TASKHANDLING_NAMECLASH_FOR_MOVE )
914         {
915             NameClashException excep;
916             excep.Name = getTitle(aUncPath);
917             excep.Classification = InteractionClassification_ERROR;
918             Reference<XInterface> xContext(xComProc,UNO_QUERY);
919             excep.Context = xContext;
920             excep.Message = rtl::OUString(
921                 RTL_CONSTASCII_USTRINGPARAM(
922                     "name clash during copy or move"));
923             aAny <<= excep;
924 
925             cancelCommandExecution(aAny,xEnv);
926         }
927         else if( errorCode == TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE   ||
928                  errorCode == TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY )
929         {
930             Reference<XInterface> xContext(
931                 xComProc,UNO_QUERY);
932             UnsupportedNameClashException excep;
933             excep.NameClash = minorCode;
934             excep.Context = xContext;
935             excep.Message = rtl::OUString(
936                 RTL_CONSTASCII_USTRINGPARAM(
937                     "name clash value not supported during copy or move"));
938 
939             aAny <<= excep;
940             cancelCommandExecution(aAny,xEnv);
941         }
942         else
943         {
944             // case TASKHANDLER_NO_ERROR:
945             return;
946         }
947     }
948 
949 
950 }   // end namespace fileaccess
951