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