1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
30 #include <sal/log.hxx>
32 #include <rtl/ustring.hxx>
35 #include <osl/diagnose.h>
36 #include <rtl/byteseq.hxx>
44 /** Base class for all File System specific objects.
56 E_None
= osl_File_E_None
, //< on success
57 E_PERM
= osl_File_E_PERM
, //< operation not permitted
58 E_NOENT
= osl_File_E_NOENT
, //< no such file or directory
59 E_SRCH
= osl_File_E_SRCH
, //< no process matches the PID
60 E_INTR
= osl_File_E_INTR
, //< function call was interrupted
61 E_IO
= osl_File_E_IO
, //< I/O error occured
62 E_NXIO
= osl_File_E_NXIO
, //< no such device or address
63 E_2BIG
= osl_File_E_2BIG
, //< argument list too long
64 E_NOEXEC
= osl_File_E_NOEXEC
, //< invalid executable file format
65 E_BADF
= osl_File_E_BADF
, //< bad file descriptor
66 E_CHILD
= osl_File_E_CHILD
, //< there are no child processes
67 E_AGAIN
= osl_File_E_AGAIN
, //< resource temp unavailable, try again later
68 E_NOMEM
= osl_File_E_NOMEM
, //< no memory available
69 E_ACCES
= osl_File_E_ACCES
, //< file permissions do not allow operation
70 E_FAULT
= osl_File_E_FAULT
, //< bad address; an invalid pointer detected
71 E_BUSY
= osl_File_E_BUSY
, //< resource busy
72 E_EXIST
= osl_File_E_EXIST
, //< file exists where should only be created
73 E_XDEV
= osl_File_E_XDEV
, //< improper link across file systems detected
74 E_NODEV
= osl_File_E_NODEV
, //< wrong device type specified
75 E_NOTDIR
= osl_File_E_NOTDIR
, //< file isn't a directory where one is needed
76 E_ISDIR
= osl_File_E_ISDIR
, //< file is a directory, invalid operation
77 E_INVAL
= osl_File_E_INVAL
, //< invalid argument to library function
78 E_NFILE
= osl_File_E_NFILE
, //< too many distinct file openings
79 E_MFILE
= osl_File_E_MFILE
, //< process has too many distinct files open
80 E_NOTTY
= osl_File_E_NOTTY
, //< inappropriate I/O control operation
81 E_FBIG
= osl_File_E_FBIG
, //< file too large
82 E_NOSPC
= osl_File_E_NOSPC
, //< no space left on device, write failed
83 E_SPIPE
= osl_File_E_ROFS
, //< invalid seek operation (such as on pipe)
84 E_ROFS
= osl_File_E_SPIPE
, //< illegal modification to read-only filesystem
85 E_MLINK
= osl_File_E_MLINK
, //< too many links to file
86 E_PIPE
= osl_File_E_PIPE
, //< broken pipe; no process reading from other end of pipe
87 E_DOM
= osl_File_E_DOM
, //< domain error (mathematical error)
88 E_RANGE
= osl_File_E_RANGE
, //< range error (mathematical error)
89 E_DEADLK
= osl_File_E_DEADLK
, //< deadlock avoided
90 E_NAMETOOLONG
= osl_File_E_NAMETOOLONG
, //< filename too long
91 E_NOLCK
= osl_File_E_NOLCK
, //< no locks available
92 E_NOSYS
= osl_File_E_NOSYS
, //< function not implemented
93 E_NOTEMPTY
= osl_File_E_NOTEMPTY
, //< directory not empty
94 E_LOOP
= osl_File_E_LOOP
, //< too many levels of symbolic links found during name lookup
95 E_ILSEQ
= osl_File_E_ILSEQ
, //< invalid or incomplete byte sequence of multibyte char found
96 E_NOLINK
= osl_File_E_NOLINK
, //< link has been severed
97 E_MULTIHOP
= osl_File_E_MULTIHOP
, //< remote resource is not directly available
98 E_USERS
= osl_File_E_USERS
, //< file quote system is confused as there are too many users
99 E_OVERFLOW
= osl_File_E_OVERFLOW
, //< value too large for defined data type
100 E_NOTREADY
= osl_File_E_NOTREADY
, //< device not ready
101 E_invalidError
= osl_File_E_invalidError
, //< unmapped error: always last entry in enum!
102 E_TIMEDOUT
= osl_File_E_TIMEDOUT
, //< socket operation timed out
103 E_NETWORK
= osl_File_E_NETWORK
109 /** Determine a valid unused canonical name for a requested name.
111 Determines a valid unused canonical name for a requested name.
112 Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
113 If a file or directory with the requested name already exists a new name is generated following
114 the common rules on the actual Operating System and File System.
116 @param ustrRequestedURL [in]
117 Requested name of a file or directory.
119 @param ustrValidURL [out]
120 On success receives a name which is unused and valid on the actual Operating System and
123 @retval E_None on success
124 @retval E_INVAL the format of the parameters was not valid
126 @see DirectoryItem::getFileStatus()
129 static RC
getCanonicalName( const ::rtl::OUString
& ustrRequestedURL
, ::rtl::OUString
& ustrValidURL
)
131 return static_cast< RC
>( osl_getCanonicalName( ustrRequestedURL
.pData
, &ustrValidURL
.pData
) );
134 /** Convert a path relative to a given directory into an full qualified file URL.
136 Convert a path relative to a given directory into an full qualified file URL.
137 The function resolves symbolic links if possible and path ellipses, so on success
138 the resulting absolute path is fully resolved.
140 @param ustrBaseDirectoryURL [in]
141 Base directory URL to which the relative path is related to.
143 @param ustrRelativeFileURL [in]
144 An URL of a file or directory relative to the directory path specified by ustrBaseDirectoryURL
146 If ustrRelativeFileURL denotes an absolute path ustrBaseDirectoryURL will be ignored.
148 @param ustrAbsoluteFileURL [out]
149 On success it receives the full qualified absolute file URL.
151 @retval E_None on success
152 @retval E_INVAL the format of the parameters was not valid
153 @retval E_NOMEM not enough memory for allocating structures
154 @retval E_NOTDIR not a directory
155 @retval E_ACCES permission denied
156 @retval E_NOENT no such file or directory
157 @retval E_NAMETOOLONG file name too long
158 @retval E_OVERFLOW value too large for defined data type
159 @retval E_FAULT bad address
160 @retval E_INTR function call was interrupted
161 @retval E_LOOP too many symbolic links encountered
162 @retval E_MULTIHOP multihop attempted
163 @retval E_NOLINK link has been severed
165 @see DirectoryItem::getFileStatus()
168 static 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 dependent path.
175 @param ustrFileURL [in]
178 @param ustrSystemPath [out]
179 On success it receives the system path.
181 @retval E_None on success
182 @retval E_INVAL the format of the parameters was not valid
184 @see getFileURLFromSystemPath()
187 static RC
getSystemPathFromFileURL( const ::rtl::OUString
& ustrFileURL
, ::rtl::OUString
& ustrSystemPath
)
189 return static_cast< RC
>( osl_getSystemPathFromFileURL( ustrFileURL
.pData
, &ustrSystemPath
.pData
) );
192 /** Convert a system dependent path into a file URL.
194 @param ustrSystemPath [in]
195 A System dependent path of a file or directory.
197 @param ustrFileURL [out]
198 On success it receives the file URL.
200 @retval E_None on success
201 @retval E_INVAL the format of the parameters was not valid
203 @see getSystemPathFromFileURL()
206 static RC
getFileURLFromSystemPath( const ::rtl::OUString
& ustrSystemPath
, ::rtl::OUString
& ustrFileURL
)
208 return static_cast< RC
>( osl_getFileURLFromSystemPath( ustrSystemPath
.pData
, &ustrFileURL
.pData
) );
211 /** Searche a full qualified system path or a file URL.
213 @param ustrFileName [in]
214 A system dependent path, a file URL, a file or relative directory
216 @param ustrSearchPath [in]
217 A list of system paths, in which a given file has to be searched. The Notation of a path list is
218 system dependent, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
219 These paths are only for the search of a file or a relative path, otherwise it will be ignored.
220 If ustrSearchPath is NULL or while using the search path the search failed, the function searches for
221 a matching file in all system directories and in the directories listed in the PATH environment
223 The value of an environment variable should be used (e.g. LD_LIBRARY_PATH) if the caller is not
224 aware of the Operating System and so doesn't know which path list delimiter to use.
226 @param ustrFileURL [out]
227 On success it receives the full qualified file URL.
229 @retval E_None on success
230 @retval E_INVAL the format of the parameters was not valid
231 @retval E_NOTDIR not a directory
232 @retval E_NOENT no such file or directory not found
234 @see getFileURLFromSystemPath()
235 @see getSystemPathFromFileURL()
238 static RC
searchFileURL( const ::rtl::OUString
& ustrFileName
, const ::rtl::OUString
& ustrSearchPath
, ::rtl::OUString
& ustrFileURL
)
240 return static_cast< RC
>( osl_searchFileURL( ustrFileName
.pData
, ustrSearchPath
.pData
, &ustrFileURL
.pData
) );
243 /** Retrieves the file URL of the system's temporary directory path.
245 @param[out] ustrTempDirURL
246 On success receives the URL of system's temporary directory path.
248 @retval E_None on success
249 @retval E_NOENT no such file or directory not found
252 static RC
getTempDirURL( ::rtl::OUString
& ustrTempDirURL
)
254 return static_cast< RC
>( osl_getTempDirURL( &ustrTempDirURL
.pData
) );
257 /** Creates a temporary file in the directory provided by the caller or the
258 directory returned by getTempDirURL.
259 Under UNIX Operating Systems the file will be created with read and write
260 access for the user exclusively.
261 If the caller requests only a handle to the open file but not the name of
262 it, the file will be automatically removed on close else the caller is
263 responsible for removing the file on success.<br><br>
265 @param pustrDirectoryURL [in]
266 Specifies the full qualified URL where the temporary file should be created.
267 If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
270 On success receives a handle to the open file.
271 If pHandle is 0 the file will be closed on return, in this case
272 pustrTempFileURL must not be 0.
274 @param pustrTempFileURL [out]
275 On success receives the full qualified URL of the temporary file.
276 If pustrTempFileURL is 0 the file will be automatically removed
277 on close, in this case pHandle must not be 0.
278 If pustrTempFileURL is not 0 the caller receives the name of the
279 created file and is responsible for removing the file.
281 Description of the different pHandle, ppustrTempFileURL parameter combinations.
282 pHandle is 0 and pustrTempDirURL is 0 - this combination is invalid<br>
283 pHandle is not 0 and pustrTempDirURL is 0 - a handle to the open file
284 will be returned on success and the file will be automatically removed on close<br>
285 pHandle is 0 and pustrTempDirURL is not 0 - the name of the file will be
286 returned, the caller is responsible for opening, closing and removing the file.<br>
287 pHandle is not 0 and pustrTempDirURL is not 0 - a handle to the open file as well as
288 the file name will be returned, the caller is responsible for closing and removing
291 @retval E_None on success
292 @retval E_INVAL the format of the parameter is invalid
293 @retval E_NOMEM not enough memory for allocating structures
294 @retval E_ACCES Permission denied
295 @retval E_NOENT No such file or directory
296 @retval E_NOTDIR Not a directory
297 @retval E_ROFS Read-only file system
298 @retval E_NOSPC No space left on device
299 @retval E_DQUOT Quota exceeded
304 static RC
createTempFile(
305 ::rtl::OUString
* pustrDirectoryURL
,
306 oslFileHandle
* pHandle
,
307 ::rtl::OUString
* pustrTempFileURL
)
309 rtl_uString
* pustr_dir_url
= pustrDirectoryURL
? pustrDirectoryURL
->pData
: NULL
;
310 rtl_uString
** ppustr_tmp_file_url
= pustrTempFileURL
? &pustrTempFileURL
->pData
: NULL
;
312 return static_cast< RC
>( osl_createTempFile(pustr_dir_url
, pHandle
, ppustr_tmp_file_url
) );
317 /** The VolumeDevice class.
322 class VolumeDevice
: public FileBase
324 oslVolumeDeviceHandle _aHandle
;
331 VolumeDevice() : _aHandle( NULL
)
335 /** Copy constructor.
338 The other volume device.
341 VolumeDevice( const VolumeDevice
& rDevice
)
343 _aHandle
= rDevice
._aHandle
;
345 osl_acquireVolumeDeviceHandle( _aHandle
);
354 osl_releaseVolumeDeviceHandle( _aHandle
);
357 /** Assignment operator.
360 The other volume device.
363 VolumeDevice
& operator =( const VolumeDevice
& rDevice
)
365 oslVolumeDeviceHandle newHandle
= rDevice
._aHandle
;
368 osl_acquireVolumeDeviceHandle( newHandle
);
371 osl_releaseVolumeDeviceHandle( _aHandle
);
373 _aHandle
= newHandle
;
378 /** Get the full qualified URL where a device is mounted to.
381 The full qualified URL where the device is mounted to.
383 rtl::OUString
getMountPath()
386 osl_getVolumeDeviceMountPath( _aHandle
, &aPath
.pData
);
390 friend class VolumeInfo
;
396 /** The VolumeInfo class.
398 Neither copy nor assignment is allowed for this class.
400 @see Directory::getVolumeInfo
406 oslVolumeInfo _aInfo
;
408 VolumeDevice _aDevice
;
410 /** Copy constructor.
413 VolumeInfo( VolumeInfo
& ) SAL_DELETED_FUNCTION
;
415 /** Assginment operator.
418 VolumeInfo
& operator = ( VolumeInfo
& ) SAL_DELETED_FUNCTION
;
425 Set of flags describing the demanded information.
428 VolumeInfo( sal_uInt32 nMask
)
431 memset( &_aInfo
, 0, sizeof( oslVolumeInfo
));
432 _aInfo
.uStructSize
= sizeof( oslVolumeInfo
);
433 _aInfo
.pDeviceHandle
= &_aDevice
._aHandle
;
441 if( _aInfo
.ustrFileSystemName
)
442 rtl_uString_release( _aInfo
.ustrFileSystemName
);
445 /** Check if specified fields are valid.
448 Set of flags for the fields to check.
450 @return true if all fields are valid else false.
453 bool isValid( sal_uInt32 nMask
) const
455 return ( nMask
& _aInfo
.uValidFields
) == nMask
;
458 /** Check the remote flag.
461 true if Attributes are valid and the volume is remote else false.
464 bool getRemoteFlag() const
466 return (_aInfo
.uAttributes
& osl_Volume_Attribute_Remote
) != 0;
469 /** Check the removeable flag.
472 true if attributes are valid and the volume is removable else false.
475 bool getRemoveableFlag() const
477 return (_aInfo
.uAttributes
& osl_Volume_Attribute_Removeable
) != 0;
480 /** Check the compact disc flag.
483 true if attributes are valid and the volume is a CDROM else false.
486 bool getCompactDiscFlag() const
488 return (_aInfo
.uAttributes
& osl_Volume_Attribute_CompactDisc
) != 0;
491 /** Check the floppy disc flag.
494 true if attributes are valid and the volume is a floppy disk else false.
497 bool getFloppyDiskFlag() const
499 return (_aInfo
.uAttributes
& osl_Volume_Attribute_FloppyDisk
) != 0;
502 /** Check the fixed disk flag.
505 true if attributes are valid and the volume is a fixed disk else false.
508 bool getFixedDiskFlag() const
510 return (_aInfo
.uAttributes
& osl_Volume_Attribute_FixedDisk
) != 0;
513 /** Check the RAM disk flag.
516 true if attributes are valid and the volume is a RAM disk else false.
519 bool getRAMDiskFlag() const
521 return (_aInfo
.uAttributes
& osl_Volume_Attribute_RAMDisk
) != 0;
524 /** Determine the total space of a volume device.
527 The total diskspace of this volume if this information is valid,
531 sal_uInt64
getTotalSpace() const
533 return _aInfo
.uTotalSpace
;
536 /** Determine the free space of a volume device.
539 The free diskspace of this volume if this information is valid,
543 sal_uInt64
getFreeSpace() const
545 return _aInfo
.uFreeSpace
;
548 /** Determine the used space of a volume device.
551 The used diskspace of this volume if this information is valid,
555 sal_uInt64
getUsedSpace() const
557 return _aInfo
.uUsedSpace
;
560 /** Determine the maximal length of a file name.
563 The maximal length of a file name if this information is valid,
567 sal_uInt32
getMaxNameLength() const
569 return _aInfo
.uMaxNameLength
;
572 /** Determine the maximal length of a path name.
575 The maximal length of a path if this information is valid,
579 sal_uInt32
getMaxPathLength() const
581 return _aInfo
.uMaxPathLength
;
584 /** Determine the name of the volume device's File System.
587 The name of the volume's filesystem if this information is valid,
588 otherwise an empty string.
591 ::rtl::OUString
getFileSystemName() const
593 return _aInfo
.ustrFileSystemName
? ::rtl::OUString( _aInfo
.ustrFileSystemName
) : ::rtl::OUString();
597 /** Get the volume device handle.
600 The device handle of the volume if this information is valid,
601 otherwise returns NULL;
604 VolumeDevice
getDeviceHandle() const
609 /** Return whether the file system is case sensitive or
613 true if the file system is case sensitive false otherwise
615 bool isCaseSensitiveFileSystem() const
617 return (_aInfo
.uAttributes
& osl_Volume_Attribute_Case_Sensitive
) != 0;
620 /** Return whether the file system preserves the case of
621 file and directory names or not
624 true if the file system preserves the case of file and
625 directory names false otherwise
627 bool isCasePreservingFileSystem() const
629 return (_aInfo
.uAttributes
& osl_Volume_Attribute_Case_Is_Preserved
) != 0;
632 friend class Directory
;
638 /** The FileStatus class.
640 @see DirectoryItem::getFileStatus
645 oslFileStatus _aStatus
;
648 /** Copy constructor.
651 FileStatus( FileStatus
& ) SAL_DELETED_FUNCTION
;
653 /** Assignment operator.
656 FileStatus
& operator = ( FileStatus
& ) SAL_DELETED_FUNCTION
;
661 Directory
= osl_File_Type_Directory
,
662 Volume
= osl_File_Type_Volume
,
663 Regular
= osl_File_Type_Regular
,
664 Fifo
= osl_File_Type_Fifo
,
665 Socket
= osl_File_Type_Socket
,
666 Link
= osl_File_Type_Link
,
667 Special
= osl_File_Type_Special
,
668 Unknown
= osl_File_Type_Unknown
674 Set of flags describing the demanded information.
676 FileStatus(sal_uInt32 nMask
)
679 memset(&_aStatus
, 0, sizeof(_aStatus
));
680 _aStatus
.uStructSize
= sizeof(_aStatus
);
687 if ( _aStatus
.ustrFileURL
)
688 rtl_uString_release( _aStatus
.ustrFileURL
);
689 if ( _aStatus
.ustrLinkTargetURL
)
690 rtl_uString_release( _aStatus
.ustrLinkTargetURL
);
691 if ( _aStatus
.ustrFileName
)
692 rtl_uString_release( _aStatus
.ustrFileName
);
695 /** Check if specified fields are valid.
698 Set of flags for the fields to check.
701 true if all fields are valid else false.
704 bool isValid( sal_uInt32 nMask
) const
706 return ( nMask
& _aStatus
.uValidFields
) == nMask
;
709 /** Get the file type.
714 Type
getFileType() const
717 !isValid(osl_FileStatus_Mask_Type
), "sal.osl",
718 "no FileStatus Type determined");
719 return isValid(osl_FileStatus_Mask_Type
)
720 ? static_cast< Type
>(_aStatus
.eType
) : Unknown
;
723 /** Is it a directory?
724 This method returns True for both directories, and volumes.
727 True if it's a directory, False otherwise.
730 @since LibreOffice 3.6
732 bool isDirectory() const
734 return ( getFileType() == Directory
|| getFileType() == Volume
);
737 /** Is it a regular file?
740 True if it's a regular file, False otherwise.
745 @since LibreOffice 3.6
747 bool isRegular() const
749 return ( getFileType() == Regular
);
755 True if it's a link, False otherwise.
758 @since LibreOffice 3.6
762 return ( getFileType() == Link
);
765 /** Get the file attributes.
768 The set of attribute flags of this file.
771 sal_uInt64
getAttributes() const
774 !isValid(osl_FileStatus_Mask_Attributes
), "sal.osl",
775 "no FileStatus Attributes determined");
776 return _aStatus
.uAttributes
;
779 /** Get the creation time of this file.
782 The creation time if this information is valid, an uninitialized
786 TimeValue
getCreationTime() const
789 !isValid(osl_FileStatus_Mask_CreationTime
), "sal.osl",
790 "no FileStatus CreationTime determined");
791 return _aStatus
.aCreationTime
;
794 /** Get the file access time.
797 The last access time if this information is valid, an uninitialized
801 TimeValue
getAccessTime() const
804 !isValid(osl_FileStatus_Mask_AccessTime
), "sal.osl",
805 "no FileStatus AccessTime determined");
806 return _aStatus
.aAccessTime
;
809 /** Get the file modification time.
812 The last modified time if this information is valid, an uninitialized
816 TimeValue
getModifyTime() const
819 !isValid(osl_FileStatus_Mask_ModifyTime
), "sal.osl",
820 "no FileStatus ModifyTime determined");
821 return _aStatus
.aModifyTime
;
824 /** Get the size of the file.
827 The actual file size if this information is valid, 0 otherwise.
830 sal_uInt64
getFileSize() const
833 !isValid(osl_FileStatus_Mask_FileSize
), "sal.osl",
834 "no FileStatus FileSize determined");
835 return _aStatus
.uFileSize
;
838 /** Get the file name.
841 The file name if this information is valid, an empty string otherwise.
844 ::rtl::OUString
getFileName() const
847 !isValid(osl_FileStatus_Mask_FileName
), "sal.osl",
848 "no FileStatus FileName determined");
849 return isValid(osl_FileStatus_Mask_FileName
)
850 ? rtl::OUString(_aStatus
.ustrFileName
) : rtl::OUString();
854 /** Get the URL of the file.
857 The full qualified URL of the file if this information is valid, an
858 empty string otherwise.
861 ::rtl::OUString
getFileURL() const
864 !isValid(osl_FileStatus_Mask_FileURL
), "sal.osl",
865 "no FileStatus FileURL determined");
866 return isValid(osl_FileStatus_Mask_FileURL
)
867 ? rtl::OUString(_aStatus
.ustrFileURL
) : rtl::OUString();
870 /** Get the link target URL.
873 The link target URL if this information is valid, an empty string
877 ::rtl::OUString
getLinkTargetURL() const
880 !isValid(osl_FileStatus_Mask_LinkTargetURL
), "sal.osl",
881 "no FileStatus LinkTargetURL determined");
882 return isValid(osl_FileStatus_Mask_LinkTargetURL
)
883 ? rtl::OUString(_aStatus
.ustrLinkTargetURL
) : rtl::OUString();
886 friend class DirectoryItem
;
890 /** The file class object provides access to file contents and attributes.
896 class File
: public FileBase
898 oslFileHandle _pData
;
899 ::rtl::OUString _aPath
;
901 /** Copy constructor.
904 File( File
& ) SAL_DELETED_FUNCTION
;
906 /** Assginment operator.
909 File
& operator = ( File
& ) SAL_DELETED_FUNCTION
;
915 @param ustrFileURL [in]
916 The full qualified URL of the file. Relative paths are not allowed.
919 File( const ::rtl::OUString
& ustrFileURL
): _pData( NULL
), _aPath( ustrFileURL
) {}
932 the URL with which this File instance was created.
934 @since LibreOffice 4.1
936 rtl::OUString
getURL() const { return _aPath
; }
938 /** Open a regular file.
940 Open a file. Only regular files can be openend.
943 Specifies the open mode.
945 @retval E_None on success
946 @retval E_NOMEM not enough memory for allocating structures
947 @retval E_INVAL the format of the parameters was not valid
948 @retval E_NAMETOOLONG pathname was too long
949 @retval E_NOENT no such file or directory
950 @retval E_ACCES permission denied
951 @retval E_AGAIN a write lock could not be established
952 @retval E_NOTDIR not a directory
953 @retval E_NXIO no such device or address
954 @retval E_NODEV no such device
955 @retval E_ROFS read-only file system
956 @retval E_TXTBSY text file busy
957 @retval E_FAULT bad address
958 @retval E_LOOP too many symbolic links encountered
959 @retval E_NOSPC no space left on device
960 @retval E_ISDIR is a directory
961 @retval E_MFILE too many open files used by the process
962 @retval E_NFILE too many open files in the system
963 @retval E_DQUOT quota exceeded
964 @retval E_EXIST file exists
965 @retval E_INTR function call was interrupted
966 @retval E_IO on I/O errors
967 @retval E_MULTIHOP multihop attempted
968 @retval E_NOLINK link has been severed
969 @retval E_EOVERFLOW value too large for defined data type
980 RC
open( sal_uInt32 uFlags
)
982 return static_cast< RC
>( osl_openFile( _aPath
.pData
, &_pData
, uFlags
) );
985 /** Close an open file.
987 @retval E_None on success
988 @retval E_INVAL the format of the parameters was not valid
989 @retval E_BADF Bad file
990 @retval E_INTR function call was interrupted
991 @retval E_NOLINK link has been severed
992 @retval E_NOSPC no space left on device
993 @retval E_IO on I/O errors
1000 oslFileError Error
= osl_File_E_BADF
;
1004 Error
=osl_closeFile( _pData
);
1008 return static_cast< RC
>( Error
);
1011 /** Set the internal position pointer of an open file.
1014 Distance to move the internal position pointer (from uPos).
1017 Absolute position from the beginning of the file.
1019 @retval E_None on success
1020 @retval E_INVAL the format of the parameters was not valid
1021 @retval E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1027 RC
setPos( sal_uInt32 uHow
, sal_Int64 uPos
) SAL_WARN_UNUSED_RESULT
1029 return static_cast< RC
>( osl_setFilePos( _pData
, uHow
, uPos
) );
1032 /** Retrieve the current position of the internal pointer of an open file.
1035 On success receives the current position of the file pointer.
1037 @retval E_None on success
1038 @retval E_INVAL the format of the parameters was not valid
1039 @retval E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1047 RC
getPos( sal_uInt64
& uPos
)
1049 return static_cast< RC
>( osl_getFilePos( _pData
, &uPos
) );
1052 /** Test if the end of a file is reached.
1055 Points to a variable that receives the end-of-file status.
1057 @retval E_None on success
1058 @retval E_INVAL the format of the parameters was not valid
1059 @retval E_INTR function call was interrupted
1060 @retval E_IO on I/O errors
1061 @retval E_ISDIR is a directory
1062 @retval E_BADF bad file
1063 @retval E_FAULT bad address
1064 @retval E_AGAIN operation would block
1065 @retval E_NOLINK link has been severed
1073 RC
isEndOfFile( sal_Bool
*pIsEOF
)
1075 return static_cast< RC
>( osl_isEndOfFile( _pData
, pIsEOF
) );
1078 /** Set the file size of an open file.
1080 Sets the file size of an open file. The file can be truncated or enlarged by the function.
1081 The position of the file pointer is not affeced by this function.
1086 @retval E_None on success
1087 @retval E_INVAL the format of the parameters was not valid
1088 @retval E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1095 RC
setSize( sal_uInt64 uSize
)
1097 return static_cast< RC
>( osl_setFileSize( _pData
, uSize
) );
1100 /** Get the file size of an open file.
1102 Gets the file size of an open file.
1103 The position of the file pointer is not affeced by this function.
1106 Current size in bytes.
1108 @retval E_None on success
1109 @retval E_INVAL the format of the parameters was not valid
1110 @retval E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1119 RC
getSize( sal_uInt64
&rSize
)
1121 return static_cast< RC
>( osl_getFileSize( _pData
, &rSize
) );
1124 /** Read a number of bytes from a file.
1126 Reads a number of bytes from a file. The internal file pointer is
1127 increased by the number of bytes read.
1129 @param pBuffer [out]
1130 Points to a buffer which receives data. The buffer must be large enough
1131 to hold uBytesRequested bytes.
1133 @param uBytesRequested [in]
1134 Number of bytes which should be retrieved.
1136 @param rBytesRead [out]
1137 On success the number of bytes which have actually been retrieved.
1139 @retval E_None on success
1140 @retval E_INVAL the format of the parameters was not valid
1141 @retval E_INTR function call was interrupted
1142 @retval E_IO on I/O errors
1143 @retval E_ISDIR is a directory
1144 @retval E_BADF bad file
1145 @retval E_FAULT bad address
1146 @retval E_AGAIN operation would block
1147 @retval E_NOLINK link has been severed
1155 RC
read( void *pBuffer
, sal_uInt64 uBytesRequested
, sal_uInt64
& rBytesRead
)
1157 return static_cast< RC
>( osl_readFile( _pData
, pBuffer
, uBytesRequested
, &rBytesRead
) );
1160 /** Write a number of bytes to a file.
1162 Writes a number of bytes to a file.
1163 The internal file pointer is increased by the number of bytes read.
1166 Points to a buffer which contains the data.
1168 @param uBytesToWrite [in]
1169 Number of bytes which should be written.
1171 @param rBytesWritten [out]
1172 On success the number of bytes which have actually been written.
1174 @retval E_None on success
1175 @retval E_INVAL the format of the parameters was not valid
1176 @retval E_FBIG file too large
1177 @retval E_DQUOT quota exceeded
1178 @retval E_AGAIN operation would block
1179 @retval E_BADF bad file
1180 @retval E_FAULT bad address
1181 @retval E_INTR function call was interrupted
1182 @retval E_IO on I/O errosr
1183 @retval E_NOLCK no record locks available
1184 @retval E_NOLINK link has been severed
1185 @retval E_NOSPC no space left on device
1186 @retval E_NXIO no such device or address
1193 RC
write(const void *pBuffer
, sal_uInt64 uBytesToWrite
, sal_uInt64
& rBytesWritten
)
1195 return static_cast< RC
>( osl_writeFile( _pData
, pBuffer
, uBytesToWrite
, &rBytesWritten
) );
1199 /** Read a line from a file.
1201 Reads a line from a file. The new line delimiter is NOT returned!
1203 @param aSeq [in/out]
1204 A reference to a ::rtl::ByteSequence that will hold the line read on success.
1206 @retval E_None on success
1207 @retval E_INVAL the format of the parameters was not valid
1208 @retval E_INTR function call was interrupted
1209 @retval E_IO on I/O errors
1210 @retval E_ISDIR is a directory
1211 @retval E_BADF bad file
1212 @retval E_FAULT bad address
1213 @retval E_AGAIN operation would block
1214 @retval E_NOLINK link has been severed
1222 RC
readLine( ::rtl::ByteSequence
& aSeq
)
1224 return static_cast< RC
>( osl_readLine( _pData
, reinterpret_cast<sal_Sequence
**>(&aSeq
) ) );
1227 /** Synchronize the memory representation of a file with that on the physical medium.
1229 The function ensures that all modified data and attributes of the file associated with
1230 the given file handle have been written to the physical medium.
1231 In case the hard disk has a write cache enabled, the data may not really be on
1232 permanent storage when osl_syncFile returns.
1234 @retval E_None On success
1235 @retval E_INVAL The value of the input parameter is invalid
1236 @retval E_BADF The file is not open for writing
1237 @retval E_IO An I/O error occurred
1238 @retval E_NOSPC There is no enough space on the target device
1239 @retval E_ROFS The file is located on a read only file system
1240 @retval E_TIMEDOUT A remote connection timed out. This may happen when a file is on a remote location
1248 OSL_PRECOND(_pData
, "File::sync(): File not open");
1249 return static_cast< RC
>(osl_syncFile(_pData
));
1252 /** Copy a file to a new destination.
1254 Copies a file to a new destination. Copies only files not directories.
1255 No assumptions should be made about preserving attributes or file time.
1257 @param ustrSourceFileURL [in]
1258 Full qualified URL of the source file.
1260 @param ustrDestFileURL [in]
1261 Full qualified URL of the destination file. A directory is NOT a valid destination file!
1263 @retval E_None on success
1264 @retval E_INVAL the format of the parameters was not valid
1265 @retval E_NOMEM not enough memory for allocating structures
1266 @retval E_ACCES permission denied
1267 @retval E_PERM operation not permitted
1268 @retval E_NAMETOOLONG file name too long
1269 @retval E_NOENT no such file or directory
1270 @retval E_ISDIR is a directory
1271 @retval E_ROFS read-only file system
1277 static RC
copy( const ::rtl::OUString
& ustrSourceFileURL
, const ::rtl::OUString
& ustrDestFileURL
)
1279 return static_cast< RC
>( osl_copyFile( ustrSourceFileURL
.pData
, ustrDestFileURL
.pData
) );
1282 /** Move a file or directory to a new destination or renames it.
1284 Moves a file or directory to a new destination or renames it.
1285 File time and attributes are preserved.
1287 @param ustrSourceFileURL [in]
1288 Full qualified URL of the source file.
1290 @param ustrDestFileURL [in]
1291 Full qualified URL of the destination file. An existing directory is NOT a valid destination !
1293 @retval E_None on success
1294 @retval E_INVAL the format of the parameters was not valid
1295 @retval E_NOMEM not enough memory for allocating structures
1296 @retval E_ACCES permission denied
1297 @retval E_PERM operation not permitted
1298 @retval E_NAMETOOLONG file name too long
1299 @retval E_NOENT no such file or directory
1300 @retval E_ROFS read-only file system
1305 static RC
move( const ::rtl::OUString
& ustrSourceFileURL
, const ::rtl::OUString
& ustrDestFileURL
)
1307 return static_cast< RC
>( osl_moveFile( ustrSourceFileURL
.pData
, ustrDestFileURL
.pData
) );
1310 /** Remove a regular file.
1312 @param ustrFileURL [in]
1313 Full qualified URL of the file to remove.
1315 @retval E_None on success
1316 @retval E_INVAL the format of the parameters was not valid
1317 @retval E_NOMEM not enough memory for allocating structures
1318 @retval E_ACCES permission denied
1319 @retval E_PERM operation not permitted
1320 @retval E_NAMETOOLONG file name too long
1321 @retval E_NOENT no such file or directory
1322 @retval E_ISDIR is a directory
1323 @retval E_ROFS read-only file system
1324 @retval E_FAULT bad address
1325 @retval E_LOOP too many symbolic links encountered
1326 @retval E_IO on I/O errors
1327 @retval E_BUSY device or resource busy
1328 @retval E_INTR function call was interrupted
1329 @retval E_LOOP too many symbolic links encountered
1330 @retval E_MULTIHOP multihop attempted
1331 @retval E_NOLINK link has been severed
1332 @retval E_TXTBSY text file busy
1337 static RC
remove( const ::rtl::OUString
& ustrFileURL
)
1339 return static_cast< RC
>( osl_removeFile( ustrFileURL
.pData
) );
1342 /** Set file attributes.
1344 @param ustrFileURL [in]
1345 The full qualified file URL.
1347 @param uAttributes [in]
1348 Attributes of the file to be set.
1351 @retval E_None on success
1352 @retval E_INVAL the format of the parameters was not valid
1357 static RC
setAttributes( const ::rtl::OUString
& ustrFileURL
, sal_uInt64 uAttributes
)
1359 return static_cast< RC
>( osl_setFileAttributes( ustrFileURL
.pData
, uAttributes
) );
1362 /** Set the file time.
1364 @param ustrFileURL [in]
1365 The full qualified URL of the file.
1367 @param rCreationTime [in]
1368 Creation time of the given file.
1370 @param rLastAccessTime [in]
1371 Time of the last access of the given file.
1373 @param rLastWriteTime [in]
1374 Time of the last modifying of the given file.
1376 @retval E_None on success
1377 @retval E_INVAL the format of the parameters was not valid
1378 @retval E_NOENT no such file or directory not found
1384 const ::rtl::OUString
& ustrFileURL
,
1385 const TimeValue
& rCreationTime
,
1386 const TimeValue
& rLastAccessTime
,
1387 const TimeValue
& rLastWriteTime
)
1389 return static_cast< RC
>( osl_setFileTime(
1393 &rLastWriteTime
) );
1396 friend class DirectoryItem
;
1400 /** The directory item class object provides access to file status information.
1405 class DirectoryItem
: public FileBase
1407 oslDirectoryItem _pData
;
1414 DirectoryItem(): _pData( NULL
)
1418 /** Copy constructor.
1421 DirectoryItem( const DirectoryItem
& rItem
): _pData( rItem
._pData
)
1424 osl_acquireDirectoryItem( _pData
);
1433 osl_releaseDirectoryItem( _pData
);
1436 /** Assignment operator.
1439 DirectoryItem
& operator=(const DirectoryItem
& rItem
)
1444 osl_releaseDirectoryItem( _pData
);
1446 _pData
= rItem
._pData
;
1449 osl_acquireDirectoryItem( _pData
);
1454 /** Check for validity of this instance.
1457 true if object is valid directory item else false.
1462 return _pData
!= NULL
;
1465 /** Retrieve a single directory item.
1467 Retrieves a single directory item. The returned handle has an initial refcount of 1.
1468 Due to performance issues it is not recommended to use this function while
1469 enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
1471 @param ustrFileURL [in]
1472 An absolute file URL.
1475 On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
1476 The handle has to be released by a call to osl_releaseDirectoryItem().
1478 @retval E_None on success
1479 @retval E_INVAL the format of the parameters was not valid
1480 @retval E_NOMEM not enough memory for allocating structures
1481 @retval E_ACCES permission denied
1482 @retval E_MFILE too many open files used by the process
1483 @retval E_NFILE too many open files in the system
1484 @retval E_NOENT no such file or directory
1485 @retval E_LOOP too many symbolic links encountered
1486 @retval E_NAMETOOLONG the file name is too long
1487 @retval E_NOTDIR a component of the path prefix of path is not a directory
1488 @retval E_IO on I/O errors
1489 @retval E_MULTIHOP multihop attempted
1490 @retval E_NOLINK link has been severed
1491 @retval E_FAULT bad address
1492 @retval E_INTR the function call was interrupted
1495 @see Directory::getNextItem()
1498 static RC
get( const ::rtl::OUString
& ustrFileURL
, DirectoryItem
& rItem
)
1502 osl_releaseDirectoryItem( rItem
._pData
);
1503 rItem
._pData
= NULL
;
1506 return static_cast< RC
>( osl_getDirectoryItem( ustrFileURL
.pData
, &rItem
._pData
) );
1509 /** Retrieve information about a single file or directory.
1511 @param rStatus [in|out]
1512 Reference to a class which receives the information of the file or directory
1513 represented by this directory item.
1515 @retval E_None on success
1516 @retval E_NOMEM not enough memory for allocating structures
1517 @retval E_INVAL the format of the parameters was not valid
1518 @retval E_LOOP too many symbolic links encountered
1519 @retval E_ACCES permission denied
1520 @retval E_NOENT no such file or directory
1521 @retval E_NAMETOOLONG file name too long
1522 @retval E_BADF invalid oslDirectoryItem parameter
1523 @retval E_FAULT bad address
1524 @retval E_OVERFLOW value too large for defined data type
1525 @retval E_INTR function call was interrupted
1526 @retval E_NOLINK link has been severed
1527 @retval E_MULTIHOP components of path require hopping to multiple remote machines and the file system does not allow it
1528 @retval E_MFILE too many open files used by the process
1529 @retval E_NFILE too many open files in the system
1530 @retval E_NOSPC no space left on device
1531 @retval E_NXIO no such device or address
1532 @retval E_IO on I/O errors
1533 @retval E_NOSYS function not implemented
1536 @see Directory::getNextItem()
1540 RC
getFileStatus( FileStatus
& rStatus
)
1542 return static_cast< RC
>( osl_getFileStatus( _pData
, &rStatus
._aStatus
, rStatus
._nMask
) );
1545 /** Determine if a directory item point the same underlying file
1547 The comparison is done first by URL, and then by resolving links to
1548 find the target, and finally by comparing inodes on unix.
1551 A directory handle to compare with the underlying object's item
1553 @retval true if the items point to an identical resource<br>
1554 @retval false if the items point to a different resource, or a fatal error occurred<br>
1556 @see osl_getDirectoryItem()
1558 @since LibreOffice 3.6
1560 bool isIdenticalTo( const DirectoryItem
&pOther
)
1562 return osl_identicalDirectoryItem( _pData
, pOther
._pData
);
1565 friend class Directory
;
1569 /** Base class for observers of directory creation notifications.
1571 Clients which uses the method createDirectoryPath of the class
1572 Directory may want to be informed about the directories that
1573 have been created. This may be accomplished by deriving from
1574 this base class and overwriting the virtual function
1577 @see Directory::createPath
1579 class DirectoryCreationObserver
1582 virtual ~DirectoryCreationObserver() {}
1584 /** This method will be called when a new directory has been
1585 created and needs to be overwritten by derived classes.
1586 You must not delete the directory that was just created
1587 otherwise you will run into an endless loop.
1589 @param aDirectoryUrl
1590 [in]The absolute file URL of the directory that was just created by
1591 ::osl::Directory::createPath.
1593 virtual void DirectoryCreated(const rtl::OUString
& aDirectoryUrl
) = 0;
1597 // This just an internal helper function for
1599 extern "C" inline void SAL_CALL
onDirectoryCreated(void* pData
, rtl_uString
* aDirectoryUrl
)
1601 (static_cast<DirectoryCreationObserver
*>(pData
))->DirectoryCreated(aDirectoryUrl
);
1604 /** The directory class object provides a enumeration of DirectoryItems.
1610 class Directory
: public FileBase
1612 oslDirectory _pData
;
1613 ::rtl::OUString _aPath
;
1615 /** Copy constructor.
1618 Directory( Directory
& ) SAL_DELETED_FUNCTION
;
1620 /** Assignment operator.
1623 Directory
& operator = ( Directory
& ) SAL_DELETED_FUNCTION
;
1630 The full qualified URL of the directory.
1631 Relative URLs are not allowed.
1634 Directory( const ::rtl::OUString
& strPath
): _pData( NULL
), _aPath( strPath
)
1649 the URL with which this Directory instance was created.
1651 @since LibreOffice 4.1
1653 rtl::OUString
getURL() const { return _aPath
; }
1655 /** Open a directory for enumerating its contents.
1657 @retval E_None on success
1658 @retval E_INVAL the format of the parameters was not valid
1659 @retval E_NOENT the specified path doesn't exist
1660 @retval E_NOTDIR the specified path is not an directory
1661 @retval E_NOMEM not enough memory for allocating structures
1662 @retval E_ACCES permission denied
1663 @retval E_MFILE too many open files used by the process
1664 @retval E_NFILE too many open files in the system
1665 @retval E_NAMETOOLONG File name too long
1666 @retval E_LOOP Too many symbolic links encountered
1674 return static_cast< RC
>( osl_openDirectory( _aPath
.pData
, &_pData
) );
1677 /** Query if directory is open.
1679 Query if directory is open and so item enumeration is valid.
1681 @retval true if the directory is open else false.
1687 bool isOpen() { return _pData
!= NULL
; }
1689 /** Close a directory.
1691 @retval E_None on success
1692 @retval E_INVAL the format of the parameters was not valid
1693 @retval E_NOMEM not enough memory for allocating structures
1694 @retval E_BADF invalid oslDirectory parameter
1695 @retval E_INTR the function call was interrupted
1702 oslFileError Error
= osl_File_E_BADF
;
1706 Error
=osl_closeDirectory( _pData
);
1710 return static_cast< RC
>( Error
);
1714 /** Resets the directory item enumeration to the beginning.
1716 @retval E_None on success
1717 @retval E_INVAL the format of the parameters was not valid
1718 @retval E_NOENT the specified path doesn't exist
1719 @retval E_NOTDIR the specified path is not an directory
1720 @retval E_NOMEM not enough memory for allocating structures
1721 @retval E_ACCES permission denied
1722 @retval E_MFILE too many open files used by the process
1723 @retval E_NFILE too many open files in the system
1724 @retval E_NAMETOOLONG File name too long
1725 @retval E_LOOP Too many symbolic links encountered
1736 /** Retrieve the next item of a previously opened directory.
1738 Retrieves the next item of a previously opened directory.
1741 On success a valid DirectoryItem.
1744 With this parameter the caller can tell the implementation that (s)he
1745 is going to call this function uHint times afterwards. This enables the implementation to
1746 get the information for more than one file and cache it until the next calls.
1748 @retval E_None on success
1749 @retval E_INVAL the format of the parameters was not valid
1750 @retval E_NOMEM not enough memory for allocating structures
1751 @retval E_NOENT no more entries in this directory
1752 @retval E_BADF invalid oslDirectory parameter
1753 @retval E_OVERFLOW the value too large for defined data type
1758 RC
getNextItem( DirectoryItem
& rItem
, sal_uInt32 nHint
= 0 )
1762 osl_releaseDirectoryItem( rItem
._pData
);
1763 rItem
._pData
= NULL
;
1765 return ( RC
) osl_getNextDirectoryItem( _pData
, &rItem
._pData
, nHint
);
1769 /** Retrieve information about a volume.
1771 Retrieves information about a volume. A volume can either be a mount point, a network
1772 resource or a drive depending on Operating System and File System.
1774 @param ustrDirectoryURL [in]
1775 Full qualified URL of the volume
1778 On success it receives information about the volume.
1780 @retval E_None on success
1781 @retval E_NOMEM not enough memory for allocating structures
1782 @retval E_INVAL the format of the parameters was not valid
1783 @retval E_NOTDIR not a directory
1784 @retval E_NAMETOOLONG file name too long
1785 @retval E_NOENT no such file or directory
1786 @retval E_ACCES permission denied
1787 @retval E_LOOP too many symbolic links encountered
1788 @retval E_FAULT Bad address
1789 @retval E_IO on I/O errors
1790 @retval E_NOSYS function not implemented
1791 @retval E_MULTIHOP multihop attempted
1792 @retval E_NOLINK link has been severed
1793 @retval E_INTR function call was interrupted
1799 static RC
getVolumeInfo( const ::rtl::OUString
& ustrDirectoryURL
, VolumeInfo
& rInfo
)
1801 return static_cast< RC
>( osl_getVolumeInformation( ustrDirectoryURL
.pData
, &rInfo
._aInfo
, rInfo
._nMask
) );
1804 /** Create a directory.
1806 @param ustrDirectoryURL [in]
1807 Full qualified URL of the directory to create.
1810 Optional flags, see osl_createDirectoryWithFlags for details. This
1811 defaulted parameter is new since LibreOffice 4.3.
1813 @retval E_None on success
1814 @retval E_INVAL the format of the parameters was not valid
1815 @retval E_NOMEM not enough memory for allocating structures
1816 @retval E_EXIST file exists
1817 @retval E_ACCES permission denied
1818 @retval E_NAMETOOLONG file name too long
1819 @retval E_NOENT no such file or directory
1820 @retval E_NOTDIR not a directory
1821 @retval E_ROFS read-only file system
1822 @retval E_NOSPC no space left on device
1823 @retval E_DQUOT quota exceeded
1824 @retval E_LOOP too many symbolic links encountered
1825 @retval E_FAULT bad address
1826 @retval E_IO on I/O errors
1827 @retval E_MLINK too many links
1828 @retval E_MULTIHOP multihop attempted
1829 @retval E_NOLINK link has been severed
1835 const ::rtl::OUString
& ustrDirectoryURL
,
1836 sal_uInt32 flags
= osl_File_OpenFlag_Read
| osl_File_OpenFlag_Write
)
1838 return static_cast< RC
>(
1839 osl_createDirectoryWithFlags( ustrDirectoryURL
.pData
, flags
) );
1842 /** Remove an empty directory.
1844 @param ustrDirectoryURL [in]
1845 Full qualified URL of the directory.
1847 @retval E_None on success
1848 @retval E_INVAL the format of the parameters was not valid
1849 @retval E_NOMEM not enough memory for allocating structures
1850 @retval E_PERM operation not permitted
1851 @retval E_ACCES permission denied
1852 @retval E_NOENT no such file or directory
1853 @retval E_NOTDIR not a directory
1854 @retval E_NOTEMPTY directory not empty
1855 @retval E_FAULT bad address
1856 @retval E_NAMETOOLONG file name too long
1857 @retval E_BUSY device or resource busy
1858 @retval E_ROFS read-only file system
1859 @retval E_LOOP too many symbolic links encountered
1860 @retval E_BUSY device or resource busy
1861 @retval E_EXIST file exists
1862 @retval E_IO on I/O errors
1863 @retval E_MULTIHOP multihop attempted
1864 @retval E_NOLINK link has been severed
1869 static RC
remove( const ::rtl::OUString
& ustrDirectoryURL
)
1871 return static_cast< RC
>( osl_removeDirectory( ustrDirectoryURL
.pData
) );
1874 /** Create a directory path.
1876 The osl_createDirectoryPath function creates a specified directory path.
1877 All nonexisting sub directories will be created.
1879 @attention You cannot rely on getting the error code E_EXIST for existing
1880 directories. Programming against this error code is in general a strong
1881 indication of a wrong usage of osl_createDirectoryPath.
1883 @param aDirectoryUrl
1884 [in] The absolute file URL of the directory path to create.
1885 A relative file URL will not be accepted.
1887 @param aDirectoryCreationObserver
1888 [in] Pointer to an instance of type DirectoryCreationObserver that will
1889 be informed about the creation of a directory. The value of this
1890 parameter may be NULL, in this case notifications will not be sent.
1892 @retval E_None On success
1893 @retval E_INVAL The format of the parameters was not valid
1894 @retval E_ACCES Permission denied
1895 @retval E_EXIST The final node of the specified directory path already exist
1896 @retval E_NAMETOOLONG The name of the specified directory path exceeds the maximum allowed length
1897 @retval E_NOTDIR A component of the specified directory path already exist as file in any part of the directory path
1898 @retval E_ROFS Read-only file system
1899 @retval E_NOSPC No space left on device
1900 @retval E_DQUOT Quota exceeded
1901 @retval E_FAULT Bad address
1902 @retval E_IO I/O error
1903 @retval E_LOOP Too many symbolic links encountered
1904 @retval E_NOLINK Link has been severed
1905 @retval E_invalidError An unknown error occurred
1907 @see DirectoryCreationObserver
1910 static RC
createPath(
1911 const ::rtl::OUString
& aDirectoryUrl
,
1912 DirectoryCreationObserver
* aDirectoryCreationObserver
= NULL
)
1914 return static_cast< RC
>(osl_createDirectoryPath(
1915 aDirectoryUrl
.pData
,
1916 (aDirectoryCreationObserver
) ? onDirectoryCreated
: NULL
,
1917 aDirectoryCreationObserver
));
1921 } /* namespace osl */
1923 #endif // INCLUDED_OSL_FILE_HXX
1925 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */