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 <sal/config.h>
21
22#include <string_view>
23
24#include "filglob.hxx"
25#include "filerror.hxx"
26#include "bc.hxx"
27#include <osl/file.hxx>
29#include <com/sun/star/ucb/UnsupportedCommandException.hpp>
30#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
31#include <com/sun/star/lang/IllegalArgumentException.hpp>
32#include <com/sun/star/ucb/IOErrorCode.hpp>
33#include <com/sun/star/ucb/MissingPropertiesException.hpp>
34#include <com/sun/star/ucb/MissingInputStreamException.hpp>
35#include <com/sun/star/ucb/NameClashException.hpp>
36#include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
37#include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
38#include <com/sun/star/beans/PropertyState.hpp>
39#include <com/sun/star/beans/PropertyValue.hpp>
40#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
41#include <com/sun/star/uno/Any.hxx>
42#include <com/sun/star/uno/Sequence.hxx>
43#include <o3tl/string_view.hxx>
44#include <osl/diagnose.h>
45#include <rtl/uri.hxx>
46#include <rtl/ustring.hxx>
47#include <sal/types.h>
48
49using namespace ucbhelper;
50using namespace osl;
51using namespace ::com::sun::star;
52using namespace com::sun::star::task;
53using namespace com::sun::star::beans;
54using namespace com::sun::star::lang;
55using namespace com::sun::star::uno;
56using namespace com::sun::star::ucb;
57
58namespace {
59
60 Sequence< Any > generateErrorArguments(
61 OUString const & rPhysicalUrl)
62 {
63 OUString aResourceName;
64 OUString aResourceType;
65 bool bRemovable = false;
66 bool bResourceName = false;
67 bool bResourceType = false;
68 bool bRemoveProperty = false;
69
70 if (osl::FileBase::getSystemPathFromFileURL(
71 rPhysicalUrl,
72 aResourceName)
73 == osl::FileBase::E_None)
74 bResourceName = true;
75
76 // The resource types "folder" (i.e., directory) and
77 // "volume" seem to be
78 // the most interesting when producing meaningful error messages:
79 osl::DirectoryItem aItem;
80 if (osl::DirectoryItem::get(rPhysicalUrl, aItem) ==
81 osl::FileBase::E_None)
82 {
83 osl::FileStatus aStatus( osl_FileStatus_Mask_Type );
84 if (aItem.getFileStatus(aStatus) == osl::FileBase::E_None)
85 switch (aStatus.getFileType())
86 {
87 case osl::FileStatus::Directory:
88 aResourceType = "folder";
89 bResourceType = true;
90 break;
91
92 case osl::FileStatus::Volume:
93 {
94 aResourceType = "volume";
95 bResourceType = true;
96 osl::VolumeInfo aVolumeInfo(
97 osl_VolumeInfo_Mask_Attributes );
98 if( osl::Directory::getVolumeInfo(
99 rPhysicalUrl,aVolumeInfo ) ==
100 osl::FileBase::E_None )
101 {
102 bRemovable = aVolumeInfo.getRemoveableFlag();
103 bRemoveProperty = true;
104 }
105 }
106 break;
107 case osl::FileStatus::Regular:
108 case osl::FileStatus::Fifo:
109 case osl::FileStatus::Socket:
110 case osl::FileStatus::Link:
111 case osl::FileStatus::Special:
112 case osl::FileStatus::Unknown:
113 // do nothing for now
114 break;
115 }
116 }
117
119 (bResourceName ? 1 : 0) +
120 (bResourceType ? 1 : 0) +
121 (bRemoveProperty ? 1 : 0) );
122 auto pArguments = aArguments.getArray();
123 sal_Int32 i = 0;
124 pArguments[i++]
125 <<= PropertyValue("Uri",
126 -1,
127 Any(rPhysicalUrl),
128 PropertyState_DIRECT_VALUE);
129 if (bResourceName)
130 pArguments[i++]
131 <<= PropertyValue("ResourceName",
132 -1,
133 Any(aResourceName),
134 PropertyState_DIRECT_VALUE);
135 if (bResourceType)
136 pArguments[i++]
137 <<= PropertyValue("ResourceType",
138 -1,
139 Any(aResourceType),
140 PropertyState_DIRECT_VALUE);
141 if (bRemoveProperty)
142 pArguments[i++]
143 <<= PropertyValue("Removable",
144 -1,
145 Any(bRemovable),
146 PropertyState_DIRECT_VALUE);
147
148 return aArguments;
149 }
150}
151
152
153namespace fileaccess {
154
155
156 bool isChild( std::u16string_view srcUnqPath,
157 std::u16string_view dstUnqPath )
158 {
159 static const sal_Unicode slash = '/';
160 // Simple lexical comparison
161 size_t srcL = srcUnqPath.size();
162 size_t dstL = dstUnqPath.size();
163
164 return (
165 ( srcUnqPath == dstUnqPath )
166 ||
167 ( ( dstL > srcL )
168 &&
169 o3tl::starts_with(dstUnqPath, srcUnqPath)
170 &&
171 ( dstUnqPath[ srcL ] == slash ) )
172 );
173 }
174
175
176 OUString newName(
177 std::u16string_view aNewPrefix,
178 std::u16string_view aOldPrefix,
179 std::u16string_view old_Name )
180 {
181 size_t srcL = aOldPrefix.size();
182
183 return OUString::Concat(aNewPrefix) + old_Name.substr( srcL );
184 }
185
186
187 std::u16string_view getTitle( std::u16string_view aPath )
188 {
189 size_t lastIndex = aPath.rfind( '/' );
190 return aPath.substr( lastIndex + 1 );
191 }
192
193
194 OUString getParentName( std::u16string_view aFileName )
195 {
196 size_t lastIndex = aFileName.rfind( '/' );
197 OUString aParent( aFileName.substr( 0,lastIndex ) );
198
199 if( aParent.endsWith(":") && aParent.getLength() == 6 )
200 aParent += "/";
201
202 if ( aParent == "file://" )
203 aParent = "file:///";
204
205 return aParent;
206 }
207
208
209 osl::FileBase::RC osl_File_copy( const OUString& strPath,
210 const OUString& strDestPath,
211 bool test )
212 {
213 if( test )
214 {
215 osl::DirectoryItem aItem;
216 if( osl::DirectoryItem::get( strDestPath,aItem ) != osl::FileBase:: E_NOENT )
217 return osl::FileBase::E_EXIST;
218 }
219
220 return osl::File::copy( strPath,strDestPath );
221 }
222
223
224 osl::FileBase::RC osl_File_move( const OUString& strPath,
225 const OUString& strDestPath,
226 bool test )
227 {
228 if( test )
229 {
230 osl::DirectoryItem aItem;
231 if( osl::DirectoryItem::get( strDestPath,aItem ) != osl::FileBase:: E_NOENT )
232 return osl::FileBase::E_EXIST;
233 }
234
235 return osl::File::move( strPath,strDestPath );
236 }
237
239 sal_Int32 errorCode,
240 sal_Int32 minorCode,
242 const OUString& aUncPath,
243 BaseContent* pContent,
244 bool isHandled )
245 {
246 Reference<XCommandProcessor> xComProc(pContent);
247 Any aAny;
248 IOErrorCode ioErrorCode;
249
250 if( errorCode == TASKHANDLER_UNSUPPORTED_COMMAND )
251 {
252 aAny <<= UnsupportedCommandException( OSL_LOG_PREFIX );
253 cancelCommandExecution( aAny,xEnv );
254 }
255 else if( errorCode == TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT ||
262 {
263 IllegalArgumentException excep;
264 excep.ArgumentPosition = 0;
265 cancelCommandExecution(Any(excep), xEnv);
266 }
267 else if( errorCode == TASKHANDLING_UNSUPPORTED_OPEN_MODE )
268 {
269 UnsupportedOpenModeException excep;
270 excep.Mode = sal::static_int_cast< sal_Int16 >(minorCode);
271 cancelCommandExecution( Any(excep),xEnv );
272 }
273 else if(errorCode == TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND ||
276 {
277 // What to do here?
278 }
279 else if(
280 // error in opening file
282 // error in opening file
284 // error in opening file
285 errorCode == TASKHANDLING_OPEN_FOR_STREAM ||
286 // error in opening file
288 // error in opening file
290 {
291 switch( minorCode )
292 {
293 case FileBase::E_NAMETOOLONG:
294 // pathname was too long
295 ioErrorCode = IOErrorCode_NAME_TOO_LONG;
296 break;
297 case FileBase::E_NXIO:
298 // No such device or address
299 case FileBase::E_NODEV:
300 // No such device
301 ioErrorCode = IOErrorCode_INVALID_DEVICE;
302 break;
303 case FileBase::E_NOTDIR:
304 ioErrorCode = IOErrorCode_NOT_EXISTING_PATH;
305 break;
306 case FileBase::E_NOENT:
307 // No such file or directory
308 ioErrorCode = IOErrorCode_NOT_EXISTING;
309 break;
310 case FileBase::E_ROFS:
311 // #i4735# handle ROFS transparently as ACCESS_DENIED
312 case FileBase::E_ACCES:
313 case FileBase::E_PERM:
314 // permission denied<P>
315 ioErrorCode = IOErrorCode_ACCESS_DENIED;
316 break;
317 case FileBase::E_ISDIR:
318 // Is a directory<p>
319 ioErrorCode = IOErrorCode_NO_FILE;
320 break;
321 case FileBase::E_NOTREADY:
322 ioErrorCode = IOErrorCode_DEVICE_NOT_READY;
323 break;
324 case FileBase::E_MFILE:
325 // too many open files used by the process
326 case FileBase::E_NFILE:
327 // too many open files in the system
328 ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES;
329 break;
330 case FileBase::E_INVAL:
331 // the format of the parameters was not valid
332 ioErrorCode = IOErrorCode_INVALID_PARAMETER;
333 break;
334 case FileBase::E_NOMEM:
335 // not enough memory for allocating structures
336 ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
337 break;
338 case FileBase::E_BUSY:
339 // Text file busy
340 ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
341 break;
342 case FileBase::E_AGAIN:
343 // Operation would block
344 ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
345 break;
346 case FileBase::E_NOLCK: // No record locks available
347 ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
348 break;
349 case FileBase::E_NOSYS:
350 ioErrorCode = IOErrorCode_NOT_SUPPORTED;
351 break;
352 case FileBase::E_FAULT: // Bad address
353 case FileBase::E_LOOP: // Too many symbolic links encountered
354 case FileBase::E_NOSPC: // No space left on device
355 case FileBase::E_INTR: // function call was interrupted
356 case FileBase::E_IO: // I/O error
357 case FileBase::E_MULTIHOP: // Multihop attempted
358 case FileBase::E_NOLINK: // Link has been severed
359 default:
360 ioErrorCode = IOErrorCode_GENERAL;
361 break;
362 }
363
366 generateErrorArguments(aUncPath),
367 xEnv,
368 "an error occurred during file opening",
369 xComProc);
370 }
371 else if( errorCode == TASKHANDLING_OPEN_FOR_DIRECTORYLISTING ||
373 {
374 switch( minorCode )
375 {
376 case FileBase::E_INVAL:
377 // the format of the parameters was not valid
378 ioErrorCode = IOErrorCode_INVALID_PARAMETER;
379 break;
380 case FileBase::E_NOENT:
381 // the specified path doesn't exist
382 ioErrorCode = IOErrorCode_NOT_EXISTING;
383 break;
384 case FileBase::E_NOTDIR:
385 // the specified path is not a directory
386 ioErrorCode = IOErrorCode_NO_DIRECTORY;
387 break;
388 case FileBase::E_NOMEM:
389 // not enough memory for allocating structures
390 ioErrorCode = IOErrorCode_OUT_OF_MEMORY;
391 break;
392 case FileBase::E_ROFS:
393 // #i4735# handle ROFS transparently as ACCESS_DENIED
394 case FileBase::E_ACCES: // permission denied
395 ioErrorCode = IOErrorCode_ACCESS_DENIED;
396 break;
397 case FileBase::E_NOTREADY:
398 ioErrorCode = IOErrorCode_DEVICE_NOT_READY;
399 break;
400 case FileBase::E_MFILE:
401 // too many open files used by the process
402 case FileBase::E_NFILE:
403 // too many open files in the system
404 ioErrorCode = IOErrorCode_OUT_OF_FILE_HANDLES;
405 break;
406 case FileBase::E_NAMETOOLONG:
407 // File name too long
408 ioErrorCode = IOErrorCode_NAME_TOO_LONG;
409 break;
410 case FileBase::E_LOOP:
411 // Too many symbolic links encountered<p>
412 default:
413 ioErrorCode = IOErrorCode_GENERAL;
414 break;
415 }
416
419 generateErrorArguments(aUncPath),
420 xEnv,
421 "an error occurred during opening a directory",
422 xComProc);
423 }
424 else if( errorCode == TASKHANDLING_NOTCONNECTED_FOR_WRITE ||
430 {
431 ioErrorCode = IOErrorCode_UNKNOWN;
434 generateErrorArguments(aUncPath),
435 xEnv,
436 "an error occurred writing or reading from a file",
437 xComProc );
438 }
439 else if( errorCode == TASKHANDLING_FILEIOERROR_FOR_NO_SPACE )
440 {
441 ioErrorCode = IOErrorCode_OUT_OF_DISK_SPACE;
444 generateErrorArguments(aUncPath),
445 xEnv,
446 "device full",
447 xComProc);
448 }
449 else if( errorCode == TASKHANDLING_FILEIOERROR_FOR_WRITE ||
451 {
452 switch( minorCode )
453 {
454 case FileBase::E_INVAL:
455 // the format of the parameters was not valid
456 ioErrorCode = IOErrorCode_INVALID_PARAMETER;
457 break;
458 case FileBase::E_FBIG:
459 // File too large
460 ioErrorCode = IOErrorCode_CANT_WRITE;
461 break;
462 case FileBase::E_NOSPC:
463 // No space left on device
464 ioErrorCode = IOErrorCode_OUT_OF_DISK_SPACE;
465 break;
466 case FileBase::E_NXIO:
467 // No such device or address
468 ioErrorCode = IOErrorCode_INVALID_DEVICE;
469 break;
470 case FileBase::E_NOLINK:
471 // Link has been severed
472 case FileBase::E_ISDIR:
473 // Is a directory
474 ioErrorCode = IOErrorCode_NO_FILE;
475 break;
476 case FileBase::E_AGAIN:
477 // Operation would block
478 ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
479 break;
480 case FileBase::E_TIMEDOUT:
481 ioErrorCode = IOErrorCode_DEVICE_NOT_READY;
482 break;
483 case FileBase::E_NOLCK: // No record locks available
484 ioErrorCode = IOErrorCode_LOCKING_VIOLATION;
485 break;
486 case FileBase::E_IO: // I/O error
487 case FileBase::E_BADF: // Bad file
488 case FileBase::E_FAULT: // Bad address
489 case FileBase::E_INTR: // function call was interrupted
490 default:
491 ioErrorCode = IOErrorCode_GENERAL;
492 break;
493 }
496 generateErrorArguments(aUncPath),
497 xEnv,
498 "an error occurred during opening a file",
499 xComProc);
500 }
501 else if( errorCode == TASKHANDLING_NONAMESET_INSERT_COMMAND ||
503 {
504 static constexpr OUStringLiteral sTitle = u"Title";
505 static constexpr OUStringLiteral sContentType = u"ContentType";
507 ? OUString(sTitle)
508 : OUString(sContentType) };
509
510 aAny <<= MissingPropertiesException(
511 "a property is missing, necessary to create a content",
512 xComProc,
513 aSeq);
514 cancelCommandExecution(aAny,xEnv);
515 }
516 else if( errorCode == TASKHANDLING_FILESIZE_FOR_WRITE )
517 {
518 switch( minorCode )
519 {
520 case FileBase::E_INVAL:
521 // the format of the parameters was not valid
522 case FileBase::E_OVERFLOW:
523 // The resulting file offset would be a value which cannot
524 // be represented correctly for regular files
525 ioErrorCode = IOErrorCode_INVALID_PARAMETER;
526 break;
527 default:
528 ioErrorCode = IOErrorCode_GENERAL;
529 break;
530 }
533 generateErrorArguments(aUncPath),
534 xEnv,
535 "there were problems with the filesize",
536 xComProc);
537 }
538 else if(errorCode == TASKHANDLING_INPUTSTREAM_FOR_WRITE)
539 {
540 aAny <<=
541 MissingInputStreamException(
542 "the inputstream is missing, necessary to create a content",
543 xComProc);
544 cancelCommandExecution(aAny,xEnv);
545 }
546 else if( errorCode == TASKHANDLING_NOREPLACE_FOR_WRITE )
547 // Overwrite = false and file exists
548 {
549 NameClashException excep;
550 excep.Name = getTitle(aUncPath);
551 excep.Classification = InteractionClassification_ERROR;
552 excep.Context = Reference<XInterface>( xComProc, UNO_QUERY );
553 excep.Message = "file exists and overwrite forbidden";
554 cancelCommandExecution( Any(excep), xEnv );
555 }
556 else if( errorCode == TASKHANDLING_INVALID_NAME_MKDIR )
557 {
558 InteractiveAugmentedIOException excep;
559 excep.Code = IOErrorCode_INVALID_CHARACTER;
560 PropertyValue prop;
561 prop.Name = "ResourceName";
562 prop.Handle = -1;
563 OUString aClashingName(
564 rtl::Uri::decode(
565 OUString(getTitle(aUncPath)),
566 rtl_UriDecodeWithCharset,
567 RTL_TEXTENCODING_UTF8));
568 prop.Value <<= aClashingName;
569 excep.Arguments = { Any(prop) };
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 }
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 }
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 }
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 ||
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 }
761 generateErrorArguments(aUncPath),
762 xEnv,
763 aMsg,
764 xComProc );
765 }
766 else if( errorCode == TASKHANDLING_TRANSFER_ACCESSINGROOT )
767 {
768 ioErrorCode = IOErrorCode_WRITE_PROTECTED;
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 ||
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 }
830 generateErrorArguments(aUncPath),
831 xEnv,
832 aMsg,
833 xComProc );
834 }
835 else if( errorCode == TASKHANDLING_NAMECLASH_FOR_COPY ||
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: */
float u
#define TASKHANDLING_FILETYPE_FOR_REMOVE
Definition: filerror.hxx:75
#define TASKHANDLING_FOLDER_EXISTS_MKDIR
Definition: filerror.hxx:66
#define TASKHANDLING_CREATEDIRECTORY_MKDIR
Definition: filerror.hxx:68
#define TASKHANDLING_TRANSFER_INVALIDURL
Definition: filerror.hxx:81
#define TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE
Definition: filerror.hxx:76
#define TASKHANDLING_TRANSFER_BY_COPY_SOURCE
Definition: filerror.hxx:93
#define TASKHANDLING_IOEXCEPTION_FOR_WRITE
Definition: filerror.hxx:58
#define TASKHANDLING_FILEIOERROR_FOR_WRITE
Definition: filerror.hxx:59
#define TASKHANDLING_TRANSFER_BY_MOVE_SOURCE
Definition: filerror.hxx:83
#define TASKHANDLING_UNSUPPORTED_OPEN_MODE
Definition: filerror.hxx:35
#define TASKHANDLING_OPEN_FOR_DIRECTORYLISTING
Definition: filerror.hxx:48
#define TASKHANDLING_OPEN_FILE_FOR_PAGING
Definition: filerror.hxx:40
#define TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE
Definition: filerror.hxx:77
#define TASKHANDLING_NAMECLASH_FOR_COPY
Definition: filerror.hxx:99
#define TASKHANDLING_INPUTSTREAM_FOR_WRITE
Definition: filerror.hxx:62
#define TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE
Definition: filerror.hxx:74
#define TASKHANDLING_KEEPERROR_FOR_MOVE
Definition: filerror.hxx:85
#define TASKHANDLING_WRONG_OPEN_ARGUMENT
Definition: filerror.hxx:30
#define TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT
Definition: filerror.hxx:29
#define TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT
Definition: filerror.hxx:94
#define TASKHANDLING_READING_FILE_FOR_PAGING
Definition: filerror.hxx:44
#define TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT
Definition: filerror.hxx:28
#define TASKHANDLING_NAMECLASHMOVE_FOR_COPY
Definition: filerror.hxx:100
#define TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE
Definition: filerror.hxx:71
#define TASKHANDLING_NAMECLASHMOVE_FOR_MOVE
Definition: filerror.hxx:87
#define TASKHANDLING_WRONG_DELETE_ARGUMENT
Definition: filerror.hxx:31
#define TASKHANDLING_RENAMEMOVE_FOR_MOVE
Definition: filerror.hxx:91
#define TASKHANDLING_OVERWRITE_FOR_COPY
Definition: filerror.hxx:96
#define TASKHANDLING_OPEN_FOR_STREAM
Definition: filerror.hxx:47
#define TASKHANDLING_DELETEFILE_FOR_REMOVE
Definition: filerror.hxx:73
#define TASKHANDLING_WRONG_TRANSFER_ARGUMENT
Definition: filerror.hxx:32
#define TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE
Definition: filerror.hxx:70
#define TASKHANDLING_RENAME_FOR_MOVE
Definition: filerror.hxx:90
#define TASKHANDLING_NONAMESET_INSERT_COMMAND
Definition: filerror.hxx:51
#define TASKHANDLING_WRONG_INSERT_ARGUMENT
Definition: filerror.hxx:33
#define TASKHANDLING_RENAME_FOR_COPY
Definition: filerror.hxx:97
#define TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND
Definition: filerror.hxx:37
#define TASKHANDLER_UNSUPPORTED_COMMAND
Definition: filerror.hxx:27
#define TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND
Definition: filerror.hxx:50
#define TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT
Definition: filerror.hxx:84
#define TASKHANDLING_ENSUREDIR_FOR_WRITE
Definition: filerror.hxx:64
#define TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND
Definition: filerror.hxx:52
#define TASKHANDLING_RENAMEMOVE_FOR_COPY
Definition: filerror.hxx:98
#define TASKHANDLING_TRANSFER_INVALIDSCHEME
Definition: filerror.hxx:80
#define TASKHANDLING_NOREPLACE_FOR_WRITE
Definition: filerror.hxx:63
#define TASKHANDLING_NOTCONNECTED_FOR_WRITE
Definition: filerror.hxx:56
#define TASKHANDLING_OVERWRITE_FOR_MOVE
Definition: filerror.hxx:89
#define TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE
Definition: filerror.hxx:54
#define TASKHANDLING_KEEPERROR_FOR_COPY
Definition: filerror.hxx:95
#define TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND
Definition: filerror.hxx:38
#define TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE
Definition: filerror.hxx:57
#define TASKHANDLING_OPEN_FOR_INPUTSTREAM
Definition: filerror.hxx:46
#define TASKHANDLING_INVALID_NAME_MKDIR
Definition: filerror.hxx:67
#define TASKHANDLING_FILEIOERROR_FOR_NO_SPACE
Definition: filerror.hxx:60
#define TASKHANDLING_TRANSFER_DESTFILETYPE
Definition: filerror.hxx:82
#define TASKHANDLING_NAMECLASH_FOR_MOVE
Definition: filerror.hxx:86
#define TASKHANDLING_TRANSFER_ACCESSINGROOT
Definition: filerror.hxx:79
#define TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING
Definition: filerror.hxx:42
#define TASKHANDLING_NOTCONNECTED_FOR_PAGING
Definition: filerror.hxx:41
#define TASKHANDLING_OPENDIRECTORY_FOR_REMOVE
Definition: filerror.hxx:72
#define TASKHANDLING_IOEXCEPTION_FOR_PAGING
Definition: filerror.hxx:43
#define TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE
Definition: filerror.hxx:88
#define TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT
Definition: filerror.hxx:34
#define TASKHANDLING_NO_OPEN_FILE_FOR_WRITE
Definition: filerror.hxx:55
#define TASKHANDLING_FILESIZE_FOR_WRITE
Definition: filerror.hxx:61
#define TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY
Definition: filerror.hxx:101
Sequence< PropertyValue > aArguments
Sequence< sal_Int8 > aSeq
OUString getParentName(std::u16string_view aFileName)
Definition: filglob.cxx:194
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:224
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:209
void throw_handler(sal_Int32 errorCode, sal_Int32 minorCode, const Reference< XCommandEnvironment > &xEnv, const OUString &aUncPath, BaseContent *pContent, bool isHandled)
Definition: filglob.cxx:238
OUString newName(std::u16string_view aNewPrefix, std::u16string_view aOldPrefix, std::u16string_view old_Name)
Definition: filglob.cxx:176
bool isChild(std::u16string_view srcUnqPath, std::u16string_view dstUnqPath)
Definition: filglob.cxx:156
std::u16string_view getTitle(std::u16string_view aPath)
Definition: filglob.cxx:187
int i
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
UCBHELPER_DLLPUBLIC void cancelCommandExecution(const css::uno::Any &rException, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
sal_uInt16 sal_Unicode
IOErrorCode ioErrorCode