Branch libreoffice-5-0-4
[LibreOffice.git] / include / osl / file.hxx
blob19489484cb3b33f3df1a0ca4e261f1c97209eb8d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OSL_FILE_HXX
21 #define INCLUDED_OSL_FILE_HXX
23 #include <sal/config.h>
25 #include <string.h>
27 #include <cassert>
29 #include <sal/log.hxx>
30 #include <osl/time.h>
31 #include <rtl/ustring.hxx>
33 #include <osl/file.h>
34 #include <osl/diagnose.h>
35 #include <rtl/byteseq.hxx>
37 #include <stdio.h>
39 namespace osl
44 /** Base class for all File System specific objects.
46 @see Directory
47 @see DirectoryItem
48 @see File
51 class FileBase
53 public:
55 enum RC {
56 E_None = osl_File_E_None,
57 E_PERM = osl_File_E_PERM,
58 E_NOENT = osl_File_E_NOENT,
59 E_SRCH = osl_File_E_SRCH,
60 E_INTR = osl_File_E_INTR,
61 E_IO = osl_File_E_IO,
62 E_NXIO = osl_File_E_NXIO,
63 E_2BIG = osl_File_E_2BIG,
64 E_NOEXEC = osl_File_E_NOEXEC,
65 E_BADF = osl_File_E_BADF,
66 E_CHILD = osl_File_E_CHILD,
67 E_AGAIN = osl_File_E_AGAIN,
68 E_NOMEM = osl_File_E_NOMEM,
69 E_ACCES = osl_File_E_ACCES,
70 E_FAULT = osl_File_E_FAULT,
71 E_BUSY = osl_File_E_BUSY,
72 E_EXIST = osl_File_E_EXIST,
73 E_XDEV = osl_File_E_XDEV,
74 E_NODEV = osl_File_E_NODEV,
75 E_NOTDIR = osl_File_E_NOTDIR,
76 E_ISDIR = osl_File_E_ISDIR,
77 E_INVAL = osl_File_E_INVAL,
78 E_NFILE = osl_File_E_NFILE,
79 E_MFILE = osl_File_E_MFILE,
80 E_NOTTY = osl_File_E_NOTTY,
81 E_FBIG = osl_File_E_FBIG,
82 E_NOSPC = osl_File_E_NOSPC,
83 E_SPIPE = osl_File_E_SPIPE,
84 E_ROFS = osl_File_E_ROFS,
85 E_MLINK = osl_File_E_MLINK,
86 E_PIPE = osl_File_E_PIPE,
87 E_DOM = osl_File_E_DOM,
88 E_RANGE = osl_File_E_RANGE,
89 E_DEADLK = osl_File_E_DEADLK,
90 E_NAMETOOLONG = osl_File_E_NAMETOOLONG,
91 E_NOLCK = osl_File_E_NOLCK,
92 E_NOSYS = osl_File_E_NOSYS,
93 E_NOTEMPTY = osl_File_E_NOTEMPTY,
94 E_LOOP = osl_File_E_LOOP,
95 E_ILSEQ = osl_File_E_ILSEQ,
96 E_NOLINK = osl_File_E_NOLINK,
97 E_MULTIHOP = osl_File_E_MULTIHOP,
98 E_USERS = osl_File_E_USERS,
99 E_OVERFLOW = osl_File_E_OVERFLOW,
100 E_NOTREADY = osl_File_E_NOTREADY,
101 E_invalidError = osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
102 E_TIMEDOUT = osl_File_E_TIMEDOUT,
103 E_NETWORK = osl_File_E_NETWORK
107 public:
109 /** Determine a valid unused canonical name for a requested name.
111 Determines a valid unused canonical name for a requested name.
112 Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
113 If a file or directory with the requested name already exists a new name is generated following
114 the common rules on the actual Operating System and File System.
116 @param ustrRequestedURL [in]
117 Requested name of a file or directory.
119 @param ustrValidURL [out]
120 On success receives a name which is unused and valid on the actual Operating System and
121 File System.
123 @return
124 E_None on success
125 E_INVAL the format of the parameters was not valid
127 @see DirectoryItem::getFileStatus()
130 static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
132 return static_cast< RC >( osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData ) );
135 /** Convert a path relative to a given directory into an full qualified file URL.
137 Convert a path relative to a given directory into an full qualified file URL.
138 The function resolves symbolic links if possible and path ellipses, so on success
139 the resulting absolute path is fully resolved.
141 @param ustrBaseDirectoryURL [in]
142 Base directory URL to which the relative path is related to.
144 @param ustrRelativeFileURL [in]
145 An URL of a file or directory relative to the directory path specified by ustrBaseDirectoryURL
146 or an absolute path.
147 If ustrRelativeFileURL denotes an absolute path ustrBaseDirectoryURL will be ignored.
149 @param ustrAbsoluteFileURL [out]
150 On success it receives the full qualified absolute file URL.
152 @return
153 E_None on success
154 E_INVAL the format of the parameters was not valid
155 E_NOMEM not enough memory for allocating structures
156 E_NOTDIR not a directory
157 E_ACCES permission denied
158 E_NOENT no such file or directory
159 E_NAMETOOLONG file name too long
160 E_OVERFLOW value too large for defined data type
161 E_FAULT bad address
162 E_INTR function call was interrupted
163 E_LOOP too many symbolic links encountered
164 E_MULTIHOP multihop attempted
165 E_NOLINK link has been severed
167 @see DirectoryItem::getFileStatus()
170 static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
172 return static_cast< RC >( osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData ) );
175 /** Convert a file URL into a system dependent path.
177 @param ustrFileURL [in]
178 A File URL.
180 @param ustrSystemPath [out]
181 On success it receives the system path.
183 @return
184 E_None on success
185 E_INVAL the format of the parameters was not valid
187 @see getFileURLFromSystemPath()
190 static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
192 return static_cast< RC >( osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData ) );
195 /** Convert a system dependent path into a file URL.
197 @param ustrSystemPath [in]
198 A System dependent path of a file or directory.
200 @param ustrFileURL [out]
201 On success it receives the file URL.
203 @return
204 E_None on success
205 E_INVAL the format of the parameters was not valid
207 @see getSystemPathFromFileURL()
210 static inline RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
212 return static_cast< RC >( osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData ) );
215 /** Searche a full qualified system path or a file URL.
217 @param ustrFileName [in]
218 A system dependent path, a file URL, a file or relative directory
220 @param ustrSearchPath [in]
221 A list of system paths, in which a given file has to be searched. The Notation of a path list is
222 system dependent, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
223 These paths are only for the search of a file or a relative path, otherwise it will be ignored.
224 If ustrSearchPath is NULL or while using the search path the search failed, the function searches for
225 a matching file in all system directories and in the directories listed in the PATH environment
226 variable.
227 The value of an environment variable should be used (e.g. LD_LIBRARY_PATH) if the caller is not
228 aware of the Operating System and so doesn't know which path list delimiter to use.
230 @param ustrFileURL [out]
231 On success it receives the full qualified file URL.
233 @return
234 E_None on success
235 E_INVAL the format of the parameters was not valid
236 E_NOTDIR not a directory
237 E_NOENT no such file or directory not found
239 @see getFileURLFromSystemPath()
240 @see getSystemPathFromFileURL()
243 static inline RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
245 return static_cast< RC >( osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData ) );
248 /** Retrieves the file URL of the system's temporary directory path.
250 @param[out] ustrTempDirURL
251 On success receives the URL of system's temporary directory path.
253 @return
254 E_None on success
255 E_NOENT no such file or directory not found
258 static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
260 return static_cast< RC >( osl_getTempDirURL( &ustrTempDirURL.pData ) );
263 /** Creates a temporary file in the directory provided by the caller or the
264 directory returned by getTempDirURL.
265 Under UNIX Operating Systems the file will be created with read and write
266 access for the user exclusively.
267 If the caller requests only a handle to the open file but not the name of
268 it, the file will be automatically removed on close else the caller is
269 responsible for removing the file on success.<br><br>
271 @param pustrDirectoryURL [in]
272 Specifies the full qualified URL where the temporary file should be created.
273 If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
275 @param pHandle [out]
276 On success receives a handle to the open file.
277 If pHandle is 0 the file will be closed on return, in this case
278 pustrTempFileURL must not be 0.
280 @param pustrTempFileURL [out]
281 On success receives the full qualified URL of the temporary file.
282 If pustrTempFileURL is 0 the file will be automatically removed
283 on close, in this case pHandle must not be 0.
284 If pustrTempFileURL is not 0 the caller receives the name of the
285 created file and is responsible for removing the file.
287 Description of the different pHandle, ppustrTempFileURL parameter combinations.
288 pHandle is 0 and pustrTempDirURL is 0 - this combination is invalid<br>
289 pHandle is not 0 and pustrTempDirURL is 0 - a handle to the open file
290 will be returned on success and the file will be automatically removed on close<br>
291 pHandle is 0 and pustrTempDirURL is not 0 - the name of the file will be
292 returned, the caller is responsible for opening, closing and removing the file.<br>
293 pHandle is not 0 and pustrTempDirURL is not 0 - a handle to the open file as well as
294 the file name will be returned, the caller is responsible for closing and removing
295 the file.<br>
297 @return
298 E_None on success
299 E_INVAL the format of the parameter is invalid
300 E_NOMEM not enough memory for allocating structures
301 E_ACCES Permission denied
302 E_NOENT No such file or directory
303 E_NOTDIR Not a directory
304 E_ROFS Read-only file system
305 E_NOSPC No space left on device
306 E_DQUOT Quota exceeded
308 @see getTempDirURL()
311 static inline RC createTempFile(
312 ::rtl::OUString* pustrDirectoryURL,
313 oslFileHandle* pHandle,
314 ::rtl::OUString* pustrTempFileURL)
316 rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : 0;
317 rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : 0;
319 return static_cast< RC >( osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url) );
325 /** The VolumeDevice class.
327 @see VolumeInfo
330 class VolumeDevice : public FileBase
332 oslVolumeDeviceHandle _aHandle;
334 public:
336 /** Constructor.
339 VolumeDevice() : _aHandle( NULL )
343 /** Copy constructor.
345 @param rDevice
346 The other volume device.
349 VolumeDevice( const VolumeDevice & rDevice )
351 _aHandle = rDevice._aHandle;
352 if ( _aHandle )
353 osl_acquireVolumeDeviceHandle( _aHandle );
356 /** Destructor.
359 ~VolumeDevice()
361 if ( _aHandle )
362 osl_releaseVolumeDeviceHandle( _aHandle );
365 /** Assignment operator.
367 @param rDevice
368 The other volume device.
371 inline VolumeDevice & operator =( const VolumeDevice & rDevice )
373 oslVolumeDeviceHandle newHandle = rDevice._aHandle;
375 if ( newHandle )
376 osl_acquireVolumeDeviceHandle( newHandle );
378 if ( _aHandle )
379 osl_releaseVolumeDeviceHandle( _aHandle );
381 _aHandle = newHandle;
383 return *this;
386 /** Get the full qualified URL where a device is mounted to.
388 @return
389 The full qualified URL where the device is mounted to.
391 inline rtl::OUString getMountPath()
393 rtl::OUString aPath;
394 osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
395 return aPath;
398 friend class VolumeInfo;
403 class Directory;
405 /** The VolumeInfo class.
407 Neither copy nor assignment is allowed for this class.
409 @see Directory::getVolumeInfo
413 class VolumeInfo
415 oslVolumeInfo _aInfo;
416 sal_uInt32 _nMask;
417 VolumeDevice _aDevice;
419 /** Copy constructor.
422 VolumeInfo( VolumeInfo& ) SAL_DELETED_FUNCTION;
424 /** Assginment operator.
427 VolumeInfo& operator = ( VolumeInfo& ) SAL_DELETED_FUNCTION;
429 public:
431 /** Constructor.
433 @param nMask
434 Set of flags describing the demanded information.
437 VolumeInfo( sal_uInt32 nMask )
438 : _nMask( nMask )
440 memset( &_aInfo, 0, sizeof( oslVolumeInfo ));
441 _aInfo.uStructSize = sizeof( oslVolumeInfo );
442 _aInfo.pDeviceHandle = &_aDevice._aHandle;
445 /** Destructor.
448 ~VolumeInfo()
450 if( _aInfo.ustrFileSystemName )
451 rtl_uString_release( _aInfo.ustrFileSystemName );
454 /** Check if specified fields are valid.
456 @param nMask
457 Set of flags for the fields to check.
459 @return true if all fields are valid else false.
462 inline bool isValid( sal_uInt32 nMask ) const
464 return ( nMask & _aInfo.uValidFields ) == nMask;
467 /** Check the remote flag.
469 @return
470 true if Attributes are valid and the volume is remote else false.
473 inline bool getRemoteFlag() const
475 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Remote);
478 /** Check the removeable flag.
480 @return
481 true if attributes are valid and the volume is removable else false.
484 inline bool getRemoveableFlag() const
486 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Removeable);
489 /** Check the compact disc flag.
491 @return
492 true if attributes are valid and the volume is a CDROM else false.
495 inline bool getCompactDiscFlag() const
497 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc);
500 /** Check the floppy disc flag.
502 @return
503 true if attributes are valid and the volume is a floppy disk else false.
506 inline bool getFloppyDiskFlag() const
508 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk);
511 /** Check the fixed disk flag.
513 @return
514 true if attributes are valid and the volume is a fixed disk else false.
517 inline bool getFixedDiskFlag() const
519 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk);
522 /** Check the RAM disk flag.
524 @return
525 true if attributes are valid and the volume is a RAM disk else false.
528 inline bool getRAMDiskFlag() const
530 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk);
533 /** Determine the total space of a volume device.
535 @return
536 The total diskspace of this volume if this information is valid,
537 0 otherwise.
540 inline sal_uInt64 getTotalSpace() const
542 return _aInfo.uTotalSpace;
545 /** Determine the free space of a volume device.
547 @return
548 The free diskspace of this volume if this information is valid,
549 0 otherwise.
552 inline sal_uInt64 getFreeSpace() const
554 return _aInfo.uFreeSpace;
557 /** Determine the used space of a volume device.
559 @return
560 The used diskspace of this volume if this information is valid,
561 0 otherwise.
564 inline sal_uInt64 getUsedSpace() const
566 return _aInfo.uUsedSpace;
569 /** Determine the maximal length of a file name.
571 @return
572 The maximal length of a file name if this information is valid,
573 0 otherwise.
576 inline sal_uInt32 getMaxNameLength() const
578 return _aInfo.uMaxNameLength;
581 /** Determine the maximal length of a path name.
583 @return
584 The maximal length of a path if this information is valid,
585 0 otherwise.
588 inline sal_uInt32 getMaxPathLength() const
590 return _aInfo.uMaxPathLength;
593 /** Determine the name of the volume device's File System.
595 @return
596 The name of the volume's fielsystem if this information is valid,
597 otherwise an empty string.
600 inline ::rtl::OUString getFileSystemName() const
602 return _aInfo.ustrFileSystemName ? ::rtl::OUString( _aInfo.ustrFileSystemName ) : ::rtl::OUString();
606 /** Get the volume device handle.
608 @return
609 The device handle of the volume if this information is valid,
610 otherwise returns NULL;
613 inline VolumeDevice getDeviceHandle() const
615 return _aDevice;
618 /** Return whether the file system is case sensitive or
619 case insensitive
621 @return
622 true if the file system is case sensitive false otherwise
624 bool isCaseSensitiveFileSystem() const
626 return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive) != 0;
629 /** Return whether the file system preserves the case of
630 file and directory names or not
632 @return
633 true if the file system preserves the case of file and
634 directory names false otherwise
636 bool isCasePreservingFileSystem() const
638 return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Is_Preserved) != 0;
641 friend class Directory;
645 class DirectoryItem;
647 /** The FileStatus class.
649 @see DirectoryItem::getFileStatus
652 class FileStatus
654 oslFileStatus _aStatus;
655 sal_uInt32 _nMask;
657 /** Copy constructor.
660 FileStatus( FileStatus& ) SAL_DELETED_FUNCTION;
662 /** Assignment operator.
665 FileStatus& operator = ( FileStatus& ) SAL_DELETED_FUNCTION;
667 public:
669 enum Type {
670 Directory = osl_File_Type_Directory,
671 Volume = osl_File_Type_Volume,
672 Regular = osl_File_Type_Regular,
673 Fifo = osl_File_Type_Fifo,
674 Socket = osl_File_Type_Socket,
675 Link = osl_File_Type_Link,
676 Special = osl_File_Type_Special,
677 Unknown = osl_File_Type_Unknown
680 /** Constructor.
682 @param nMask
683 Set of flags describing the demanded information.
685 FileStatus(sal_uInt32 nMask)
686 : _nMask(nMask)
688 memset(&_aStatus, 0, sizeof(_aStatus));
689 _aStatus.uStructSize = sizeof(_aStatus);
692 /** Destructor.
694 ~FileStatus()
696 if ( _aStatus.ustrFileURL )
697 rtl_uString_release( _aStatus.ustrFileURL );
698 if ( _aStatus.ustrLinkTargetURL )
699 rtl_uString_release( _aStatus.ustrLinkTargetURL );
700 if ( _aStatus.ustrFileName )
701 rtl_uString_release( _aStatus.ustrFileName );
704 /** Check if specified fields are valid.
706 @param nMask
707 Set of flags for the fields to check.
709 @return
710 true if all fields are valid else false.
713 inline bool isValid( sal_uInt32 nMask ) const
715 return ( nMask & _aStatus.uValidFields ) == nMask;
718 /** Get the file type.
720 @return
721 The file type.
723 inline Type getFileType() const
725 SAL_INFO_IF(
726 !isValid(osl_FileStatus_Mask_Type), "sal.osl",
727 "no FileStatus Type determined");
728 return isValid(osl_FileStatus_Mask_Type)
729 ? static_cast< Type >(_aStatus.eType) : Unknown;
732 /** Is it a directory?
733 This method returns True for both directories, and volumes.
735 @return
736 True if it's a directory, False otherwise.
738 @see getFileType
739 @since LibreOffice 3.6
741 inline bool isDirectory() const
743 return ( getFileType() == Directory || getFileType() == Volume );
746 /** Is it a regular file?
748 @return
749 True if it's a regular file, False otherwise.
751 @see getFileType
752 @see isFile
753 @see isLink
754 @since LibreOffice 3.6
756 inline bool isRegular() const
758 return ( getFileType() == Regular );
761 /** Is it a link?
763 @return
764 True if it's a link, False otherwise.
766 @see getFileType
767 @since LibreOffice 3.6
769 inline bool isLink() const
771 return ( getFileType() == Link );
774 /** Get the file attributes.
776 @return
777 The set of attribute flags of this file.
780 inline sal_uInt64 getAttributes() const
782 SAL_INFO_IF(
783 !isValid(osl_FileStatus_Mask_Attributes), "sal.osl",
784 "no FileStatus Attributes determined");
785 return _aStatus.uAttributes;
788 /** Get the creation time of this file.
790 @return
791 The creation time if this information is valid, an uninitialized
792 TimeValue otherwise.
795 inline TimeValue getCreationTime() const
797 SAL_INFO_IF(
798 !isValid(osl_FileStatus_Mask_CreationTime), "sal.osl",
799 "no FileStatus CreationTime determined");
800 return _aStatus.aCreationTime;
803 /** Get the file access time.
805 @return
806 The last access time if this information is valid, an uninitialized
807 TimeValue otherwise.
810 inline TimeValue getAccessTime() const
812 SAL_INFO_IF(
813 !isValid(osl_FileStatus_Mask_AccessTime), "sal.osl",
814 "no FileStatus AccessTime determined");
815 return _aStatus.aAccessTime;
818 /** Get the file modification time.
820 @return
821 The last modified time if this information is valid, an uninitialized
822 TimeValue otherwise.
825 inline TimeValue getModifyTime() const
827 SAL_INFO_IF(
828 !isValid(osl_FileStatus_Mask_ModifyTime), "sal.osl",
829 "no FileStatus ModifyTime determined");
830 return _aStatus.aModifyTime;
833 /** Get the size of the file.
835 @return
836 The actual file size if this information is valid, 0 otherwise.
839 inline sal_uInt64 getFileSize() const
841 SAL_INFO_IF(
842 !isValid(osl_FileStatus_Mask_FileSize), "sal.osl",
843 "no FileStatus FileSize determined");
844 return _aStatus.uFileSize;
847 /** Get the file name.
849 @return
850 The file name if this information is valid, an empty string otherwise.
853 inline ::rtl::OUString getFileName() const
855 SAL_INFO_IF(
856 !isValid(osl_FileStatus_Mask_FileName), "sal.osl",
857 "no FileStatus FileName determined");
858 return isValid(osl_FileStatus_Mask_FileName)
859 ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
863 /** Get the URL of the file.
865 @return
866 The full qualified URL of the file if this information is valid, an
867 empty string otherwise.
870 inline ::rtl::OUString getFileURL() const
872 SAL_INFO_IF(
873 !isValid(osl_FileStatus_Mask_FileURL), "sal.osl",
874 "no FileStatus FileURL determined");
875 return isValid(osl_FileStatus_Mask_FileURL)
876 ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
879 /** Get the link target URL.
881 @return
882 The link target URL if this information is valid, an empty string
883 otherwise.
886 inline ::rtl::OUString getLinkTargetURL() const
888 SAL_INFO_IF(
889 !isValid(osl_FileStatus_Mask_LinkTargetURL), "sal.osl",
890 "no FileStatus LinkTargetURL determined");
891 return isValid(osl_FileStatus_Mask_LinkTargetURL)
892 ? rtl::OUString(_aStatus.ustrLinkTargetURL) : rtl::OUString();
895 friend class DirectoryItem;
900 /** The file class object provides access to file contents and attributes.
902 @see Directory
903 @see DirectoryItem
906 class File: public FileBase
908 oslFileHandle _pData;
909 ::rtl::OUString _aPath;
911 /** Copy constructor.
914 File( File& ) SAL_DELETED_FUNCTION;
916 /** Assginment operator.
919 File& operator = ( File& ) SAL_DELETED_FUNCTION;
921 public:
923 /** Constructor.
925 @param ustrFileURL [in]
926 The full qualified URL of the file. Relative paths are not allowed.
929 File( const ::rtl::OUString& ustrFileURL ): _pData( 0 ), _aPath( ustrFileURL ) {}
931 /** Destructor
934 inline ~File()
936 close();
939 /** Obtain the URL.
941 @return
942 the URL with which this File instance was created.
944 @since LibreOffice 4.1
946 inline rtl::OUString getURL() const { return _aPath; }
948 /** Open a regular file.
950 Open a file. Only regular files can be openend.
952 @param uFlags [in]
953 Specifies the open mode.
955 @return
956 E_None on success
957 E_NOMEM not enough memory for allocating structures
958 E_INVAL the format of the parameters was not valid
959 E_NAMETOOLONG pathname was too long
960 E_NOENT no such file or directory
961 E_ACCES permission denied
962 E_AGAIN a write lock could not be established
963 E_NOTDIR not a directory
964 E_NXIO no such device or address
965 E_NODEV no such device
966 E_ROFS read-only file system
967 E_TXTBSY text file busy
968 E_FAULT bad address
969 E_LOOP too many symbolic links encountered
970 E_NOSPC no space left on device
971 E_ISDIR is a directory
972 E_MFILE too many open files used by the process
973 E_NFILE too many open files in the system
974 E_DQUOT quota exceeded
975 E_EXIST file exists
976 E_INTR function call was interrupted
977 E_IO on I/O errors
978 E_MULTIHOP multihop attempted
979 E_NOLINK link has been severed
980 E_EOVERFLOW value too large for defined data type
982 @see close()
983 @see setPos()
984 @see getPos()
985 @see read()
986 @see write()
987 @see getSize()
988 @see setSize()
991 inline RC open( sal_uInt32 uFlags )
993 return static_cast< RC >( osl_openFile( _aPath.pData, &_pData, uFlags ) );
996 /** Close an open file.
998 @return
999 E_None on success
1000 E_INVAL the format of the parameters was not valid
1001 E_BADF Bad file
1002 E_INTR function call was interrupted
1003 E_NOLINK link has been severed
1004 E_NOSPC no space left on device
1005 E_IO on I/O errors
1007 @see open()
1010 inline RC close()
1012 oslFileError Error = osl_File_E_BADF;
1014 if( _pData )
1016 Error=osl_closeFile( _pData );
1017 _pData = NULL;
1020 return static_cast< RC >( Error );
1023 /** Set the internal position pointer of an open file.
1025 @param uHow [in]
1026 Distance to move the internal position pointer (from uPos).
1028 @param uPos [in]
1029 Absolute position from the beginning of the file.
1031 @return
1032 E_None on success
1033 E_INVAL the format of the parameters was not valid
1034 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1036 @see open()
1037 @see getPos()
1040 inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT
1042 return static_cast< RC >( osl_setFilePos( _pData, uHow, uPos ) );
1045 /** Retrieve the current position of the internal pointer of an open file.
1047 @param uPos [out]
1048 On success receives the current position of the file pointer.
1050 @return
1051 E_None on success
1052 E_INVAL the format of the parameters was not valid
1053 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1055 @see open()
1056 @see setPos()
1057 @see read()
1058 @see write()
1061 inline RC getPos( sal_uInt64& uPos )
1063 return static_cast< RC >( osl_getFilePos( _pData, &uPos ) );
1066 /** Test if the end of a file is reached.
1068 @param pIsEOF [out]
1069 Points to a variable that receives the end-of-file status.
1071 @return
1072 E_None on success
1073 E_INVAL the format of the parameters was not valid
1074 E_INTR function call was interrupted
1075 E_IO on I/O errors
1076 E_ISDIR is a directory
1077 E_BADF bad file
1078 E_FAULT bad address
1079 E_AGAIN operation would block
1080 E_NOLINK link has been severed
1082 @see open()
1083 @see read()
1084 @see readLine()
1085 @see setPos()
1088 inline RC isEndOfFile( sal_Bool *pIsEOF )
1090 return static_cast< RC >( osl_isEndOfFile( _pData, pIsEOF ) );
1093 /** Set the file size of an open file.
1095 Sets the file size of an open file. The file can be truncated or enlarged by the function.
1096 The position of the file pointer is not affeced by this function.
1098 @param uSize [in]
1099 New size in bytes.
1101 @return
1102 E_None on success
1103 E_INVAL the format of the parameters was not valid
1104 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1106 @see open()
1107 @see setPos()
1108 @see getStatus()
1111 inline RC setSize( sal_uInt64 uSize )
1113 return static_cast< RC >( osl_setFileSize( _pData, uSize ) );
1116 /** Get the file size of an open file.
1118 Gets the file size of an open file.
1119 The position of the file pointer is not affeced by this function.
1121 @param rSize [out]
1122 Current size in bytes.
1124 @return
1125 E_None on success
1126 E_INVAL the format of the parameters was not valid
1127 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1129 @see open()
1130 @see setPos()
1131 @see getSize()
1132 @see setSize()
1133 @see getStatus()
1136 inline RC getSize( sal_uInt64 &rSize )
1138 return static_cast< RC >( osl_getFileSize( _pData, &rSize ) );
1141 /** Read a number of bytes from a file.
1143 Reads a number of bytes from a file. The internal file pointer is
1144 increased by the number of bytes read.
1146 @param pBuffer [out]
1147 Points to a buffer which receives data. The buffer must be large enough
1148 to hold uBytesRequested bytes.
1150 @param uBytesRequested [in]
1151 Number of bytes which should be retrieved.
1153 @param rBytesRead [out]
1154 On success the number of bytes which have actually been retrieved.
1156 @return
1157 E_None on success
1158 E_INVAL the format of the parameters was not valid
1159 E_INTR function call was interrupted
1160 E_IO on I/O errors
1161 E_ISDIR is a directory
1162 E_BADF bad file
1163 E_FAULT bad address
1164 E_AGAIN operation would block
1165 E_NOLINK link has been severed
1167 @see open()
1168 @see write()
1169 @see readLine()
1170 @see setPos()
1173 inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
1175 return static_cast< RC >( osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead ) );
1178 /** Write a number of bytes to a file.
1180 Writes a number of bytes to a file.
1181 The internal file pointer is increased by the number of bytes read.
1183 @param pBuffer [in]
1184 Points to a buffer which contains the data.
1186 @param uBytesToWrite [in]
1187 Number of bytes which should be written.
1189 @param rBytesWritten [out]
1190 On success the number of bytes which have actually been written.
1192 @return
1193 E_None on success
1194 E_INVAL the format of the parameters was not valid
1195 E_FBIG file too large
1196 E_DQUOT quota exceeded
1197 E_AGAIN operation would block
1198 E_BADF bad file
1199 E_FAULT bad address
1200 E_INTR function call was interrupted
1201 E_IO on I/O errosr
1202 E_NOLCK no record locks available
1203 E_NOLINK link has been severed
1204 E_NOSPC no space left on device
1205 E_NXIO no such device or address
1207 @see open()
1208 @see read()
1209 @see setPos()
1212 inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
1214 return static_cast< RC >( osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten ) );
1218 /** Read a line from a file.
1220 Reads a line from a file. The new line delimiter is NOT returned!
1222 @param aSeq [in/out]
1223 A reference to a ::rtl::ByteSequence that will hold the line read on success.
1225 @return
1226 E_None on success
1227 E_INVAL the format of the parameters was not valid
1228 E_INTR function call was interrupted
1229 E_IO on I/O errors
1230 E_ISDIR is a directory
1231 E_BADF bad file
1232 E_FAULT bad address
1233 E_AGAIN operation would block
1234 E_NOLINK link has been severed
1236 @see open()
1237 @see read()
1238 @see write()
1239 @see setPos()
1242 inline RC readLine( ::rtl::ByteSequence& aSeq )
1244 return static_cast< RC >( osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) ) );
1247 /** Synchronize the memory representation of a file with that on the physical medium.
1249 The function ensures that all modified data and attributes of the file associated with
1250 the given file handle have been written to the physical medium.
1251 In case the hard disk has a write cache enabled, the data may not really be on
1252 permanent storage when osl_syncFile returns.
1254 @return
1255 <dl>
1256 <dt>E_None</dt>
1257 <dd>On success</dd>
1258 <dt>E_INVAL</dt>
1259 <dd>The value of the input parameter is invalid</dd>
1260 <br><p><strong>In addition to these error codes others may occur as well, for instance:</strong></p><br>
1261 <dt>E_BADF</dt>
1262 <dd>The file is not open for writing</dd>
1263 <dt>E_IO</dt>
1264 <dd>An I/O error occurred</dd>
1265 <dt>E_NOSPC</dt>
1266 <dd>There is no enough space on the target device</dd>
1267 <dt>E_ROFS</dt>
1268 <dd>The file is located on a read only file system</dd>
1269 <dt>E_TIMEDOUT</dt>
1270 <dd>A remote connection timed out. This may happen when a file is on a remote location</dd>
1271 </dl>
1273 @see osl_syncFile()
1274 @see open()
1275 @see write()
1277 inline RC sync() const
1279 OSL_PRECOND(_pData, "File::sync(): File not open");
1280 return static_cast< RC >(osl_syncFile(_pData));
1283 /** Copy a file to a new destination.
1285 Copies a file to a new destination. Copies only files not directories.
1286 No assumptions should be made about preserving attributes or file time.
1288 @param ustrSourceFileURL [in]
1289 Full qualified URL of the source file.
1291 @param ustrDestFileURL [in]
1292 Full qualified URL of the destination file. A directory is NOT a valid destination file!
1294 @return
1295 E_None on success
1296 E_INVAL the format of the parameters was not valid
1297 E_NOMEM not enough memory for allocating structures
1298 E_ACCES permission denied
1299 E_PERM operation not permitted
1300 E_NAMETOOLONG file name too long
1301 E_NOENT no such file or directory
1302 E_ISDIR is a directory
1303 E_ROFS read-only file system
1305 @see move()
1306 @see remove()
1309 inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1311 return static_cast< RC >( osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1314 /** Move a file or directory to a new destination or renames it.
1316 Moves a file or directory to a new destination or renames it.
1317 File time and attributes are preserved.
1319 @param ustrSourceFileURL [in]
1320 Full qualified URL of the source file.
1322 @param ustrDestFileURL [in]
1323 Full qualified URL of the destination file. An existing directory is NOT a valid destination !
1325 @return
1326 E_None on success
1327 E_INVAL the format of the parameters was not valid
1328 E_NOMEM not enough memory for allocating structures
1329 E_ACCES permission denied
1330 E_PERM operation not permitted
1331 E_NAMETOOLONG file name too long
1332 E_NOENT no such file or directory
1333 E_ROFS read-only file system
1335 @see copy()
1338 inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1340 return static_cast< RC >( osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1343 /** Remove a regular file.
1345 @param ustrFileURL [in]
1346 Full qualified URL of the file to remove.
1348 @return
1349 E_None on success
1350 E_INVAL the format of the parameters was not valid
1351 E_NOMEM not enough memory for allocating structures
1352 E_ACCES permission denied
1353 E_PERM operation not permitted
1354 E_NAMETOOLONG file name too long
1355 E_NOENT no such file or directory
1356 E_ISDIR is a directory
1357 E_ROFS read-only file system
1358 E_FAULT bad address
1359 E_LOOP too many symbolic links encountered
1360 E_IO on I/O errors
1361 E_BUSY device or resource busy
1362 E_INTR function call was interrupted
1363 E_LOOP too many symbolic links encountered
1364 E_MULTIHOP multihop attempted
1365 E_NOLINK link has been severed
1366 E_TXTBSY text file busy
1368 @see open()
1371 inline static RC remove( const ::rtl::OUString& ustrFileURL )
1373 return static_cast< RC >( osl_removeFile( ustrFileURL.pData ) );
1376 /** Set file attributes.
1378 @param ustrFileURL [in]
1379 The full qualified file URL.
1381 @param uAttributes [in]
1382 Attributes of the file to be set.
1384 @return
1385 E_None on success
1386 E_INVAL the format of the parameters was not valid
1388 @see FileStatus
1391 inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
1393 return static_cast< RC >( osl_setFileAttributes( ustrFileURL.pData, uAttributes ) );
1396 /** Set the file time.
1398 @param ustrFileURL [in]
1399 The full qualified URL of the file.
1401 @param rCreationTime [in]
1402 Creation time of the given file.
1404 @param rLastAccessTime [in]
1405 Time of the last access of the given file.
1407 @param rLastWriteTime [in]
1408 Time of the last modifying of the given file.
1410 @return
1411 E_None on success
1412 E_INVAL the format of the parameters was not valid
1413 E_NOENT no such file or directory not found
1415 @see FileStatus
1418 inline static RC setTime(
1419 const ::rtl::OUString& ustrFileURL,
1420 const TimeValue& rCreationTime,
1421 const TimeValue& rLastAccessTime,
1422 const TimeValue& rLastWriteTime )
1424 return static_cast< RC >( osl_setFileTime(
1425 ustrFileURL.pData,
1426 &rCreationTime,
1427 &rLastAccessTime,
1428 &rLastWriteTime ) );
1431 friend class DirectoryItem;
1435 /** The directory item class object provides access to file status information.
1437 @see FileStatus
1440 class DirectoryItem: public FileBase
1442 oslDirectoryItem _pData;
1444 public:
1446 /** Constructor.
1449 DirectoryItem(): _pData( NULL )
1453 /** Copy constructor.
1456 DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
1458 if( _pData )
1459 osl_acquireDirectoryItem( _pData );
1462 /** Destructor.
1465 ~DirectoryItem()
1467 if( _pData )
1468 osl_releaseDirectoryItem( _pData );
1471 /** Assignment operator.
1474 DirectoryItem& operator=(const DirectoryItem& rItem )
1476 if (&rItem != this)
1478 if( _pData )
1479 osl_releaseDirectoryItem( _pData );
1481 _pData = rItem._pData;
1483 if( _pData )
1484 osl_acquireDirectoryItem( _pData );
1486 return *this;
1489 /** Check for validity of this instance.
1491 @return
1492 true if object is valid directory item else false.
1495 inline bool is()
1497 return _pData != NULL;
1500 /** Retrieve a single directory item.
1502 Retrieves a single directory item. The returned handle has an initial refcount of 1.
1503 Due to performance issues it is not recommended to use this function while
1504 enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
1506 @param ustrFileURL [in]
1507 An absolute file URL.
1509 @param rItem [out]
1510 On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
1511 The handle has to be released by a call to osl_releaseDirectoryItem().
1513 @return
1514 E_None on success
1515 E_INVAL the format of the parameters was not valid
1516 E_NOMEM not enough memory for allocating structures
1517 E_ACCES permission denied
1518 E_MFILE too many open files used by the process
1519 E_NFILE too many open files in the system
1520 E_NOENT no such file or directory
1521 E_LOOP too many symbolic links encountered
1522 E_NAMETOOLONG the file name is too long
1523 E_NOTDIR a component of the path prefix of path is not a directory
1524 E_IO on I/O errors
1525 E_MULTIHOP multihop attempted
1526 E_NOLINK link has been severed
1527 E_FAULT bad address
1528 E_INTR the function call was interrupted
1530 @see FileStatus
1531 @see Directory::getNextItem()
1534 static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
1536 if( rItem._pData)
1538 osl_releaseDirectoryItem( rItem._pData );
1539 rItem._pData = NULL;
1542 return static_cast< RC >( osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData ) );
1545 /** Retrieve information about a single file or directory.
1547 @param rStatus [in|out]
1548 Reference to a class which receives the information of the file or directory
1549 represented by this directory item.
1551 @return
1552 E_None on success
1553 E_NOMEM not enough memory for allocating structures
1554 E_INVAL the format of the parameters was not valid
1555 E_LOOP too many symbolic links encountered
1556 E_ACCES permission denied
1557 E_NOENT no such file or directory
1558 E_NAMETOOLONG file name too long
1559 E_BADF invalid oslDirectoryItem parameter
1560 E_FAULT bad address
1561 E_OVERFLOW value too large for defined data type
1562 E_INTR function call was interrupted
1563 E_NOLINK link has been severed
1564 E_MULTIHOP components of path require hopping to multiple remote machines and the file system does not allow it
1565 E_MFILE too many open files used by the process
1566 E_NFILE too many open files in the system
1567 E_NOSPC no space left on device
1568 E_NXIO no such device or address
1569 E_IO on I/O errors
1570 E_NOSYS function not implemented
1572 @see get()
1573 @see Directory::getNextItem()
1574 @see FileStatus
1577 inline RC getFileStatus( FileStatus& rStatus )
1579 return static_cast< RC >( osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask ) );
1582 /** Determine if a directory item point the same underlying file
1584 The comparison is done first by URL, and then by resolving links to
1585 find the target, and finally by comparing inodes on unix.
1587 @param[in] pOther
1588 A directory handle to compare with the underlying object's item
1590 @return
1591 true: if the items point to an identical resource<br>
1592 false: if the items point to a different resource, or a fatal error occurred<br>
1594 @see osl_getDirectoryItem()
1596 @since LibreOffice 3.6
1598 inline bool isIdenticalTo( const DirectoryItem &pOther )
1600 return osl_identicalDirectoryItem( _pData, pOther._pData );
1603 friend class Directory;
1608 /** Base class for observers of directory creation notifications.
1610 Clients which uses the method createDirectoryPath of the class
1611 Directory may want to be informed about the directories that
1612 have been created. This may be accomplished by deriving from
1613 this base class and overwriting the virtual function
1614 DirectoryCreated.
1616 @see Directory::createPath
1618 class DirectoryCreationObserver
1620 public:
1621 virtual ~DirectoryCreationObserver() {}
1623 /** This method will be called when a new directory has been
1624 created and needs to be overwritten by derived classes.
1625 You must not delete the directory that was just created
1626 otherwise you will run into an endless loop.
1628 @param aDirectoryUrl
1629 [in]The absolute file URL of the directory that was just created by
1630 ::osl::Directory::createPath.
1632 virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
1636 // This just an internal helper function for
1637 // private use.
1638 extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
1640 (static_cast<DirectoryCreationObserver*>(pData))->DirectoryCreated(aDirectoryUrl);
1643 /** The directory class object provides a enumeration of DirectoryItems.
1645 @see DirectoryItem
1646 @see File
1649 class Directory: public FileBase
1651 oslDirectory _pData;
1652 ::rtl::OUString _aPath;
1654 /** Copy constructor.
1657 Directory( Directory& ) SAL_DELETED_FUNCTION;
1659 /** Assignment operator.
1662 Directory& operator = ( Directory& ) SAL_DELETED_FUNCTION;
1664 public:
1666 /** Constructor.
1668 @param strPath [in]
1669 The full qualified URL of the directory.
1670 Relative URLs are not allowed.
1673 Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath )
1677 /** Destructor.
1680 ~Directory()
1682 close();
1685 /** Obtain the URL.
1687 @return
1688 the URL with which this Directory instance was created.
1690 @since LibreOffice 4.1
1692 inline rtl::OUString getURL() const { return _aPath; }
1694 /** Open a directory for enumerating its contents.
1696 @return
1697 E_None on success
1698 E_INVAL the format of the parameters was not valid
1699 E_NOENT the specified path doesn't exist
1700 E_NOTDIR the specified path is not an directory
1701 E_NOMEM not enough memory for allocating structures
1702 E_ACCES permission denied
1703 E_MFILE too many open files used by the process
1704 E_NFILE too many open files in the system
1705 E_NAMETOOLONG File name too long
1706 E_LOOP Too many symbolic links encountered
1708 @see getNextItem()
1709 @see close()
1712 inline RC open()
1714 return static_cast< RC >( osl_openDirectory( _aPath.pData, &_pData ) );
1717 /** Query if directory is open.
1719 Query if directory is open and so item enumeration is valid.
1721 @return
1722 true if the directory is open else false.
1724 @see open()
1725 @see close()
1728 inline bool isOpen() { return _pData != NULL; }
1730 /** Close a directory.
1732 @return
1733 E_None on success
1734 E_INVAL the format of the parameters was not valid
1735 E_NOMEM not enough memory for allocating structures
1736 E_BADF invalid oslDirectory parameter
1737 E_INTR the function call was interrupted
1739 @see open()
1742 inline RC close()
1744 oslFileError Error = osl_File_E_BADF;
1746 if( _pData )
1748 Error=osl_closeDirectory( _pData );
1749 _pData = NULL;
1752 return static_cast< RC >( Error );
1756 /** Resets the directory item enumeration to the beginning.
1758 @return
1759 E_None on success
1760 E_INVAL the format of the parameters was not valid
1761 E_NOENT the specified path doesn't exist
1762 E_NOTDIR the specified path is not an directory
1763 E_NOMEM not enough memory for allocating structures
1764 E_ACCES permission denied
1765 E_MFILE too many open files used by the process
1766 E_NFILE too many open files in the system
1767 E_NAMETOOLONG File name too long
1768 E_LOOP Too many symbolic links encountered
1770 @see open()
1773 inline RC reset()
1775 close();
1776 return open();
1779 /** Retrieve the next item of a previously opened directory.
1781 Retrieves the next item of a previously opened directory.
1783 @param rItem [out]
1784 On success a valid DirectoryItem.
1786 @param nHint [in]
1787 With this parameter the caller can tell the implementation that (s)he
1788 is going to call this function uHint times afterwards. This enables the implementation to
1789 get the information for more than one file and cache it until the next calls.
1791 @return
1792 E_None on success
1793 E_INVAL the format of the parameters was not valid
1794 E_NOMEM not enough memory for allocating structures
1795 E_NOENT no more entries in this directory
1796 E_BADF invalid oslDirectory parameter
1797 E_OVERFLOW the value too large for defined data type
1799 @see DirectoryItem
1802 inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
1804 if( rItem._pData )
1806 osl_releaseDirectoryItem( rItem._pData );
1807 rItem._pData = 0;
1809 return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
1813 /** Retrieve information about a volume.
1815 Retrieves information about a volume. A volume can either be a mount point, a network
1816 resource or a drive depending on Operating System and File System.
1818 @param ustrDirectoryURL [in]
1819 Full qualified URL of the volume
1821 @param rInfo [out]
1822 On success it receives information about the volume.
1824 @return
1825 E_None on success
1826 E_NOMEM not enough memory for allocating structures
1827 E_INVAL the format of the parameters was not valid
1828 E_NOTDIR not a directory
1829 E_NAMETOOLONG file name too long
1830 E_NOENT no such file or directory
1831 E_ACCES permission denied
1832 E_LOOP too many symbolic links encountered
1833 E_FAULT Bad address
1834 E_IO on I/O errors
1835 E_NOSYS function not implemented
1836 E_MULTIHOP multihop attempted
1837 E_NOLINK link has been severed
1838 E_INTR function call was interrupted
1840 @see FileStatus
1841 @see VolumeInfo
1844 inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
1846 return static_cast< RC >( osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask ) );
1849 /** Create a directory.
1851 @param ustrDirectoryURL [in]
1852 Full qualified URL of the directory to create.
1854 @param flags [in]
1855 Optional flags, see osl_createDirectoryWithFlags for details. This
1856 defaulted parameter is new since LibreOffice 4.3.
1858 @return
1859 E_None on success
1860 E_INVAL the format of the parameters was not valid
1861 E_NOMEM not enough memory for allocating structures
1862 E_EXIST file exists
1863 E_ACCES permission denied
1864 E_NAMETOOLONG file name too long
1865 E_NOENT no such file or directory
1866 E_NOTDIR not a directory
1867 E_ROFS read-only file system
1868 E_NOSPC no space left on device
1869 E_DQUOT quota exceeded
1870 E_LOOP too many symbolic links encountered
1871 E_FAULT bad address
1872 E_IO on I/O errors
1873 E_MLINK too many links
1874 E_MULTIHOP multihop attempted
1875 E_NOLINK link has been severed
1877 @see remove()
1880 inline static RC create(
1881 const ::rtl::OUString& ustrDirectoryURL,
1882 sal_uInt32 flags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write )
1884 return static_cast< RC >(
1885 osl_createDirectoryWithFlags( ustrDirectoryURL.pData, flags ) );
1888 /** Remove an empty directory.
1890 @param ustrDirectoryURL [in]
1891 Full qualified URL of the directory.
1893 @return
1894 E_None on success
1895 E_INVAL the format of the parameters was not valid
1896 E_NOMEM not enough memory for allocating structures
1897 E_PERM operation not permitted
1898 E_ACCES permission denied
1899 E_NOENT no such file or directory
1900 E_NOTDIR not a directory
1901 E_NOTEMPTY directory not empty
1902 E_FAULT bad address
1903 E_NAMETOOLONG file name too long
1904 E_BUSY device or resource busy
1905 E_ROFS read-only file system
1906 E_LOOP too many symbolic links encountered
1907 E_BUSY device or resource busy
1908 E_EXIST file exists
1909 E_IO on I/O errors
1910 E_MULTIHOP multihop attempted
1911 E_NOLINK link has been severed
1913 @see create()
1916 inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
1918 return static_cast< RC >( osl_removeDirectory( ustrDirectoryURL.pData ) );
1921 /** Create a directory path.
1923 The osl_createDirectoryPath function creates a specified directory path.
1924 All nonexisting sub directories will be created.
1925 <p><strong>PLEASE NOTE:</strong> You cannot rely on getting the error code
1926 E_EXIST for existing directories. Programming against this error code is
1927 in general a strong indication of a wrong usage of osl_createDirectoryPath.</p>
1929 @param aDirectoryUrl
1930 [in] The absolute file URL of the directory path to create.
1931 A relative file URL will not be accepted.
1933 @param aDirectoryCreationObserver
1934 [in] Pointer to an instance of type DirectoryCreationObserver that will
1935 be informed about the creation of a directory. The value of this
1936 parameter may be NULL, in this case notifications will not be sent.
1938 @return
1939 <dl>
1940 <dt>E_None</dt>
1941 <dd>On success</dd>
1942 <dt>E_INVAL</dt>
1943 <dd>The format of the parameters was not valid</dd>
1944 <dt>E_ACCES</dt>
1945 <dd>Permission denied</dd>
1946 <dt>E_EXIST</dt>
1947 <dd>The final node of the specified directory path already exist</dd>
1948 <dt>E_NAMETOOLONG</dt>
1949 <dd>The name of the specified directory path exceeds the maximum allowed length</dd>
1950 <dt>E_NOTDIR</dt>
1951 <dd>A component of the specified directory path already exist as file in any part of the directory path</dd>
1952 <dt>E_ROFS</dt>
1953 <dd>Read-only file system</dd>
1954 <dt>E_NOSPC</dt>
1955 <dd>No space left on device</dd>
1956 <dt>E_DQUOT</dt>
1957 <dd>Quota exceeded</dd>
1958 <dt>E_FAULT</dt>
1959 <dd>Bad address</dd>
1960 <dt>E_IO</dt>
1961 <dd>I/O error</dd>
1962 <dt>E_LOOP</dt>
1963 <dd>Too many symbolic links encountered</dd>
1964 <dt>E_NOLINK</dt>
1965 <dd>Link has been severed</dd>
1966 <dt>E_invalidError</dt>
1967 <dd>An unknown error occurred</dd>
1968 </dl>
1970 @see DirectoryCreationObserver
1971 @see create
1973 static RC createPath(
1974 const ::rtl::OUString& aDirectoryUrl,
1975 DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
1977 return static_cast< RC >(osl_createDirectoryPath(
1978 aDirectoryUrl.pData,
1979 (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
1980 aDirectoryCreationObserver));
1984 } /* namespace osl */
1986 #endif // INCLUDED_OSL_FILE_HXX
1988 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */