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