bump product version to 4.2.0.1
[LibreOffice.git] / include / osl / file.hxx
blob7b50b537ea929ffb159b7a695e059aa7a103eb0f
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 <osl/time.h>
30 #include <rtl/ustring.hxx>
32 #include <osl/file.h>
33 #include <rtl/byteseq.hxx>
35 #include <stdio.h>
37 namespace osl
41 // -----------------------------------------------------------------------------
42 /** Base class for all File System specific objects.
44 @see Directory
45 @see DirectoryItem
46 @see File
49 class FileBase
51 public:
53 enum RC {
54 E_None = osl_File_E_None,
55 E_PERM = osl_File_E_PERM,
56 E_NOENT = osl_File_E_NOENT,
57 E_SRCH = osl_File_E_SRCH,
58 E_INTR = osl_File_E_INTR,
59 E_IO = osl_File_E_IO,
60 E_NXIO = osl_File_E_NXIO,
61 E_2BIG = osl_File_E_2BIG,
62 E_NOEXEC = osl_File_E_NOEXEC,
63 E_BADF = osl_File_E_BADF,
64 E_CHILD = osl_File_E_CHILD,
65 E_AGAIN = osl_File_E_AGAIN,
66 E_NOMEM = osl_File_E_NOMEM,
67 E_ACCES = osl_File_E_ACCES,
68 E_FAULT = osl_File_E_FAULT,
69 E_BUSY = osl_File_E_BUSY,
70 E_EXIST = osl_File_E_EXIST,
71 E_XDEV = osl_File_E_XDEV,
72 E_NODEV = osl_File_E_NODEV,
73 E_NOTDIR = osl_File_E_NOTDIR,
74 E_ISDIR = osl_File_E_ISDIR,
75 E_INVAL = osl_File_E_INVAL,
76 E_NFILE = osl_File_E_NFILE,
77 E_MFILE = osl_File_E_MFILE,
78 E_NOTTY = osl_File_E_NOTTY,
79 E_FBIG = osl_File_E_FBIG,
80 E_NOSPC = osl_File_E_NOSPC,
81 E_SPIPE = osl_File_E_SPIPE,
82 E_ROFS = osl_File_E_ROFS,
83 E_MLINK = osl_File_E_MLINK,
84 E_PIPE = osl_File_E_PIPE,
85 E_DOM = osl_File_E_DOM,
86 E_RANGE = osl_File_E_RANGE,
87 E_DEADLK = osl_File_E_DEADLK,
88 E_NAMETOOLONG = osl_File_E_NAMETOOLONG,
89 E_NOLCK = osl_File_E_NOLCK,
90 E_NOSYS = osl_File_E_NOSYS,
91 E_NOTEMPTY = osl_File_E_NOTEMPTY,
92 E_LOOP = osl_File_E_LOOP,
93 E_ILSEQ = osl_File_E_ILSEQ,
94 E_NOLINK = osl_File_E_NOLINK,
95 E_MULTIHOP = osl_File_E_MULTIHOP,
96 E_USERS = osl_File_E_USERS,
97 E_OVERFLOW = osl_File_E_OVERFLOW,
98 E_NOTREADY = osl_File_E_NOTREADY,
99 E_invalidError = osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
100 E_TIMEDOUT = osl_File_E_TIMEDOUT,
101 E_NETWORK = osl_File_E_NETWORK
105 public:
107 /** Determine a valid unused canonical name for a requested name.
109 Determines a valid unused canonical name for a requested name.
110 Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
111 If a file or directory with the requested name already exists a new name is generated following
112 the common rules on the actual Operating System and File System.
114 @param ustrRequestedURL [in]
115 Requested name of a file or directory.
117 @param ustrValidURL [out]
118 On success receives a name which is unused and valid on the actual Operating System and
119 File System.
121 @return
122 E_None on success
123 E_INVAL the format of the parameters was not valid
125 @see DirectoryItem::getFileStatus()
128 static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
130 return static_cast< RC >( osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData ) );
133 /** Convert a path relative to a given directory into an full qualified file URL.
135 Convert a path relative to a given directory into an full qualified file URL.
136 The function resolves symbolic links if possible and path ellipses, so on success
137 the resulting absolute path is fully resolved.
139 @param ustrBaseDirectoryURL [in]
140 Base directory URL to which the relative path is related to.
142 @param ustrRelativeFileURL [in]
143 An URL of a file or directory relative to the directory path specified by ustrBaseDirectoryURL
144 or an absolute path.
145 If ustrRelativeFileURL denotes an absolute path ustrBaseDirectoryURL will be ignored.
147 @param ustrAbsoluteFileURL [out]
148 On success it receives the full qualified absolute file URL.
150 @return
151 E_None on success
152 E_INVAL the format of the parameters was not valid
153 E_NOMEM not enough memory for allocating structures
154 E_NOTDIR not a directory
155 E_ACCES permission denied
156 E_NOENT no such file or directory
157 E_NAMETOOLONG file name too long
158 E_OVERFLOW value too large for defined data type
159 E_FAULT bad address
160 E_INTR function call was interrupted
161 E_LOOP too many symbolic links encountered
162 E_MULTIHOP multihop attempted
163 E_NOLINK link has been severed
165 @see DirectoryItem::getFileStatus()
168 static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
170 return static_cast< RC >( osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData ) );
173 /** Convert a file URL into a system dependend path.
175 @param ustrFileURL [in]
176 A File URL.
178 @param ustrSystemPath [out]
179 On success it receives the system path.
181 @return
182 E_None on success
183 E_INVAL the format of the parameters was not valid
185 @see getFileURLFromSystemPath()
188 static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
190 return static_cast< RC >( osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData ) );
193 /** Convert a system dependend path into a file URL.
195 @param ustrSystemPath [in]
196 A System dependent path of a file or directory.
198 @param ustrFileURL [out]
199 On success it receives the file URL.
201 @return
202 E_None on success
203 E_INVAL the format of the parameters was not valid
205 @see getSystemPathFromFileURL()
208 static inline RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
210 return static_cast< RC >( osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData ) );
213 /** Searche a full qualified system path or a file URL.
215 @param ustrFileName [in]
216 A system dependent path, a file URL, a file or relative directory
218 @param ustrSearchPath [in]
219 A list of system paths, in which a given file has to be searched. The Notation of a path list is
220 system dependend, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
221 These paths are only for the search of a file or a relative path, otherwise it will be ignored.
222 If ustrSearchPath is NULL or while using the search path the search failed, the function searches for
223 a matching file in all system directories and in the directories listed in the PATH environment
224 variable.
225 The value of an environment variable should be used (e.g. LD_LIBRARY_PATH) if the caller is not
226 aware of the Operating System and so doesn't know which path list delimiter to use.
228 @param ustrFileURL [out]
229 On success it receives the full qualified file URL.
231 @return
232 E_None on success
233 E_INVAL the format of the parameters was not valid
234 E_NOTDIR not a directory
235 E_NOENT no such file or directory not found
237 @see getFileURLFromSystemPath()
238 @see getSystemPathFromFileURL()
241 static inline RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
243 return static_cast< RC >( osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData ) );
246 /** Retrieves the file URL of the system's temporary directory path.
248 @param[out] ustrTempDirURL
249 On success receives the URL of system's temporary directory path.
251 @return
252 E_None on success
253 E_NOENT no such file or directory not found
256 static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
258 return static_cast< RC >( osl_getTempDirURL( &ustrTempDirURL.pData ) );
261 /** Creates a temporary file in the directory provided by the caller or the
262 directory returned by getTempDirURL.
263 Under UNIX Operating Systems the file will be created with read and write
264 access for the user exclusively.
265 If the caller requests only a handle to the open file but not the name of
266 it, the file will be automatically removed on close else the caller is
267 responsible for removing the file on success.<br><br>
269 @param pustrDirectoryURL [in]
270 Specifies the full qualified URL where the temporary file should be created.
271 If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
273 @param pHandle [out]
274 On success receives a handle to the open file.
275 If pHandle is 0 the file will be closed on return, in this case
276 pustrTempFileURL must not be 0.
278 @param pustrTempFileURL [out]
279 On success receives the full qualified URL of the temporary file.
280 If pustrTempFileURL is 0 the file will be automatically removed
281 on close, in this case pHandle must not be 0.
282 If pustrTempFileURL is not 0 the caller receives the name of the
283 created file and is responsible for removing the file.
285 Description of the different pHandle, ppustrTempFileURL parameter combinations.
286 pHandle is 0 and pustrTempDirURL is 0 - this combination is invalid<br>
287 pHandle is not 0 and pustrTempDirURL is 0 - a handle to the open file
288 will be returned on success and the file will be automatically removed on close<br>
289 pHandle is 0 and pustrTempDirURL is not 0 - the name of the file will be
290 returned, the caller is responsible for opening, closing and removing the file.<br>
291 pHandle is not 0 and pustrTempDirURL is not 0 - a handle to the open file as well as
292 the file name will be returned, the caller is responsible for closing and removing
293 the file.<br>
295 @return
296 E_None on success
297 E_INVAL the format of the parameter is invalid
298 E_NOMEM not enough memory for allocating structures
299 E_ACCES Permission denied
300 E_NOENT No such file or directory
301 E_NOTDIR Not a directory
302 E_ROFS Read-only file system
303 E_NOSPC No space left on device
304 E_DQUOT Quota exceeded
306 @see getTempDirURL()
309 static inline RC createTempFile(
310 ::rtl::OUString* pustrDirectoryURL,
311 oslFileHandle* pHandle,
312 ::rtl::OUString* pustrTempFileURL)
314 rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : 0;
315 rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : 0;
317 return static_cast< RC >( osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url) );
322 // -----------------------------------------------------------------------------
323 /** The VolumeDevice class.
325 @see VolumeInfo
328 class VolumeDevice : public FileBase
330 oslVolumeDeviceHandle _aHandle;
332 public:
334 /** Constructor.
337 VolumeDevice() : _aHandle( NULL )
341 /** Copy constructor.
343 @param rDevice
344 The other volume device.
347 VolumeDevice( const VolumeDevice & rDevice )
349 _aHandle = rDevice._aHandle;
350 if ( _aHandle )
351 osl_acquireVolumeDeviceHandle( _aHandle );
354 /** Destructor.
357 ~VolumeDevice()
359 if ( _aHandle )
360 osl_releaseVolumeDeviceHandle( _aHandle );
363 /** Assignment operator.
365 @param rDevice
366 The other volume device.
369 inline VolumeDevice & operator =( const VolumeDevice & rDevice )
371 oslVolumeDeviceHandle newHandle = rDevice._aHandle;
373 if ( newHandle )
374 osl_acquireVolumeDeviceHandle( newHandle );
376 if ( _aHandle )
377 osl_releaseVolumeDeviceHandle( _aHandle );
379 _aHandle = newHandle;
381 return *this;
384 /** Get the full qualified URL where a device is mounted to.
386 @return
387 The full qualified URL where the device is mounted to.
389 inline rtl::OUString getMountPath()
391 rtl::OUString aPath;
392 osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
393 return aPath;
396 friend class VolumeInfo;
399 // -----------------------------------------------------------------------------
401 class Directory;
403 /** The VolumeInfo class.
405 Neither copy nor assignment is allowed for this class.
407 @see Directory::getVolumeInfo
411 class VolumeInfo
413 oslVolumeInfo _aInfo;
414 sal_uInt32 _nMask;
415 VolumeDevice _aDevice;
417 /** Copy constructor.
420 VolumeInfo( VolumeInfo& );
422 /** Assginment operator.
425 VolumeInfo& operator = ( VolumeInfo& );
427 public:
429 /** Constructor.
431 @param nMask
432 Set of flags decribing the demanded information.
435 VolumeInfo( sal_uInt32 nMask ): _nMask( nMask )
437 _aInfo.uStructSize = sizeof( oslVolumeInfo );
438 memset( &_aInfo.uValidFields, 0, sizeof( oslVolumeInfo ) - sizeof( sal_uInt32 ) );
439 _aInfo.pDeviceHandle = &_aDevice._aHandle;
442 /** Destructor.
445 ~VolumeInfo()
447 if( _aInfo.ustrFileSystemName )
448 rtl_uString_release( _aInfo.ustrFileSystemName );
451 /** Check if specified fields are valid.
453 @param nMask
454 Set of flags for the fields to check.
456 @return sal_True if all fields are valid else sal_False.
459 inline sal_Bool isValid( sal_uInt32 nMask ) const
461 return ( nMask & _aInfo.uValidFields ) == nMask;
464 /** Check the remote flag.
466 @return
467 sal_True if Attributes are valid and the volume is remote else sal_False.
470 inline sal_Bool getRemoteFlag() const
472 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Remote);
475 /** Check the removeable flag.
477 @return
478 sal_True if attributes are valid and the volume is removable else sal_False.
481 inline sal_Bool getRemoveableFlag() const
483 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Removeable);
486 /** Check the compact disc flag.
488 @return
489 sal_True if attributes are valid and the volume is a CDROM else sal_False.
492 inline sal_Bool getCompactDiscFlag() const
494 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc);
497 /** Check the floppy disc flag.
499 @return
500 sal_True if attributes are valid and the volume is a floppy disk else sal_False.
503 inline sal_Bool getFloppyDiskFlag() const
505 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk);
508 /** Check the fixed disk flag.
510 @return
511 sal_True if attributes are valid and the volume is a fixed disk else sal_False.
514 inline sal_Bool getFixedDiskFlag() const
516 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk);
519 /** Check the RAM disk flag.
521 @return
522 sal_True if attributes are valid and the volume is a RAM disk else sal_False.
525 inline sal_Bool getRAMDiskFlag() const
527 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk);
530 /** Determine the total space of a volume device.
532 @return
533 The total diskspace of this volume if this information is valid,
534 0 otherwise.
537 inline sal_uInt64 getTotalSpace() const
539 return _aInfo.uTotalSpace;
542 /** Determine the free space of a volume device.
544 @return
545 The free diskspace of this volume if this information is valid,
546 0 otherwise.
549 inline sal_uInt64 getFreeSpace() const
551 return _aInfo.uFreeSpace;
554 /** Determine the used space of a volume device.
556 @return
557 The used diskspace of this volume if this information is valid,
558 0 otherwise.
561 inline sal_uInt64 getUsedSpace() const
563 return _aInfo.uUsedSpace;
566 /** Determine the maximal length of a file name.
568 @return
569 The maximal length of a file name if this information is valid,
570 0 otherwise.
573 inline sal_uInt32 getMaxNameLength() const
575 return _aInfo.uMaxNameLength;
578 /** Determine the maximal length of a path name.
580 @return
581 The maximal length of a path if this information is valid,
582 0 otherwise.
585 inline sal_uInt32 getMaxPathLength() const
587 return _aInfo.uMaxPathLength;
590 /** Determine the name of the volume device's File System.
592 @return
593 The name of the volume's fielsystem if this information is valid,
594 otherwise an empty string.
597 inline ::rtl::OUString getFileSystemName() const
599 return _aInfo.ustrFileSystemName ? ::rtl::OUString( _aInfo.ustrFileSystemName ) : ::rtl::OUString();
603 /** Get the volume device handle.
605 @return
606 The device handle of the volume if this information is valid,
607 otherwise returns NULL;
610 inline VolumeDevice getDeviceHandle() const
612 return _aDevice;
615 /** Return whether the file system is case sensitive or
616 case insensitive
618 @return
619 true if the file system is case sensitive false otherwise
621 bool isCaseSensitiveFileSystem() const
623 return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive);
626 /** Return whether the file system preserves the case of
627 file and directory names or not
629 @return
630 true if the file system preserves the case of file and
631 directory names false otherwise
633 bool isCasePreservingFileSystem() const
635 return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Is_Preserved);
638 friend class Directory;
641 // -----------------------------------------------------------------------------
642 class DirectoryItem;
644 /** The FileStatus class.
646 @see DirectoryItem::getFileStatus
649 class FileStatus
651 oslFileStatus _aStatus;
652 sal_uInt32 _nMask;
654 /** Copy constructor.
657 FileStatus( FileStatus& );
659 /** Assignment operator.
662 FileStatus& operator = ( FileStatus& );
664 public:
666 enum Type {
667 Directory = osl_File_Type_Directory,
668 Volume = osl_File_Type_Volume,
669 Regular = osl_File_Type_Regular,
670 Fifo = osl_File_Type_Fifo,
671 Socket = osl_File_Type_Socket,
672 Link = osl_File_Type_Link,
673 Special = osl_File_Type_Special,
674 Unknown = osl_File_Type_Unknown
677 /** Constructor.
679 @param nMask
680 Set of flags decribing the demanded information.
683 FileStatus( sal_uInt32 nMask ): _nMask( nMask )
685 _aStatus.uStructSize = sizeof( oslFileStatus );
686 memset( &_aStatus.uValidFields, 0, sizeof( oslFileStatus ) - sizeof( sal_uInt32 ) );
689 /** Destructor.
692 ~FileStatus()
694 if ( _aStatus.ustrFileURL )
695 rtl_uString_release( _aStatus.ustrFileURL );
696 if ( _aStatus.ustrLinkTargetURL )
697 rtl_uString_release( _aStatus.ustrLinkTargetURL );
698 if ( _aStatus.ustrFileName )
699 rtl_uString_release( _aStatus.ustrFileName );
702 /** Check if specified fields are valid.
704 @param nMask
705 Set of flags for the fields to check.
707 @return
708 sal_True if all fields are valid else sal_False.
711 inline sal_Bool isValid( sal_uInt32 nMask ) const
713 return ( nMask & _aStatus.uValidFields ) == nMask;
716 /** Get the file type.
718 @return
719 The file type.
721 inline Type getFileType() const
723 SAL_INFO_IF(
724 !isValid(osl_FileStatus_Mask_Type), "sal.osl",
725 "no FileStatus Type determined");
726 return isValid(osl_FileStatus_Mask_Type)
727 ? static_cast< Type >(_aStatus.eType) : Unknown;
730 /** Is it a directory?
731 This method returns True for both directories, and volumes.
733 @return
734 True if it's a directory, False otherwise.
736 @see getFileType
737 @since LibreOffice 3.6
739 inline sal_Bool isDirectory() const
741 return ( getFileType() == Directory || getFileType() == Volume );
744 /** Is it a regular file?
746 @return
747 True if it's a regular file, False otherwise.
749 @see getFileType
750 @see isFile
751 @see isLink
752 @since LibreOffice 3.6
754 inline sal_Bool isRegular() const
756 return ( getFileType() == Regular );
759 /** Is it a link?
761 @return
762 True if it's a link, False otherwise.
764 @see getFileType
765 @since LibreOffice 3.6
767 inline sal_Bool isLink() const
769 return ( getFileType() == Link );
772 /** Get the file attributes.
774 @return
775 The set of attribute flags of this file.
778 inline sal_uInt64 getAttributes() const
780 SAL_INFO_IF(
781 !isValid(osl_FileStatus_Mask_Attributes), "sal.osl",
782 "no FileStatus Attributes determined");
783 return _aStatus.uAttributes;
786 /** Get the creation time of this file.
788 @return
789 The creation time if this information is valid, an uninitialized
790 TimeValue otherwise.
793 inline TimeValue getCreationTime() const
795 SAL_INFO_IF(
796 !isValid(osl_FileStatus_Mask_CreationTime), "sal.osl",
797 "no FileStatus CreationTime determined");
798 return _aStatus.aCreationTime;
801 /** Get the file access time.
803 @return
804 The last access time if this information is valid, an uninitialized
805 TimeValue otherwise.
808 inline TimeValue getAccessTime() const
810 SAL_INFO_IF(
811 !isValid(osl_FileStatus_Mask_AccessTime), "sal.osl",
812 "no FileStatus AccessTime determined");
813 return _aStatus.aAccessTime;
816 /** Get the file modification time.
818 @return
819 The last modified time if this information is valid, an uninitialized
820 TimeValue otherwise.
823 inline TimeValue getModifyTime() const
825 SAL_INFO_IF(
826 !isValid(osl_FileStatus_Mask_ModifyTime), "sal.osl",
827 "no FileStatus ModifyTime determined");
828 return _aStatus.aModifyTime;
831 /** Get the size of the file.
833 @return
834 The actual file size if this information is valid, 0 otherwise.
837 inline sal_uInt64 getFileSize() const
839 SAL_INFO_IF(
840 !isValid(osl_FileStatus_Mask_FileSize), "sal.osl",
841 "no FileStatus FileSize determined");
842 return _aStatus.uFileSize;
845 /** Get the file name.
847 @return
848 The file name if this information is valid, an empty string otherwise.
851 inline ::rtl::OUString getFileName() const
853 SAL_INFO_IF(
854 !isValid(osl_FileStatus_Mask_FileName), "sal.osl",
855 "no FileStatus FileName determined");
856 return isValid(osl_FileStatus_Mask_FileName)
857 ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
861 /** Get the URL of the file.
863 @return
864 The full qualified URL of the file if this information is valid, an
865 empty string otherwise.
868 inline ::rtl::OUString getFileURL() const
870 SAL_INFO_IF(
871 !isValid(osl_FileStatus_Mask_FileURL), "sal.osl",
872 "no FileStatus FileURL determined");
873 return isValid(osl_FileStatus_Mask_FileURL)
874 ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
877 /** Get the link target URL.
879 @return
880 The link target URL if this information is valid, an empty string
881 otherwise.
884 inline ::rtl::OUString getLinkTargetURL() const
886 SAL_INFO_IF(
887 !isValid(osl_FileStatus_Mask_LinkTargetURL), "sal.osl",
888 "no FileStatus LinkTargetURL determined");
889 return isValid(osl_FileStatus_Mask_LinkTargetURL)
890 ? rtl::OUString(_aStatus.ustrLinkTargetURL) : rtl::OUString();
893 friend class DirectoryItem;
897 // -----------------------------------------------------------------------------
898 /** The file class object provides access to file contents and attributes.
900 @see Directory
901 @see DirectoryItem
904 class File: public FileBase
906 oslFileHandle _pData;
907 ::rtl::OUString _aPath;
909 /** Copy constructor.
912 File( File& );
914 /** Assginment operator.
917 File& operator = ( File& );
919 public:
921 /** Constructor.
923 @param ustrFileURL [in]
924 The full qualified URL of the file. Relative paths are not allowed.
927 File( const ::rtl::OUString& ustrFileURL ): _pData( 0 ), _aPath( ustrFileURL ) {}
929 /** Destructor
932 inline ~File()
934 close();
937 /** Obtain the URL.
939 @return
940 the URL with which this File instance was created.
942 @since LibreOffice 4.1
944 inline rtl::OUString getURL() const { return _aPath; }
946 /** Open a regular file.
948 Open a file. Only regular files can be openend.
950 @param uFlags [in]
951 Specifies the open mode.
953 @return
954 E_None on success
955 E_NOMEM not enough memory for allocating structures
956 E_INVAL the format of the parameters was not valid
957 E_NAMETOOLONG pathname was too long
958 E_NOENT no such file or directory
959 E_ACCES permission denied
960 E_AGAIN a write lock could not be established
961 E_NOTDIR not a directory
962 E_NXIO no such device or address
963 E_NODEV no such device
964 E_ROFS read-only file system
965 E_TXTBSY text file busy
966 E_FAULT bad address
967 E_LOOP too many symbolic links encountered
968 E_NOSPC no space left on device
969 E_ISDIR is a directory
970 E_MFILE too many open files used by the process
971 E_NFILE too many open files in the system
972 E_DQUOT quota exceeded
973 E_EXIST file exists
974 E_INTR function call was interrupted
975 E_IO on I/O errors
976 E_MULTIHOP multihop attempted
977 E_NOLINK link has been severed
978 E_EOVERFLOW value too large for defined data type
980 @see close()
981 @see setPos()
982 @see getPos()
983 @see read()
984 @see write()
985 @see getSize()
986 @see setSize()
989 inline RC open( sal_uInt32 uFlags )
991 return static_cast< RC >( osl_openFile( _aPath.pData, &_pData, uFlags ) );
994 /** Close an open file.
996 @return
997 E_None on success
998 E_INVAL the format of the parameters was not valid
999 E_BADF Bad file
1000 E_INTR function call was interrupted
1001 E_NOLINK link has been severed
1002 E_NOSPC no space left on device
1003 E_IO on I/O errors
1005 @see open()
1008 inline RC close()
1010 oslFileError Error = osl_File_E_BADF;
1012 if( _pData )
1014 Error=osl_closeFile( _pData );
1015 _pData = NULL;
1018 return static_cast< RC >( Error );
1021 /** Set the internal position pointer of an open file.
1023 @param uHow [in]
1024 Distance to move the internal position pointer (from uPos).
1026 @param uPos [in]
1027 Absolute position from the beginning of the file.
1029 @return
1030 E_None on success
1031 E_INVAL the format of the parameters was not valid
1032 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1034 @see open()
1035 @see getPos()
1038 inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT
1040 return static_cast< RC >( osl_setFilePos( _pData, uHow, uPos ) );
1043 /** Retrieve the current position of the internal pointer of an open file.
1045 @param uPos [out]
1046 On success receives the current position of the file pointer.
1048 @return
1049 E_None on success
1050 E_INVAL the format of the parameters was not valid
1051 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1053 @see open()
1054 @see setPos()
1055 @see read()
1056 @see write()
1059 inline RC getPos( sal_uInt64& uPos )
1061 return static_cast< RC >( osl_getFilePos( _pData, &uPos ) );
1064 /** Test if the end of a file is reached.
1066 @param pIsEOF [out]
1067 Points to a variable that receives the end-of-file status.
1069 @return
1070 E_None on success
1071 E_INVAL the format of the parameters was not valid
1072 E_INTR function call was interrupted
1073 E_IO on I/O errors
1074 E_ISDIR is a directory
1075 E_BADF bad file
1076 E_FAULT bad address
1077 E_AGAIN operation would block
1078 E_NOLINK link has been severed
1080 @see open()
1081 @see read()
1082 @see readLine()
1083 @see setPos()
1086 inline RC isEndOfFile( sal_Bool *pIsEOF )
1088 return static_cast< RC >( osl_isEndOfFile( _pData, pIsEOF ) );
1091 /** Set the file size of an open file.
1093 Sets the file size of an open file. The file can be truncated or enlarged by the function.
1094 The position of the file pointer is not affeced by this function.
1096 @param uSize [in]
1097 New size in bytes.
1099 @return
1100 E_None on success
1101 E_INVAL the format of the parameters was not valid
1102 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1104 @see open()
1105 @see setPos()
1106 @see getStatus()
1109 inline RC setSize( sal_uInt64 uSize )
1111 return static_cast< RC >( osl_setFileSize( _pData, uSize ) );
1114 /** Get the file size of an open file.
1116 Gets the file size of an open file.
1117 The position of the file pointer is not affeced by this function.
1119 @param rSize [out]
1120 Current size in bytes.
1122 @return
1123 E_None on success
1124 E_INVAL the format of the parameters was not valid
1125 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1127 @see open()
1128 @see setPos()
1129 @see getSize()
1130 @see setSize()
1131 @see getStatus()
1134 inline RC getSize( sal_uInt64 &rSize )
1136 return static_cast< RC >( osl_getFileSize( _pData, &rSize ) );
1139 /** Read a number of bytes from a file.
1141 Reads a number of bytes from a file. The internal file pointer is
1142 increased by the number of bytes read.
1144 @param pBuffer [out]
1145 Points to a buffer which receives data. The buffer must be large enough
1146 to hold uBytesRequested bytes.
1148 @param uBytesRequested [in]
1149 Number of bytes which should be retrieved.
1151 @param rBytesRead [out]
1152 On success the number of bytes which have actually been retrieved.
1154 @return
1155 E_None on success
1156 E_INVAL the format of the parameters was not valid
1157 E_INTR function call was interrupted
1158 E_IO on I/O errors
1159 E_ISDIR is a directory
1160 E_BADF bad file
1161 E_FAULT bad address
1162 E_AGAIN operation would block
1163 E_NOLINK link has been severed
1165 @see open()
1166 @see write()
1167 @see readLine()
1168 @see setPos()
1171 inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
1173 return static_cast< RC >( osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead ) );
1176 /** Write a number of bytes to a file.
1178 Writes a number of bytes to a file.
1179 The internal file pointer is increased by the number of bytes read.
1181 @param pBuffer [in]
1182 Points to a buffer which contains the data.
1184 @param uBytesToWrite [in]
1185 Number of bytes which should be written.
1187 @param rBytesWritten [out]
1188 On success the number of bytes which have actually been written.
1190 @return
1191 E_None on success
1192 E_INVAL the format of the parameters was not valid
1193 E_FBIG file too large
1194 E_DQUOT quota exceeded
1195 E_AGAIN operation would block
1196 E_BADF bad file
1197 E_FAULT bad address
1198 E_INTR function call was interrupted
1199 E_IO on I/O errosr
1200 E_NOLCK no record locks available
1201 E_NOLINK link has been severed
1202 E_NOSPC no space left on device
1203 E_NXIO no such device or address
1205 @see open()
1206 @see read()
1207 @see setPos()
1210 inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
1212 return static_cast< RC >( osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten ) );
1216 /** Read a line from a file.
1218 Reads a line from a file. The new line delimiter is NOT returned!
1220 @param aSeq [in/out]
1221 A reference to a ::rtl::ByteSequence that will hold the line read on success.
1223 @return
1224 E_None on success
1225 E_INVAL the format of the parameters was not valid
1226 E_INTR function call was interrupted
1227 E_IO on I/O errors
1228 E_ISDIR is a directory
1229 E_BADF bad file
1230 E_FAULT bad address
1231 E_AGAIN operation would block
1232 E_NOLINK link has been severed
1234 @see open()
1235 @see read()
1236 @see write()
1237 @see setPos()
1240 inline RC readLine( ::rtl::ByteSequence& aSeq )
1242 return static_cast< RC >( osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) ) );
1245 /** Synchronize the memory representation of a file with that on the physical medium.
1247 The function ensures that all modified data and attributes of the file associated with
1248 the given file handle have been written to the physical medium.
1249 In case the hard disk has a write cache enabled, the data may not really be on
1250 permanent storage when osl_syncFile returns.
1252 @return
1253 <dl>
1254 <dt>E_None</dt>
1255 <dd>On success</dd>
1256 <dt>E_INVAL</dt>
1257 <dd>The value of the input parameter is invalid</dd>
1258 <br><p><strong>In addition to these error codes others may occur as well, for instance:</strong></p><br>
1259 <dt>E_BADF</dt>
1260 <dd>The file is not open for writing</dd>
1261 <dt>E_IO</dt>
1262 <dd>An I/O error occurred</dd>
1263 <dt>E_NOSPC</dt>
1264 <dd>There is no enough space on the target device</dd>
1265 <dt>E_ROFS</dt>
1266 <dd>The file is located on a read only file system</dd>
1267 <dt>E_TIMEDOUT</dt>
1268 <dd>A remote connection timed out. This may happen when a file is on a remote location</dd>
1269 </dl>
1271 @see osl_syncFile()
1272 @see open()
1273 @see write()
1275 inline RC sync() const
1277 OSL_PRECOND(_pData, "File::sync(): File not open");
1278 return static_cast< RC >(osl_syncFile(_pData));
1281 /** Copy a file to a new destination.
1283 Copies a file to a new destination. Copies only files not directories.
1284 No assumptions should be made about preserving attributes or file time.
1286 @param ustrSourceFileURL [in]
1287 Full qualified URL of the source file.
1289 @param ustrDestFileURL [in]
1290 Full qualified URL of the destination file. A directory is NOT a valid destination file!
1292 @return
1293 E_None on success
1294 E_INVAL the format of the parameters was not valid
1295 E_NOMEM not enough memory for allocating structures
1296 E_ACCES permission denied
1297 E_PERM operation not permitted
1298 E_NAMETOOLONG file name too long
1299 E_NOENT no such file or directory
1300 E_ISDIR is a directory
1301 E_ROFS read-only file system
1303 @see move()
1304 @see remove()
1307 inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1309 return static_cast< RC >( osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1312 /** Move a file or directory to a new destination or renames it.
1314 Moves a file or directory to a new destination or renames it.
1315 File time and attributes are preserved.
1317 @param ustrSourceFileURL [in]
1318 Full qualified URL of the source file.
1320 @param ustrDestFileURL [in]
1321 Full qualified URL of the destination file. An existing directory is NOT a valid destination !
1323 @return
1324 E_None on success
1325 E_INVAL the format of the parameters was not valid
1326 E_NOMEM not enough memory for allocating structures
1327 E_ACCES permission denied
1328 E_PERM operation not permitted
1329 E_NAMETOOLONG file name too long
1330 E_NOENT no such file or directory
1331 E_ROFS read-only file system
1333 @see copy()
1336 inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1338 return static_cast< RC >( osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1341 /** Remove a regular file.
1343 @param ustrFileURL [in]
1344 Full qualified URL of the file to remove.
1346 @return
1347 E_None on success
1348 E_INVAL the format of the parameters was not valid
1349 E_NOMEM not enough memory for allocating structures
1350 E_ACCES permission denied
1351 E_PERM operation not permitted
1352 E_NAMETOOLONG file name too long
1353 E_NOENT no such file or directory
1354 E_ISDIR is a directory
1355 E_ROFS read-only file system
1356 E_FAULT bad address
1357 E_LOOP too many symbolic links encountered
1358 E_IO on I/O errors
1359 E_BUSY device or resource busy
1360 E_INTR function call was interrupted
1361 E_LOOP too many symbolic links encountered
1362 E_MULTIHOP multihop attempted
1363 E_NOLINK link has been severed
1364 E_TXTBSY text file busy
1366 @see open()
1369 inline static RC remove( const ::rtl::OUString& ustrFileURL )
1371 return static_cast< RC >( osl_removeFile( ustrFileURL.pData ) );
1374 /** Set file attributes.
1376 @param ustrFileURL [in]
1377 The full qualified file URL.
1379 @param uAttributes [in]
1380 Attributes of the file to be set.
1382 @return
1383 E_None on success
1384 E_INVAL the format of the parameters was not valid
1386 @see FileStatus
1389 inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
1391 return static_cast< RC >( osl_setFileAttributes( ustrFileURL.pData, uAttributes ) );
1394 /** Set the file time.
1396 @param ustrFileURL [in]
1397 The full qualified URL of the file.
1399 @param rCreationTime [in]
1400 Creation time of the given file.
1402 @param rLastAccessTime [in]
1403 Time of the last access of the given file.
1405 @param rLastWriteTime [in]
1406 Time of the last modifying of the given file.
1408 @return
1409 E_None on success
1410 E_INVAL the format of the parameters was not valid
1411 E_NOENT no such file or directory not found
1413 @see FileStatus
1416 inline static RC setTime(
1417 const ::rtl::OUString& ustrFileURL,
1418 const TimeValue& rCreationTime,
1419 const TimeValue& rLastAccessTime,
1420 const TimeValue& rLastWriteTime )
1422 return static_cast< RC >( osl_setFileTime(
1423 ustrFileURL.pData,
1424 &rCreationTime,
1425 &rLastAccessTime,
1426 &rLastWriteTime ) );
1429 friend class DirectoryItem;
1432 // -----------------------------------------------------------------------------
1433 /** The directory item class object provides access to file status information.
1435 @see FileStatus
1438 class DirectoryItem: public FileBase
1440 oslDirectoryItem _pData;
1442 public:
1444 /** Constructor.
1447 DirectoryItem(): _pData( NULL )
1451 /** Copy constructor.
1454 DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
1456 if( _pData )
1457 osl_acquireDirectoryItem( _pData );
1460 /** Destructor.
1463 ~DirectoryItem()
1465 if( _pData )
1466 osl_releaseDirectoryItem( _pData );
1469 /** Assignment operator.
1472 DirectoryItem& operator=(const DirectoryItem& rItem )
1474 if (&rItem != this)
1476 if( _pData )
1477 osl_releaseDirectoryItem( _pData );
1479 _pData = rItem._pData;
1481 if( _pData )
1482 osl_acquireDirectoryItem( _pData );
1484 return *this;
1487 /** Check for validity of this instance.
1489 @return
1490 sal_True if object is valid directory item else sal_False.
1493 inline sal_Bool is()
1495 return _pData != NULL;
1498 /** Retrieve a single directory item.
1500 Retrieves a single directory item. The returned handle has an initial refcount of 1.
1501 Due to performance issues it is not recommended to use this function while
1502 enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
1504 @param ustrFileURL [in]
1505 An absolute file URL.
1507 @param rItem [out]
1508 On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
1509 The handle has to be released by a call to osl_releaseDirectoryItem().
1511 @return
1512 E_None on success
1513 E_INVAL the format of the parameters was not valid
1514 E_NOMEM not enough memory for allocating structures
1515 E_ACCES permission denied
1516 E_MFILE too many open files used by the process
1517 E_NFILE too many open files in the system
1518 E_NOENT no such file or directory
1519 E_LOOP too many symbolic links encountered
1520 E_NAMETOOLONG the file name is too long
1521 E_NOTDIR a component of the path prefix of path is not a directory
1522 E_IO on I/O errors
1523 E_MULTIHOP multihop attempted
1524 E_NOLINK link has been severed
1525 E_FAULT bad address
1526 E_INTR the function call was interrupted
1528 @see FileStatus
1529 @see Directory::getNextItem()
1532 static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
1534 if( rItem._pData)
1536 osl_releaseDirectoryItem( rItem._pData );
1537 rItem._pData = NULL;
1540 return static_cast< RC >( osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData ) );
1543 /** Retrieve information about a single file or directory.
1545 @param rStatus [in|out]
1546 Reference to a class which receives the information of the file or directory
1547 represented by this directory item.
1549 @return
1550 E_None on success
1551 E_NOMEM not enough memory for allocating structures
1552 E_INVAL the format of the parameters was not valid
1553 E_LOOP too many symbolic links encountered
1554 E_ACCES permission denied
1555 E_NOENT no such file or directory
1556 E_NAMETOOLONG file name too long
1557 E_BADF invalid oslDirectoryItem parameter
1558 E_FAULT bad address
1559 E_OVERFLOW value too large for defined data type
1560 E_INTR function call was interrupted
1561 E_NOLINK link has been severed
1562 E_MULTIHOP components of path require hopping to multiple remote machines and the file system does not allow it
1563 E_MFILE too many open files used by the process
1564 E_NFILE too many open files in the system
1565 E_NOSPC no space left on device
1566 E_NXIO no such device or address
1567 E_IO on I/O errors
1568 E_NOSYS function not implemented
1570 @see get()
1571 @see Directory::getNextItem()
1572 @see FileStatus
1575 inline RC getFileStatus( FileStatus& rStatus )
1577 return static_cast< RC >( osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask ) );
1580 /** Determine if a directory item point the same underlying file
1582 The comparison is done first by URL, and then by resolving links to
1583 find the target, and finally by comparing inodes on unix.
1585 @param[in] pOther
1586 A directory handle to compare with the underlying object's item
1588 @return
1589 sal_True: if the items point to an identical resource<br>
1590 sal_False: if the items point to a different resource, or a fatal error occured<br>
1592 @see osl_getDirectoryItem()
1594 @since LibreOffice 3.6
1596 inline sal_Bool isIdenticalTo( const DirectoryItem &pOther )
1598 return osl_identicalDirectoryItem( _pData, pOther._pData );
1601 friend class Directory;
1604 //###########################################
1606 /** Base class for observers of directory creation notifications.
1608 Clients which uses the method createDirectoryPath of the class
1609 Directory may want to be informed about the directories that
1610 have been created. This may be accomplished by deriving from
1611 this base class and overwriting the virtual function
1612 DirectoryCreated.
1614 @see Directory::createPath
1616 class DirectoryCreationObserver
1618 public:
1619 virtual ~DirectoryCreationObserver() {}
1621 /** This method will be called when a new directory has been
1622 created and needs to be overwritten by derived classes.
1623 You must not delete the directory that was just created
1624 otherwise you will run into an endless loop.
1626 @param aDirectoryUrl
1627 [in]The absolute file URL of the directory that was just created by
1628 ::osl::Directory::createPath.
1630 virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
1633 //###########################################
1634 // This just an internal helper function for
1635 // private use.
1636 extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
1638 (static_cast<DirectoryCreationObserver*>(pData))->DirectoryCreated(aDirectoryUrl);
1641 /** The directory class object provides a enumeration of DirectoryItems.
1643 @see DirectoryItem
1644 @see File
1647 class Directory: public FileBase
1649 oslDirectory _pData;
1650 ::rtl::OUString _aPath;
1652 /** Copy constructor.
1655 Directory( Directory& );
1657 /** Assignment operator.
1660 Directory& operator = ( Directory& );
1662 public:
1664 /** Constructor.
1666 @param strPath [in]
1667 The full qualified URL of the directory.
1668 Relative URLs are not allowed.
1671 Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath )
1675 /** Destructor.
1678 ~Directory()
1680 close();
1683 /** Obtain the URL.
1685 @return
1686 the URL with which this Directory instance was created.
1688 @since LibreOffice 4.1
1690 inline rtl::OUString getURL() const { return _aPath; }
1692 /** Open a directory for enumerating its contents.
1694 @return
1695 E_None on success
1696 E_INVAL the format of the parameters was not valid
1697 E_NOENT the specified path doesn't exist
1698 E_NOTDIR the specified path is not an directory
1699 E_NOMEM not enough memory for allocating structures
1700 E_ACCES permission denied
1701 E_MFILE too many open files used by the process
1702 E_NFILE too many open files in the system
1703 E_NAMETOOLONG File name too long
1704 E_LOOP Too many symbolic links encountered
1706 @see getNextItem()
1707 @see close()
1710 inline RC open()
1712 return static_cast< RC >( osl_openDirectory( _aPath.pData, &_pData ) );
1715 /** Query if directory is open.
1717 Query if directory is open and so item enumeration is valid.
1719 @return
1720 sal_True if the directory is open else sal_False.
1722 @see open()
1723 @see close()
1726 inline sal_Bool isOpen() { return _pData != NULL; }
1728 /** Close a directory.
1730 @return
1731 E_None on success
1732 E_INVAL the format of the parameters was not valid
1733 E_NOMEM not enough memory for allocating structures
1734 E_BADF invalid oslDirectory parameter
1735 E_INTR the function call was interrupted
1737 @see open()
1740 inline RC close()
1742 oslFileError Error = osl_File_E_BADF;
1744 if( _pData )
1746 Error=osl_closeDirectory( _pData );
1747 _pData = NULL;
1750 return static_cast< RC >( Error );
1754 /** Resets the directory item enumeration to the beginning.
1756 @return
1757 E_None on success
1758 E_INVAL the format of the parameters was not valid
1759 E_NOENT the specified path doesn't exist
1760 E_NOTDIR the specified path is not an directory
1761 E_NOMEM not enough memory for allocating structures
1762 E_ACCES permission denied
1763 E_MFILE too many open files used by the process
1764 E_NFILE too many open files in the system
1765 E_NAMETOOLONG File name too long
1766 E_LOOP Too many symbolic links encountered
1768 @see open()
1771 inline RC reset()
1773 close();
1774 return open();
1777 /** Retrieve the next item of a previously opened directory.
1779 Retrieves the next item of a previously opened directory.
1781 @param rItem [out]
1782 On success a valid DirectoryItem.
1784 @param nHint [in]
1785 With this parameter the caller can tell the implementation that (s)he
1786 is going to call this function uHint times afterwards. This enables the implementation to
1787 get the information for more than one file and cache it until the next calls.
1789 @return
1790 E_None on success
1791 E_INVAL the format of the parameters was not valid
1792 E_NOMEM not enough memory for allocating structures
1793 E_NOENT no more entries in this directory
1794 E_BADF invalid oslDirectory parameter
1795 E_OVERFLOW the value too large for defined data type
1797 @see DirectoryItem
1800 inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
1802 if( rItem._pData )
1804 osl_releaseDirectoryItem( rItem._pData );
1805 rItem._pData = 0;
1807 return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
1811 /** Retrieve information about a volume.
1813 Retrieves information about a volume. A volume can either be a mount point, a network
1814 resource or a drive depending on Operating System and File System.
1816 @param ustrDirectoryURL [in]
1817 Full qualified URL of the volume
1819 @param rInfo [out]
1820 On success it receives information about the volume.
1822 @return
1823 E_None on success
1824 E_NOMEM not enough memory for allocating structures
1825 E_INVAL the format of the parameters was not valid
1826 E_NOTDIR not a directory
1827 E_NAMETOOLONG file name too long
1828 E_NOENT no such file or directory
1829 E_ACCES permission denied
1830 E_LOOP too many symbolic links encountered
1831 E_FAULT Bad address
1832 E_IO on I/O errors
1833 E_NOSYS function not implemented
1834 E_MULTIHOP multihop attempted
1835 E_NOLINK link has been severed
1836 E_INTR function call was interrupted
1838 @see FileStatus
1839 @see VolumeInfo
1842 inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
1844 return static_cast< RC >( osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask ) );
1847 /** Create a directory.
1849 @param ustrDirectoryURL [in]
1850 Full qualified URL of the directory to create.
1852 @return
1853 E_None on success
1854 E_INVAL the format of the parameters was not valid
1855 E_NOMEM not enough memory for allocating structures
1856 E_EXIST file exists
1857 E_ACCES permission denied
1858 E_NAMETOOLONG file name too long
1859 E_NOENT no such file or directory
1860 E_NOTDIR not a directory
1861 E_ROFS read-only file system
1862 E_NOSPC no space left on device
1863 E_DQUOT quota exceeded
1864 E_LOOP too many symbolic links encountered
1865 E_FAULT bad address
1866 E_IO on I/O errors
1867 E_MLINK too many links
1868 E_MULTIHOP multihop attempted
1869 E_NOLINK link has been severed
1871 @see remove()
1874 inline static RC create( const ::rtl::OUString& ustrDirectoryURL )
1876 return static_cast< RC >( osl_createDirectory( ustrDirectoryURL.pData ) );
1879 /** Remove an empty directory.
1881 @param ustrDirectoryURL [in]
1882 Full qualified URL of the directory.
1884 @return
1885 E_None on success
1886 E_INVAL the format of the parameters was not valid
1887 E_NOMEM not enough memory for allocating structures
1888 E_PERM operation not permitted
1889 E_ACCES permission denied
1890 E_NOENT no such file or directory
1891 E_NOTDIR not a directory
1892 E_NOTEMPTY directory not empty
1893 E_FAULT bad address
1894 E_NAMETOOLONG file name too long
1895 E_BUSY device or resource busy
1896 E_ROFS read-only file system
1897 E_LOOP too many symbolic links encountered
1898 E_BUSY device or resource busy
1899 E_EXIST file exists
1900 E_IO on I/O errors
1901 E_MULTIHOP multihop attempted
1902 E_NOLINK link has been severed
1904 @see create()
1907 inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
1909 return static_cast< RC >( osl_removeDirectory( ustrDirectoryURL.pData ) );
1912 /** Create a directory path.
1914 The osl_createDirectoryPath function creates a specified directory path.
1915 All nonexisting sub directories will be created.
1916 <p><strong>PLEASE NOTE:</strong> You cannot rely on getting the error code
1917 E_EXIST for existing directories. Programming against this error code is
1918 in general a strong indication of a wrong usage of osl_createDirectoryPath.</p>
1920 @param aDirectoryUrl
1921 [in] The absolute file URL of the directory path to create.
1922 A relative file URL will not be accepted.
1924 @param aDirectoryCreationObserver
1925 [in] Pointer to an instance of type DirectoryCreationObserver that will
1926 be informed about the creation of a directory. The value of this
1927 parameter may be NULL, in this case notifications will not be sent.
1929 @return
1930 <dl>
1931 <dt>E_None</dt>
1932 <dd>On success</dd>
1933 <dt>E_INVAL</dt>
1934 <dd>The format of the parameters was not valid</dd>
1935 <dt>E_ACCES</dt>
1936 <dd>Permission denied</dd>
1937 <dt>E_EXIST</dt>
1938 <dd>The final node of the specified directory path already exist</dd>
1939 <dt>E_NAMETOOLONG</dt>
1940 <dd>The name of the specified directory path exceeds the maximum allowed length</dd>
1941 <dt>E_NOTDIR</dt>
1942 <dd>A component of the specified directory path already exist as file in any part of the directory path</dd>
1943 <dt>E_ROFS</dt>
1944 <dd>Read-only file system</dd>
1945 <dt>E_NOSPC</dt>
1946 <dd>No space left on device</dd>
1947 <dt>E_DQUOT</dt>
1948 <dd>Quota exceeded</dd>
1949 <dt>E_FAULT</dt>
1950 <dd>Bad address</dd>
1951 <dt>E_IO</dt>
1952 <dd>I/O error</dd>
1953 <dt>E_LOOP</dt>
1954 <dd>Too many symbolic links encountered</dd>
1955 <dt>E_NOLINK</dt>
1956 <dd>Link has been severed</dd>
1957 <dt>E_invalidError</dt>
1958 <dd>An unknown error occurred</dd>
1959 </dl>
1961 @see DirectoryCreationObserver
1962 @see create
1964 static RC createPath(
1965 const ::rtl::OUString& aDirectoryUrl,
1966 DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
1968 return static_cast< RC >(osl_createDirectoryPath(
1969 aDirectoryUrl.pData,
1970 (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
1971 aDirectoryCreationObserver));
1975 } /* namespace osl */
1977 #endif // INCLUDED_OSL_FILE_HXX
1979 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */