update dev300-m58
[ooovba.git] / sal / inc / osl / file.hxx
blob49f19b77b4d0dd7e6e777606c144d2e4236ade58
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: file.hxx,v $
10 * $Revision: 1.39 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 /** @HTML */
33 #ifndef _OSL_FILE_HXX_
34 #define _OSL_FILE_HXX_
36 #ifdef __cplusplus
38 #include <osl/time.h>
39 # include <rtl/memory.h>
40 # include <rtl/ustring.hxx>
42 #include <osl/file.h>
43 # include <rtl/byteseq.hxx>
45 #include <stdio.h>
47 namespace osl
51 // -----------------------------------------------------------------------------
52 /** Base class for all File System specific objects.
54 @see Directory
55 @see DirectoryItem
56 @see File
59 class FileBase
61 public:
63 enum RC {
64 E_None = osl_File_E_None,
65 E_PERM = osl_File_E_PERM,
66 E_NOENT = osl_File_E_NOENT,
67 E_SRCH = osl_File_E_SRCH,
68 E_INTR = osl_File_E_INTR,
69 E_IO = osl_File_E_IO,
70 E_NXIO = osl_File_E_NXIO,
71 E_2BIG = osl_File_E_2BIG,
72 E_NOEXEC = osl_File_E_NOEXEC,
73 E_BADF = osl_File_E_BADF,
74 E_CHILD = osl_File_E_CHILD,
75 E_AGAIN = osl_File_E_AGAIN,
76 E_NOMEM = osl_File_E_NOMEM,
77 E_ACCES = osl_File_E_ACCES,
78 E_FAULT = osl_File_E_FAULT,
79 E_BUSY = osl_File_E_BUSY,
80 E_EXIST = osl_File_E_EXIST,
81 E_XDEV = osl_File_E_XDEV,
82 E_NODEV = osl_File_E_NODEV,
83 E_NOTDIR = osl_File_E_NOTDIR,
84 E_ISDIR = osl_File_E_ISDIR,
85 E_INVAL = osl_File_E_INVAL,
86 E_NFILE = osl_File_E_NFILE,
87 E_MFILE = osl_File_E_MFILE,
88 E_NOTTY = osl_File_E_NOTTY,
89 E_FBIG = osl_File_E_FBIG,
90 E_NOSPC = osl_File_E_NOSPC,
91 E_SPIPE = osl_File_E_SPIPE,
92 E_ROFS = osl_File_E_ROFS,
93 E_MLINK = osl_File_E_MLINK,
94 E_PIPE = osl_File_E_PIPE,
95 E_DOM = osl_File_E_DOM,
96 E_RANGE = osl_File_E_RANGE,
97 E_DEADLK = osl_File_E_DEADLK,
98 E_NAMETOOLONG = osl_File_E_NAMETOOLONG,
99 E_NOLCK = osl_File_E_NOLCK,
100 E_NOSYS = osl_File_E_NOSYS,
101 E_NOTEMPTY = osl_File_E_NOTEMPTY,
102 E_LOOP = osl_File_E_LOOP,
103 E_ILSEQ = osl_File_E_ILSEQ,
104 E_NOLINK = osl_File_E_NOLINK,
105 E_MULTIHOP = osl_File_E_MULTIHOP,
106 E_USERS = osl_File_E_USERS,
107 E_OVERFLOW = osl_File_E_OVERFLOW,
108 E_NOTREADY = osl_File_E_NOTREADY,
109 E_TXTBSY = osl_File_E_TXTBSY,
110 E_invalidError = osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
111 E_TIMEDOUT = osl_File_E_TIMEDOUT,
112 E_NETWORK = osl_File_E_NETWORK
116 public:
118 /** Determine a valid unused canonical name for a requested name.
120 Determines a valid unused canonical name for a requested name.
121 Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
122 If a file or directory with the requested name already exists a new name is generated following
123 the common rules on the actual Operating System and File System.
125 @param ustrRequestedURL [in]
126 Requested name of a file or directory.
128 @param pustrValidURL [out]
129 On success receives a name which is unused and valid on the actual Operating System and
130 File System.
132 @return
133 E_None on success
134 E_INVAL the format of the parameters was not valid
136 @see DirectoryItem::getFileStatus()
139 static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
141 return (RC) osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData );
144 /** Convert a path relative to a given directory into an full qualified file URL.
146 Convert a path relative to a given directory into an full qualified file URL.
147 The function resolves symbolic links if possible and path ellipses, so on success
148 the resulting absolute path is fully resolved.
150 @param ustrBaseDirectoryURL [in]
151 Base directory URL to which the relative path is related to.
153 @param ustrRelativeFileURL [in]
154 An URL of a file or directory relative to the directory path specified by ustrBaseDirectoryURL
155 or an absolute path.
156 If ustrRelativeFileURL denotes an absolute path ustrBaseDirectoryURL will be ignored.
158 @param ustrAbsoluteFileURL [out]
159 On success it receives the full qualified absoulte file URL.
161 @return
162 E_None on success
163 E_INVAL the format of the parameters was not valid
164 E_NOMEM not enough memory for allocating structures
165 E_NOTDIR not a directory
166 E_ACCES permission denied
167 E_NOENT no such file or directory
168 E_NAMETOOLONG file name too long
169 E_OVERFLOW value too large for defined data type
170 E_FAULT bad address
171 E_INTR function call was interrupted
172 E_LOOP too many symbolic links encountered
173 E_MULTIHOP multihop attempted
174 E_NOLINK link has been severed
176 @see DirectoryItem::getFileStatus()
179 static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
181 return (RC) osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData );
184 /** Convert a file URL into a system dependend path.
186 @param ustrFileURL [in]
187 A File URL.
189 @param ustrSystemPath [out]
190 On success it receives the system path.
192 @return
193 E_None on success
194 E_INVAL the format of the parameters was not valid
196 @see getFileURLFromSystemPath()
199 static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
201 return (RC) osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData );
204 /** Convert a system dependend path into a file URL.
206 @param ustrSystemPath [in]
207 A System dependent path of a file or directory.
209 @param ustrFileURL [out]
210 On success it receives the file URL.
212 @return
213 E_None on success
214 E_INVAL the format of the parameters was not valid
216 @see getSystemPathFromFileURL()
219 static inline RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
221 return (RC) osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData );
224 /** Searche a full qualified system path or a file URL.
226 @param ustrFileName [in]
227 A system dependent path, a file URL, a file or relative directory
229 @param ustrSearchPath [in]
230 A list of system paths, in which a given file has to be searched. The Notation of a path list is
231 system dependend, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
232 These paths are only for the search of a file or a relative path, otherwise it will be ignored.
233 If ustrSearchPath is NULL or while using the search path the search failed, the function searches for
234 a matching file in all system directories and in the directories listed in the PATH environment
235 variable.
236 The value of an environment variable should be used (e.g. LD_LIBRARY_PATH) if the caller is not
237 aware of the Operating System and so doesn't know which path list delimiter to use.
239 @param ustrFileURL [out]
240 On success it receives the full qualified file URL.
242 @return
243 E_None on success
244 E_INVAL the format of the parameters was not valid
245 E_NOTDIR not a directory
246 E_NOENT no such file or directory not found
248 @see getFileURLFromSystemPath()
249 @see getSystemPathFromFileURL()
252 static inline RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
254 return (RC) osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData );
257 /** Retrieves the file URL of the system's temporary directory path.
259 @param ustrTempDirURL[out]
260 On success receives the URL of system's temporary directory path.
262 @return
263 E_None on success
264 E_NOENT no such file or directory not found
267 static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
269 return (RC) osl_getTempDirURL( &ustrTempDirURL.pData );
272 /** Creates a temporary file in the directory provided by the caller or the
273 directory returned by getTempDirURL.
274 Under UNIX Operating Systems the file will be created with read and write
275 access for the user exclusively.
276 If the caller requests only a handle to the open file but not the name of
277 it, the file will be automatically removed on close else the caller is
278 responsible for removing the file on success.<br><br>
280 @param pustrDirectoryURL [in]
281 Specifies the full qualified URL where the temporary file should be created.
282 If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
284 @param pHandle [out]
285 On success receives a handle to the open file.
286 If pHandle is 0 the file will be closed on return, in this case
287 pustrTempFileURL must not be 0.
289 @param pustrTempFileURL [out]
290 On success receives the full qualified URL of the temporary file.
291 If pustrTempFileURL is 0 the file will be automatically removed
292 on close, in this case pHandle must not be 0.
293 If pustrTempFileURL is not 0 the caller receives the name of the
294 created file and is responsible for removing the file.
296 @descr
297 Description of the different pHandle, ppustrTempFileURL parameter combinations.
298 pHandle is 0 and pustrTempDirURL is 0 - this combination is invalid<br>
299 pHandle is not 0 and pustrTempDirURL is 0 - a handle to the open file
300 will be returned on success and the file will be automatically removed on close<br>
301 pHandle is 0 and pustrTempDirURL is not 0 - the name of the file will be
302 returned, the caller is responsible for opening, closing and removing the file.<br>
303 pHandle is not 0 and pustrTempDirURL is not 0 - a handle to the open file as well as
304 the file name will be returned, the caller is responsible for closing and removing
305 the file.<br>
307 @return
308 E_None on success
309 E_INVAL the format of the parameter is invalid
310 E_NOMEM not enough memory for allocating structures
311 E_ACCES Permission denied
312 E_NOENT No such file or directory
313 E_NOTDIR Not a directory
314 E_ROFS Read-only file system
315 E_NOSPC No space left on device
316 E_DQUOT Quota exceeded
318 @see getTempDirURL()
321 static inline RC createTempFile(
322 ::rtl::OUString* pustrDirectoryURL,
323 oslFileHandle* pHandle,
324 ::rtl::OUString* pustrTempFileURL)
326 rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : 0;
327 rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : 0;
329 return (RC) osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url);
334 // -----------------------------------------------------------------------------
335 /** The VolumeDevice class.
337 @see VolumeInfo
339 #ifdef OS2
340 class VolumeInfo;
341 #endif
343 class VolumeDevice : public FileBase
345 #ifdef OS2
346 public:
347 #endif
348 oslVolumeDeviceHandle _aHandle;
350 public:
352 /** Constructor.
355 VolumeDevice() : _aHandle( NULL )
359 /** Copy constructor.
361 @param rDevice
362 The other volume device.
365 VolumeDevice( const VolumeDevice & rDevice )
367 _aHandle = rDevice._aHandle;
368 if ( _aHandle )
369 osl_acquireVolumeDeviceHandle( _aHandle );
372 /** Destructor.
375 ~VolumeDevice()
377 if ( _aHandle )
378 osl_releaseVolumeDeviceHandle( _aHandle );
381 /** Assignment operator.
383 @param rDevice
384 The other volume device.
387 inline VolumeDevice & operator =( const VolumeDevice & rDevice )
389 oslVolumeDeviceHandle newHandle = rDevice._aHandle;
391 if ( newHandle )
392 osl_acquireVolumeDeviceHandle( newHandle );
394 if ( _aHandle )
395 osl_releaseVolumeDeviceHandle( _aHandle );
397 _aHandle = newHandle;
399 return *this;
402 /** Automount a volume device.
404 @return
405 E_None on success
407 @todo
408 specify all error codes that may be returned
411 inline RC automount()
413 return (RC)osl_automountVolumeDevice( _aHandle );
416 /** Unmount a volume device.
418 @return
419 E_None on success
421 @todo
422 specify all error codes that may be returned
425 inline RC unmount()
427 return (RC)osl_unmountVolumeDevice( _aHandle );
430 /** Get the full qualified URL where a device is mounted to.
432 @return
433 The full qualified URL where the device is mounted to.
435 inline rtl::OUString getMountPath()
437 rtl::OUString aPath;
438 osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
439 return aPath;
442 friend class VolumeInfo;
445 // -----------------------------------------------------------------------------
447 #define VolumeInfoMask_Attributes osl_VolumeInfo_Mask_Attributes
448 #define VolumeInfoMask_TotalSpace osl_VolumeInfo_Mask_TotalSpace
449 #define VolumeInfoMask_UsedSpace osl_VolumeInfo_Mask_UsedSpace
450 #define VolumeInfoMask_FreeSpace osl_VolumeInfo_Mask_FreeSpace
451 #define VolumeInfoMask_MaxNameLength osl_VolumeInfo_Mask_MaxNameLength
452 #define VolumeInfoMask_MaxPathLength osl_VolumeInfo_Mask_MaxPathLength
453 #define VolumeInfoMask_FileSystemName osl_VolumeInfo_Mask_FileSystemName
454 #define VolumeInfoMask_FileSystemCaseHandling osl_VolumeInfo_Mask_FileSystemCaseHandling
456 class Directory;
458 /** The VolumeInfo class.
460 Neither copy nor assignment is allowed for this class.
462 @see Directory::getVolumeInfo
466 class VolumeInfo
468 oslVolumeInfo _aInfo;
469 sal_uInt32 _nMask;
470 VolumeDevice _aDevice;
472 /** Copy constructor.
475 VolumeInfo( VolumeInfo& );
477 /** Assginment operator.
480 VolumeInfo& operator = ( VolumeInfo& );
482 public:
484 /** Constructor.
486 @param nMask
487 Set of flaggs decribing the demanded information.
490 VolumeInfo( sal_uInt32 nMask ): _nMask( nMask )
492 _aInfo.uStructSize = sizeof( oslVolumeInfo );
493 rtl_fillMemory( &_aInfo.uValidFields, sizeof( oslVolumeInfo ) - sizeof( sal_uInt32 ), 0 );
494 _aInfo.pDeviceHandle = &_aDevice._aHandle;
497 /** Destructor.
500 ~VolumeInfo()
502 if( _aInfo.ustrFileSystemName )
503 rtl_uString_release( _aInfo.ustrFileSystemName );
506 /** Check if specified fields are valid.
508 @param nMask
509 Set of flags for the fields to check.
511 @return sal_True if all fields are valid else sal_False.
514 inline sal_Bool isValid( sal_uInt32 nMask ) const
516 return ( nMask & _aInfo.uValidFields ) == nMask;
519 /** Check the remote flag.
521 @return
522 sal_True if Attributes are valid and the volume is remote else sal_False.
525 inline sal_Bool getRemoteFlag() const
527 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Remote);
530 /** Check the removeable flag.
532 @return
533 sal_True if attributes are valid and the volume is removable else sal_False.
536 inline sal_Bool getRemoveableFlag() const
538 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Removeable);
541 /** Check the compact disc flag.
543 @return
544 sal_True if attributes are valid and the volume is a CDROM else sal_False.
547 inline sal_Bool getCompactDiscFlag() const
549 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc);
552 /** Check the floppy disc flag.
554 @return
555 sal_True if attributes are valid and the volume is a floppy disk else sal_False.
558 inline sal_Bool getFloppyDiskFlag() const
560 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk);
563 /** Check the fixed disk flag.
565 @return
566 sal_True if attributes are valid and the volume is a fixed disk else sal_False.
569 inline sal_Bool getFixedDiskFlag() const
571 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk);
574 /** Check the RAM disk flag.
576 @return
577 sal_True if attributes are valid and the volume is a RAM disk else sal_False.
580 inline sal_Bool getRAMDiskFlag() const
582 return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk);
585 /** Determine the total space of a volume device.
587 @return
588 The total diskspace of this volume if this information is valid,
589 0 otherwise.
592 inline sal_uInt64 getTotalSpace() const
594 return _aInfo.uTotalSpace;
597 /** Determine the free space of a volume device.
599 @return
600 The free diskspace of this volume if this information is valid,
601 0 otherwise.
604 inline sal_uInt64 getFreeSpace() const
606 return _aInfo.uFreeSpace;
609 /** Determine the used space of a volume device.
611 @return
612 The used diskspace of this volume if this information is valid,
613 0 otherwise.
616 inline sal_uInt64 getUsedSpace() const
618 return _aInfo.uUsedSpace;
621 /** Determine the maximal length of a file name.
623 @return
624 The maximal length of a file name if this information is valid,
625 0 otherwise.
628 inline sal_uInt32 getMaxNameLength() const
630 return _aInfo.uMaxNameLength;
633 /** Determine the maximal length of a path name.
635 @return
636 The maximal length of a path if this information is valid,
637 0 otherwise.
640 inline sal_uInt32 getMaxPathLength() const
642 return _aInfo.uMaxPathLength;
645 /** Determine the name of the volume device's File System.
647 @return
648 The name of the volume's fielsystem if this information is valid,
649 otherwise an empty string.
652 inline ::rtl::OUString getFileSystemName() const
654 return _aInfo.ustrFileSystemName ? ::rtl::OUString( _aInfo.ustrFileSystemName ) : ::rtl::OUString();
658 /** Get the volume device handle.
660 @return
661 The device handle of the volume if this information is valid,
662 otherwise returns NULL;
665 inline VolumeDevice getDeviceHandle() const
667 return _aDevice;
670 /** Return whether the file system is case sensitive or
671 case insensitive
673 @return
674 true if the file system is case sensitive false otherwise
676 bool isCaseSensitiveFileSystem() const
678 return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive);
681 /** Return whether the file system preserves the case of
682 file and directory names or not
684 @return
685 true if the file system preserves the case of file and
686 directory names false otherwise
688 bool isCasePreservingFileSystem() const
690 return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Is_Preserved);
693 friend class Directory;
696 // -----------------------------------------------------------------------------
698 #define FileStatusMask_Type osl_FileStatus_Mask_Type
699 #define FileStatusMask_Attributes osl_FileStatus_Mask_Attributes
700 #define FileStatusMask_CreationTime osl_FileStatus_Mask_CreationTime
701 #define FileStatusMask_AccessTime osl_FileStatus_Mask_AccessTime
702 #define FileStatusMask_ModifyTime osl_FileStatus_Mask_ModifyTime
703 #define FileStatusMask_FileSize osl_FileStatus_Mask_FileSize
704 #define FileStatusMask_FileName osl_FileStatus_Mask_FileName
705 #define FileStatusMask_FileURL osl_FileStatus_Mask_FileURL
706 #define FileStatusMask_LinkTargetURL osl_FileStatus_Mask_LinkTargetURL
707 #define FileStatusMask_All osl_FileStatus_Mask_All
708 #define FileStatusMask_Validate osl_FileStatus_Mask_Validate
710 #define Attribute_ReadOnly osl_File_Attribute_ReadOnly
711 #define Attribute_Hidden osl_File_Attribute_Hidden
712 #define Attribute_Executable osl_File_Attribute_Executable
713 #define Attribute_GrpWrite osl_File_Attribute_GrpWrite
714 #define Attribute_GrpRead osl_File_Attribute_GrpRead
715 #define Attribute_GrpExe osl_File_Attribute_GrpExe
716 #define Attribute_OwnWrite osl_File_Attribute_OwnWrite
717 #define Attribute_OwnRead osl_File_Attribute_OwnRead
718 #define Attribute_OwnExe osl_File_Attribute_OwnExe
719 #define Attribute_OthWrite osl_File_Attribute_OthWrite
720 #define Attribute_OthRead osl_File_Attribute_OthRead
721 #define Attribute_OthExe osl_File_Attribute_OthExe
723 class DirectoryItem;
725 /** The FileStatus class.
727 @see DirectoryItem::getFileStatus
730 class FileStatus
732 oslFileStatus _aStatus;
733 sal_uInt32 _nMask;
735 /** Copy constructor.
738 FileStatus( FileStatus& );
740 /** Assignment operator.
743 FileStatus& operator = ( FileStatus& );
745 public:
747 enum Type {
748 Directory = osl_File_Type_Directory,
749 Volume = osl_File_Type_Volume,
750 Regular = osl_File_Type_Regular,
751 Fifo = osl_File_Type_Fifo,
752 Socket = osl_File_Type_Socket,
753 Link = osl_File_Type_Link,
754 Special = osl_File_Type_Special,
755 Unknown = osl_File_Type_Unknown
758 /** Constructor.
760 @param nMask
761 Set of flaggs decribing the demanded information.
764 FileStatus( sal_uInt32 nMask ): _nMask( nMask )
766 _aStatus.uStructSize = sizeof( oslFileStatus );
767 rtl_fillMemory( &_aStatus.uValidFields, sizeof( oslFileStatus ) - sizeof( sal_uInt32 ), 0 );
770 /** Destructor.
773 ~FileStatus()
775 if ( _aStatus.ustrFileURL )
776 rtl_uString_release( _aStatus.ustrFileURL );
777 if ( _aStatus.ustrLinkTargetURL )
778 rtl_uString_release( _aStatus.ustrLinkTargetURL );
779 if ( _aStatus.ustrFileName )
780 rtl_uString_release( _aStatus.ustrFileName );
783 /** Check if specified fields are valid.
785 @param nMask
786 Set of flags for the fields to check.
788 @return
789 sal_True if all fields are valid else sal_False.
792 inline sal_Bool isValid( sal_uInt32 nMask ) const
794 return ( nMask & _aStatus.uValidFields ) == nMask;
797 /** Get the file type.
799 @return
800 The file type if this information is valid, Unknown otherwise.
802 inline Type getFileType() const
804 return (_aStatus.uValidFields & FileStatusMask_Type) ? (Type) _aStatus.eType : Unknown;
807 /** Get the file attributes.
809 @return
810 The set of attribute flags of this file.
813 inline sal_uInt64 getAttributes() const
815 return _aStatus.uAttributes;
818 /** Get the creation time of this file.
820 @return
821 The creation time if this information is valid,
822 an uninitialized TimeValue otherwise.
825 inline TimeValue getCreationTime() const
827 return _aStatus.aCreationTime;
830 /** Get the file access time.
832 @return
833 The last access time if this information is valid,
834 an uninitialized TimeValue otherwise.
837 inline TimeValue getAccessTime() const
839 return _aStatus.aAccessTime;
842 /** Get the file modification time.
844 @return
845 The last modified time if this information is valid,
846 an uninitialized TimeValue otherwise.
849 inline TimeValue getModifyTime() const
851 return _aStatus.aModifyTime;
854 /** Get the size of the file.
856 @return
857 The actual file size if this information is valid, 0 otherwise.
860 inline sal_uInt64 getFileSize() const
862 return _aStatus.uFileSize;
865 /** Get the file name.
867 @return
868 The file name if this information is valid, an empty string otherwise.
871 inline ::rtl::OUString getFileName() const
873 return _aStatus.ustrFileName ? ::rtl::OUString(_aStatus.ustrFileName) : ::rtl::OUString();
877 /** Get the URL of the file.
879 @return
880 The full qualified URL of the file if this information is valid, an empty string otherwise.
883 inline ::rtl::OUString getFileURL() const
885 return _aStatus.ustrFileURL ? ::rtl::OUString(_aStatus.ustrFileURL) : ::rtl::OUString();
888 /** Get the link target URL.
890 @return
891 The link target URL if this information is valid, an empty string otherwise.
894 inline ::rtl::OUString getLinkTargetURL() const
896 return _aStatus.ustrLinkTargetURL ? ::rtl::OUString(_aStatus.ustrLinkTargetURL) : ::rtl::OUString();
899 friend class DirectoryItem;
903 // -----------------------------------------------------------------------------
904 /** The file class object provides access to file contents and attributes.
906 @see Directory
907 @see DirectoryItem
910 class File: public FileBase
912 oslFileHandle _pData;
913 ::rtl::OUString _aPath;
915 /** Copy constructor.
918 File( File& );
920 /** Assginment operator.
923 File& operator = ( File& );
925 public:
927 /** Constructor.
929 @param ustrFileURL [in]
930 The full qualified URL of the file. Relative paths are not allowed.
933 File( const ::rtl::OUString& ustrFileURL ): _pData( 0 ), _aPath( ustrFileURL ) {}
935 /** Destructor
938 inline ~File()
940 close();
943 #define OpenFlag_Read osl_File_OpenFlag_Read
944 #define OpenFlag_Write osl_File_OpenFlag_Write
945 #define OpenFlag_Create osl_File_OpenFlag_Create
946 #define OpenFlag_NoLock osl_File_OpenFlag_NoLock
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 (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 (RC) Error;
1024 #define Pos_Absolut osl_Pos_Absolut
1025 #define Pos_Current osl_Pos_Current
1026 #define Pos_End osl_Pos_End
1028 /** Set the internal position pointer of an open file.
1030 @param uHow [in]
1031 Distance to move the internal position pointer (from uPos).
1033 @param uPos [in]
1034 Absolute position from the beginning of the file.
1036 @return
1037 E_None on success
1038 E_INVAL the format of the parameters was not valid
1039 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1041 @see open()
1042 @see getPos()
1045 inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos )
1047 return (RC) osl_setFilePos( _pData, uHow, uPos );
1050 /** Retrieve the current position of the internal pointer of an open file.
1052 @param uPos [out]
1053 On success receives the current position of the file pointer.
1055 @return
1056 E_None on success
1057 E_INVAL the format of the parameters was not valid
1058 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1060 @see open()
1061 @see setPos()
1062 @see read()
1063 @see write()
1066 inline RC getPos( sal_uInt64& uPos )
1068 return (RC) osl_getFilePos( _pData, &uPos );
1071 /** Test if the end of a file is reached.
1073 @param pIsEOF [out]
1074 Points to a variable that receives the end-of-file status.
1076 @return
1077 E_None on success
1078 E_INVAL the format of the parameters was not valid
1079 E_INTR function call was interrupted
1080 E_IO on I/O errors
1081 E_ISDIR is a directory
1082 E_BADF bad file
1083 E_FAULT bad address
1084 E_AGAIN operation would block
1085 E_NOLINK link has been severed
1087 @see open()
1088 @see read()
1089 @see readLine()
1090 @see setPos()
1093 inline RC isEndOfFile( sal_Bool *pIsEOF )
1095 return (RC) osl_isEndOfFile( _pData, pIsEOF );
1098 /** Set the file size of an open file.
1100 Sets the file size of an open file. The file can be truncated or enlarged by the function.
1101 The position of the file pointer is not affeced by this function.
1103 @param uSize [in]
1104 New size in bytes.
1106 @return
1107 E_None on success
1108 E_INVAL the format of the parameters was not valid
1109 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1111 @see open()
1112 @see setPos()
1113 @see getStatus()
1116 inline RC setSize( sal_uInt64 uSize )
1118 return (RC) osl_setFileSize( _pData, uSize );
1121 /** Get the file size of an open file.
1123 Gets the file size of an open file.
1124 The position of the file pointer is not affeced by this function.
1126 @param rSize [out]
1127 Current size in bytes.
1129 @return
1130 E_None on success
1131 E_INVAL the format of the parameters was not valid
1132 E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1134 @see open()
1135 @see setPos()
1136 @see getSize()
1137 @see setSize()
1138 @see getStatus()
1141 inline RC getSize( sal_uInt64 &rSize )
1143 return (RC) osl_getFileSize( _pData, &rSize );
1146 /** Read a number of bytes from a file.
1148 Reads a number of bytes from a file. The internal file pointer is
1149 increased by the number of bytes read.
1151 @param pBuffer [out]
1152 Points to a buffer which receives data. The buffer must be large enough
1153 to hold uBytesRequested bytes.
1155 @param uBytesRequested [in]
1156 Number of bytes which should be retrieved.
1158 @param rBytesRead [out]
1159 On success the number of bytes which have actually been retrieved.
1161 @return
1162 E_None on success
1163 E_INVAL the format of the parameters was not valid
1164 E_INTR function call was interrupted
1165 E_IO on I/O errors
1166 E_ISDIR is a directory
1167 E_BADF bad file
1168 E_FAULT bad address
1169 E_AGAIN operation would block
1170 E_NOLINK link has been severed
1172 @see open()
1173 @see write()
1174 @see readLine()
1175 @see setPos()
1178 inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
1180 return (RC) osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead );
1183 /** Write a number of bytes to a file.
1185 Writes a number of bytes to a file.
1186 The internal file pointer is increased by the number of bytes read.
1188 @param pBuffer [in]
1189 Points to a buffer which contains the data.
1191 @param uBytesToWrite [in]
1192 Number of bytes which should be written.
1194 @param rBytesWritten [out]
1195 On success the number of bytes which have actually been written.
1197 @return
1198 E_None on success
1199 E_INVAL the format of the parameters was not valid
1200 E_FBIG file too large
1201 E_DQUOT quota exceeded
1202 E_AGAIN operation would block
1203 E_BADF bad file
1204 E_FAULT bad address
1205 E_INTR function call was interrupted
1206 E_IO on I/O errosr
1207 E_NOLCK no record locks available
1208 E_NOLINK link has been severed
1209 E_NOSPC no space left on device
1210 E_NXIO no such device or address
1212 @see open()
1213 @see read()
1214 @see setPos()
1217 inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
1219 return (RC) osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten );
1223 /** Read a line from a file.
1225 Reads a line from a file. The new line delimiter is NOT returned!
1227 @param aSeq [in/out]
1228 A reference to a ::rtl::ByteSequence that will hold the line read on success.
1230 @return
1231 E_None on success
1232 E_INVAL the format of the parameters was not valid
1233 E_INTR function call was interrupted
1234 E_IO on I/O errors
1235 E_ISDIR is a directory
1236 E_BADF bad file
1237 E_FAULT bad address
1238 E_AGAIN operation would block
1239 E_NOLINK link has been severed
1241 @see open()
1242 @see read()
1243 @see write()
1244 @see setPos()
1247 inline RC readLine( ::rtl::ByteSequence& aSeq )
1249 return (RC) osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) );
1252 /** Synchronize the memory representation of a file with that on the physical medium.
1254 The function ensures that all modified data and attributes of the file associated with
1255 the given file handle have been written to the physical medium.
1256 In case the hard disk has a write cache enabled, the data may not really be on
1257 permanent storage when osl_syncFile returns.
1259 @return
1260 <dl>
1261 <dt>E_None</dt>
1262 <dd>On success</dd>
1263 <dt>E_INVAL</dt>
1264 <dd>The value of the input parameter is invalid</dd>
1265 </dl>
1266 <br><p><strong>In addition to these error codes others may occur as well, for instance:</strong></p><br>
1267 <dt>E_BADF</dt>
1268 <dd>The file is not open for writing</dd>
1269 <dt>E_IO</dt>
1270 <dd>An I/O error occurred</dd>
1271 <dt>E_NOSPC</dt>
1272 <dd>There is no enough space on the target device</dd>
1273 <dt>E_ROFS</dt>
1274 <dd>The file is located on a read only file system</dd>
1275 <dt>E_TIMEDOUT</dt>
1276 <dd>A remote connection timed out. This may happen when a file is on a remote location</dd>
1277 </dl>
1279 @see osl_syncFile()
1280 @see open()
1281 @see write()
1283 inline RC sync() const
1285 OSL_PRECOND(_pData, "File::sync(): File not open");
1286 return (RC)osl_syncFile(_pData);
1289 /** Copy a file to a new destination.
1291 Copies a file to a new destination. Copies only files not directories.
1292 No assumptions should be made about preserving attributes or file time.
1294 @param ustrSourceFileURL [in]
1295 Full qualified URL of the source file.
1297 @param ustrDestFileURL [in]
1298 Full qualified URL of the destination file. A directory is NOT a valid destination file!
1300 @return
1301 E_None on success
1302 E_INVAL the format of the parameters was not valid
1303 E_NOMEM not enough memory for allocating structures
1304 E_ACCES permission denied
1305 E_PERM operation not permitted
1306 E_NAMETOOLONG file name too long
1307 E_NOENT no such file or directory
1308 E_ISDIR is a directory
1309 E_ROFS read-only file system
1311 @see move()
1312 @see remove()
1315 inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1317 return (RC) osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData );
1320 /** Move a file or directory to a new destination or renames it.
1322 Moves a file or directory to a new destination or renames it.
1323 File time and attributes are preserved.
1325 @param ustrSourceFileURL [in]
1326 Full qualified URL of the source file.
1328 @param ustrDestFileURL [in]
1329 Full qualified URL of the destination file. An existing directory is NOT a valid destination !
1331 @return
1332 E_None on success
1333 E_INVAL the format of the parameters was not valid
1334 E_NOMEM not enough memory for allocating structures
1335 E_ACCES permission denied
1336 E_PERM operation not permitted
1337 E_NAMETOOLONG file name too long
1338 E_NOENT no such file or directory
1339 E_ROFS read-only file system
1341 @see copy()
1344 inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1346 return (RC) osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData );
1349 /** Remove a regular file.
1351 @param ustrFileURL [in]
1352 Full qualified URL of the file to remove.
1354 @return
1355 E_None on success
1356 E_INVAL the format of the parameters was not valid
1357 E_NOMEM not enough memory for allocating structures
1358 E_ACCES permission denied
1359 E_PERM operation not permitted
1360 E_NAMETOOLONG file name too long
1361 E_NOENT no such file or directory
1362 E_ISDIR is a directory
1363 E_ROFS read-only file system
1364 E_FAULT bad address
1365 E_LOOP too many symbolic links encountered
1366 E_IO on I/O errors
1367 E_BUSY device or resource busy
1368 E_INTR function call was interrupted
1369 E_LOOP too many symbolic links encountered
1370 E_MULTIHOP multihop attempted
1371 E_NOLINK link has been severed
1372 E_TXTBSY text file busy
1374 @see open()
1377 inline static RC remove( const ::rtl::OUString& ustrFileURL )
1379 return (RC) osl_removeFile( ustrFileURL.pData );
1382 /** Set file attributes.
1384 @param ustrFileURL [in]
1385 The full qualified file URL.
1387 @param uAttributes [in]
1388 Attributes of the file to be set.
1390 @return
1391 E_None on success
1392 E_INVAL the format of the parameters was not valid
1394 @see FileStatus
1397 inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
1399 return (RC) osl_setFileAttributes( ustrFileURL.pData, uAttributes );
1402 /** Set the file time.
1404 @param ustrFileURL [in]
1405 The full qualified URL of the file.
1407 @param rCreationTime [in]
1408 Creation time of the given file.
1410 @param rLastAccessTime [in]
1411 Time of the last access of the given file.
1413 @param rLastWriteTime [in]
1414 Time of the last modifying of the given file.
1416 @return
1417 E_None on success
1418 E_INVAL the format of the parameters was not valid
1419 E_NOENT no such file or directory not found
1421 @see FileStatus
1424 inline static RC setTime(
1425 const ::rtl::OUString& ustrFileURL,
1426 const TimeValue& rCreationTime,
1427 const TimeValue& rLastAccessTime,
1428 const TimeValue& rLastWriteTime )
1430 return (RC) osl_setFileTime(
1431 ustrFileURL.pData,
1432 &rCreationTime,
1433 &rLastAccessTime,
1434 &rLastWriteTime );
1437 friend class DirectoryItem;
1440 // -----------------------------------------------------------------------------
1441 /** The directory item class object provides access to file status information.
1443 @see FileStatus
1446 class DirectoryItem: public FileBase
1448 oslDirectoryItem _pData;
1450 public:
1452 /** Constructor.
1455 DirectoryItem(): _pData( NULL )
1459 /** Copy constructor.
1462 DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
1464 if( _pData )
1465 osl_acquireDirectoryItem( _pData );
1468 /** Destructor.
1471 ~DirectoryItem()
1473 if( _pData )
1474 osl_releaseDirectoryItem( _pData );
1477 /** Assignment operator.
1480 DirectoryItem& operator=(const DirectoryItem& rItem )
1482 if (&rItem != this)
1484 if( _pData )
1485 osl_releaseDirectoryItem( _pData );
1487 _pData = rItem._pData;
1489 if( _pData )
1490 osl_acquireDirectoryItem( _pData );
1492 return *this;
1495 /** Check for validity of this instance.
1497 @return
1498 sal_True if object is valid directory item else sal_False.
1501 inline sal_Bool is()
1503 return _pData != NULL;
1506 /** Retrieve a single directory item.
1508 Retrieves a single directory item. The returned handle has an initial refcount of 1.
1509 Due to performance issues it is not recommended to use this function while
1510 enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
1512 @param ustrFileURL [in]
1513 An absolute file URL.
1515 @param rItem [out]
1516 On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
1517 The handle has to be released by a call to osl_releaseDirectoryItem().
1519 @return
1520 E_None on success
1521 E_INVAL the format of the parameters was not valid
1522 E_NOMEM not enough memory for allocating structures
1523 E_ACCES permission denied
1524 E_MFILE too many open files used by the process
1525 E_NFILE too many open files in the system
1526 E_NOENT no such file or directory
1527 E_LOOP too many symbolic links encountered
1528 E_NAMETOOLONG the file name is too long
1529 E_NOTDIR a component of the path prefix of path is not a directory
1530 E_IO on I/O errors
1531 E_MULTIHOP multihop attempted
1532 E_NOLINK link has been severed
1533 E_FAULT bad address
1534 E_INTR the function call was interrupted
1536 @see FileStatus
1537 @see Directory::getNextItem()
1540 static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
1542 if( rItem._pData)
1544 osl_releaseDirectoryItem( rItem._pData );
1545 rItem._pData = NULL;
1548 return (RC) osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData );
1551 /** Retrieve information about a single file or directory.
1553 @param rStatus [in|out]
1554 Reference to a class which receives the information of the file or directory
1555 represented by this directory item.
1557 @return
1558 E_None on success
1559 E_NOMEM not enough memory for allocating structures
1560 E_INVAL the format of the parameters was not valid
1561 E_LOOP too many symbolic links encountered
1562 E_ACCES permission denied
1563 E_NOENT no such file or directory
1564 E_NAMETOOLONG file name too long
1565 E_BADF invalid oslDirectoryItem parameter
1566 E_FAULT bad address
1567 E_OVERFLOW value too large for defined data type
1568 E_INTR function call was interrupted
1569 E_NOLINK link has been severed
1570 E_MULTIHOP components of path require hopping to multiple remote machines and the file system does not allow it
1571 E_MFILE too many open files used by the process
1572 E_NFILE too many open files in the system
1573 E_NOSPC no space left on device
1574 E_NXIO no such device or address
1575 E_IO on I/O errors
1576 E_NOSYS function not implemented
1578 @see get()
1579 @see Directory::getNextItem()
1580 @see FileStatus
1583 inline RC getFileStatus( FileStatus& rStatus )
1585 return (RC) osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask );
1588 friend class Directory;
1591 //###########################################
1593 /** Base class for observers of directory creation notifications.
1595 Clients which uses the method createDirectoryPath of the class
1596 Directory may want to be informed about the directories that
1597 have been created. This may be accomplished by deriving from
1598 this base class and overwriting the virtual function
1599 DirectoryCreated.
1601 @see Directory::createPath
1603 class DirectoryCreationObserver
1605 public:
1606 virtual ~DirectoryCreationObserver() {};
1608 /** This method will be called when a new directory has been
1609 created and needs to be overwritten by derived classes.
1610 You must not delete the directory that was just created
1611 otherwise you will run into an endless loop.
1613 @param aDirectoryUrl
1614 [in]The absolute file URL of the directory that was just created by
1615 ::osl::Directory::createPath.
1617 virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
1620 //###########################################
1621 // This just an internal helper function for
1622 // private use.
1623 extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
1625 (static_cast<DirectoryCreationObserver*>(pData))->DirectoryCreated(aDirectoryUrl);
1628 /** The directory class object provides a enumeration of DirectoryItems.
1630 @see DirectoryItem
1631 @see File
1634 class Directory: public FileBase
1636 oslDirectory _pData;
1637 ::rtl::OUString _aPath;
1639 /** Copy constructor.
1642 Directory( Directory& );
1644 /** Assignment operator.
1647 Directory& operator = ( Directory& );
1649 public:
1651 /** Constructor.
1653 @param strPath [in]
1654 The full qualified URL of the directory.
1655 Relative URLs are not allowed.
1658 Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath )
1662 /** Destructor.
1665 ~Directory()
1667 close();
1670 /** Open a directory for enumerating its contents.
1672 @return
1673 E_None on success
1674 E_INVAL the format of the parameters was not valid
1675 E_NOENT the specified path doesn't exist
1676 E_NOTDIR the specified path is not an directory
1677 E_NOMEM not enough memory for allocating structures
1678 E_ACCES permission denied
1679 E_MFILE too many open files used by the process
1680 E_NFILE too many open files in the system
1681 E_NAMETOOLONG File name too long
1682 E_LOOP Too many symbolic links encountered
1684 @see getNextItem()
1685 @see close()
1688 inline RC open()
1690 return (RC) osl_openDirectory( _aPath.pData, &_pData );
1693 /** Query if directory is open.
1695 Query if directory is open and so item enumeration is valid.
1697 @return
1698 sal_True if the directory is open else sal_False.
1700 @see open()
1701 @see close()
1704 inline sal_Bool isOpen() { return _pData != NULL; };
1706 /** Close a directory.
1708 @return
1709 E_None on success
1710 E_INVAL the format of the parameters was not valid
1711 E_NOMEM not enough memory for allocating structures
1712 E_BADF invalid oslDirectory parameter
1713 E_INTR the function call was interrupted
1715 @see open()
1718 inline RC close()
1720 oslFileError Error = osl_File_E_BADF;
1722 if( _pData )
1724 Error=osl_closeDirectory( _pData );
1725 _pData = NULL;
1728 return (RC) Error;
1732 /** Resets the directory item enumeration to the beginning.
1734 @return
1735 E_None on success
1736 E_INVAL the format of the parameters was not valid
1737 E_NOENT the specified path doesn't exist
1738 E_NOTDIR the specified path is not an directory
1739 E_NOMEM not enough memory for allocating structures
1740 E_ACCES permission denied
1741 E_MFILE too many open files used by the process
1742 E_NFILE too many open files in the system
1743 E_NAMETOOLONG File name too long
1744 E_LOOP Too many symbolic links encountered
1746 @see open()
1749 inline RC reset()
1751 close();
1752 return open();
1755 /** Retrieve the next item of a previously opened directory.
1757 Retrieves the next item of a previously opened directory.
1759 @param rItem [out]
1760 On success a valid DirectoryItem.
1762 @param nHint [in]
1763 With this parameter the caller can tell the implementation that (s)he
1764 is going to call this function uHint times afterwards. This enables the implementation to
1765 get the information for more than one file and cache it until the next calls.
1767 @return
1768 E_None on success
1769 E_INVAL the format of the parameters was not valid
1770 E_NOMEM not enough memory for allocating structures
1771 E_NOENT no more entries in this directory
1772 E_BADF invalid oslDirectory parameter
1773 E_OVERFLOW the value too large for defined data type
1775 @see DirectoryItem
1778 inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
1780 if( rItem._pData )
1782 osl_releaseDirectoryItem( rItem._pData );
1783 rItem._pData = 0;
1785 return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
1789 /** Retrieve information about a volume.
1791 Retrieves information about a volume. A volume can either be a mount point, a network
1792 resource or a drive depending on Operating System and File System.
1794 @param ustrDirectoryURL [in]
1795 Full qualified URL of the volume
1797 @param rInfo [out]
1798 On success it receives information about the volume.
1800 @return
1801 E_None on success
1802 E_NOMEM not enough memory for allocating structures
1803 E_INVAL the format of the parameters was not valid
1804 E_NOTDIR not a directory
1805 E_NAMETOOLONG file name too long
1806 E_NOENT no such file or directory
1807 E_ACCES permission denied
1808 E_LOOP too many symbolic links encountered
1809 E_FAULT Bad address
1810 E_IO on I/O errors
1811 E_NOSYS function not implemented
1812 E_MULTIHOP multihop attempted
1813 E_NOLINK link has been severed
1814 E_INTR function call was interrupted
1816 @see FileStatus
1817 @see VolumeInfo
1820 inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
1822 return (RC) osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask );
1825 /** Create a directory.
1827 @param ustrDirectoryURL [in]
1828 Full qualified URL of the directory to create.
1830 @return
1831 E_None on success
1832 E_INVAL the format of the parameters was not valid
1833 E_NOMEM not enough memory for allocating structures
1834 E_EXIST file exists
1835 E_ACCES permission denied
1836 E_NAMETOOLONG file name too long
1837 E_NOENT no such file or directory
1838 E_NOTDIR not a directory
1839 E_ROFS read-only file system
1840 E_NOSPC no space left on device
1841 E_DQUOT quota exceeded
1842 E_LOOP too many symbolic links encountered
1843 E_FAULT bad address
1844 E_IO on I/O errors
1845 E_MLINK too many links
1846 E_MULTIHOP multihop attempted
1847 E_NOLINK link has been severed
1849 @see remove()
1852 inline static RC create( const ::rtl::OUString& ustrDirectoryURL )
1854 return (RC) osl_createDirectory( ustrDirectoryURL.pData );
1857 /** Remove an empty directory.
1859 @param ustrDirectoryURL [in]
1860 Full qualified URL of the directory.
1862 @return
1863 E_None on success
1864 E_INVAL the format of the parameters was not valid
1865 E_NOMEM not enough memory for allocating structures
1866 E_PERM operation not permitted
1867 E_ACCES permission denied
1868 E_NOENT no such file or directory
1869 E_NOTDIR not a directory
1870 E_NOTEMPTY directory not empty
1871 E_FAULT bad address
1872 E_NAMETOOLONG file name too long
1873 E_BUSY device or resource busy
1874 E_ROFS read-only file system
1875 E_LOOP too many symbolic links encountered
1876 E_BUSY device or resource busy
1877 E_EXIST file exists
1878 E_IO on I/O errors
1879 E_MULTIHOP multihop attempted
1880 E_NOLINK link has been severed
1882 @see create()
1885 inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
1887 return (RC) osl_removeDirectory( ustrDirectoryURL.pData );
1890 /** Create a directory path.
1892 The osl_createDirectoryPath function creates a specified directory path.
1893 All nonexisting sub directories will be created.
1894 <p><strong>PLEASE NOTE:</strong> You cannot rely on getting the error code
1895 E_EXIST for existing directories. Programming against this error code is
1896 in general a strong indication of a wrong usage of osl_createDirectoryPath.</p>
1898 @param aDirectoryUrl
1899 [in] The absolute file URL of the directory path to create.
1900 A relative file URL will not be accepted.
1902 @param aDirectoryCreationObserver
1903 [in] Pointer to an instance of type DirectoryCreationObserver that will
1904 be informed about the creation of a directory. The value of this
1905 parameter may be NULL, in this case notifications will not be sent.
1907 @return
1908 <dl>
1909 <dt>E_None</dt>
1910 <dd>On success</dd>
1911 <dt>E_INVAL</dt>
1912 <dd>The format of the parameters was not valid</dd>
1913 <dt>E_ACCES</dt>
1914 <dd>Permission denied</dd>
1915 <dt>E_EXIST</dt>
1916 <dd>The final node of the specified directory path already exist</dd>
1917 <dt>E_NAMETOOLONG</dt>
1918 <dd>The name of the specified directory path exceeds the maximum allowed length</dd>
1919 <dt>E_NOTDIR</dt>
1920 <dd>A component of the specified directory path already exist as file in any part of the directory path</dd>
1921 <dt>E_ROFS</dt>
1922 <dd>Read-only file system</dd>
1923 <dt>E_NOSPC</dt>
1924 <dd>No space left on device</dd>
1925 <dt>E_DQUOT</dt>
1926 <dd>Quota exceeded</dd>
1927 <dt>E_FAULT</dt>
1928 <dd>Bad address</dd>
1929 <dt>E_IO</dt>
1930 <dd>I/O error</dd>
1931 <dt>E_LOOP</dt>
1932 <dd>Too many symbolic links encountered</dd>
1933 <dt>E_NOLINK</dt>
1934 <dd>Link has been severed</dd>
1935 <dt>E_invalidError</dt>
1936 <dd>An unknown error occurred</dd>
1937 </dl>
1939 @see DirectoryCreationObserver
1940 @see create
1942 static RC createPath(
1943 const ::rtl::OUString& aDirectoryUrl,
1944 DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
1946 return (RC)osl_createDirectoryPath(
1947 aDirectoryUrl.pData,
1948 (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
1949 aDirectoryCreationObserver);
1953 } /* namespace osl */
1955 #endif /* __cplusplus */
1956 #endif /* _OSL_FILE_HXX_ */