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