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"
29 #include "sal/log.hxx"
31 #include "rtl/ustring.hxx"
34 #include "osl/diagnose.h"
36 namespace rtl
{ class ByteSequence
; }
42 /** Base class for all File System specific objects.
54 E_None
= osl_File_E_None
, ///< on success
55 E_PERM
= osl_File_E_PERM
, ///< operation not permitted
56 E_NOENT
= osl_File_E_NOENT
, ///< no such file or directory
57 E_SRCH
= osl_File_E_SRCH
, ///< no process matches the PID
58 E_INTR
= osl_File_E_INTR
, ///< function call was interrupted
59 E_IO
= osl_File_E_IO
, ///< I/O error occurred
60 E_NXIO
= osl_File_E_NXIO
, ///< no such device or address
61 E_2BIG
= osl_File_E_2BIG
, ///< argument list too long
62 E_NOEXEC
= osl_File_E_NOEXEC
, ///< invalid executable file format
63 E_BADF
= osl_File_E_BADF
, ///< bad file descriptor
64 E_CHILD
= osl_File_E_CHILD
, ///< there are no child processes
65 E_AGAIN
= osl_File_E_AGAIN
, ///< resource temp unavailable, try again later
66 E_NOMEM
= osl_File_E_NOMEM
, ///< no memory available
67 E_ACCES
= osl_File_E_ACCES
, ///< file permissions do not allow operation
68 E_FAULT
= osl_File_E_FAULT
, ///< bad address; an invalid pointer detected
69 E_BUSY
= osl_File_E_BUSY
, ///< resource busy
70 E_EXIST
= osl_File_E_EXIST
, ///< file exists where should only be created
71 E_XDEV
= osl_File_E_XDEV
, ///< improper link across file systems detected
72 E_NODEV
= osl_File_E_NODEV
, ///< wrong device type specified
73 E_NOTDIR
= osl_File_E_NOTDIR
, ///< file isn't a directory where one is needed
74 E_ISDIR
= osl_File_E_ISDIR
, ///< file is a directory, invalid operation
75 E_INVAL
= osl_File_E_INVAL
, ///< invalid argument to library function
76 E_NFILE
= osl_File_E_NFILE
, ///< too many distinct file openings
77 E_MFILE
= osl_File_E_MFILE
, ///< process has too many distinct files open
78 E_NOTTY
= osl_File_E_NOTTY
, ///< inappropriate I/O control operation
79 E_FBIG
= osl_File_E_FBIG
, ///< file too large
80 E_NOSPC
= osl_File_E_NOSPC
, ///< no space left on device, write failed
81 E_SPIPE
= osl_File_E_SPIPE
, ///< invalid seek operation (such as on pipe)
82 E_ROFS
= osl_File_E_ROFS
, ///< illegal modification to read-only filesystem
83 E_MLINK
= osl_File_E_MLINK
, ///< too many links to file
84 E_PIPE
= osl_File_E_PIPE
, ///< broken pipe; no process reading from other end of pipe
85 E_DOM
= osl_File_E_DOM
, ///< domain error (mathematical error)
86 E_RANGE
= osl_File_E_RANGE
, ///< range error (mathematical error)
87 E_DEADLK
= osl_File_E_DEADLK
, ///< deadlock avoided
88 E_NAMETOOLONG
= osl_File_E_NAMETOOLONG
, ///< filename too long
89 E_NOLCK
= osl_File_E_NOLCK
, ///< no locks available
90 E_NOSYS
= osl_File_E_NOSYS
, ///< function not implemented
91 E_NOTEMPTY
= osl_File_E_NOTEMPTY
, ///< directory not empty
92 E_LOOP
= osl_File_E_LOOP
, ///< too many levels of symbolic links found during name lookup
93 E_ILSEQ
= osl_File_E_ILSEQ
, ///< invalid or incomplete byte sequence of multibyte char found
94 E_NOLINK
= osl_File_E_NOLINK
, ///< link has been severed
95 E_MULTIHOP
= osl_File_E_MULTIHOP
, ///< remote resource is not directly available
96 E_USERS
= osl_File_E_USERS
, ///< file quote system is confused as there are too many users
97 E_OVERFLOW
= osl_File_E_OVERFLOW
, ///< value too large for defined data type
98 E_NOTREADY
= osl_File_E_NOTREADY
, ///< device not ready
99 E_invalidError
= osl_File_E_invalidError
, ///< unmapped error: always last entry in enum!
100 E_TIMEDOUT
= osl_File_E_TIMEDOUT
, ///< socket operation timed out
101 E_NETWORK
= osl_File_E_NETWORK
107 /** Determine a valid unused canonical name for a requested name.
109 Determines a valid unused canonical name for a requested name.
110 Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
111 If a file or directory with the requested name already exists a new name is generated following
112 the common rules on the actual Operating System and File System.
114 @param[in] ustrRequestedURL
115 Requested name of a file or directory.
117 @param[out] ustrValidURL
118 On success receives a name which is unused and valid on the actual Operating System and
121 @retval E_None on success
122 @retval E_INVAL the format of the parameters was not valid
124 @see DirectoryItem::getFileStatus()
127 static RC
getCanonicalName( const ::rtl::OUString
& ustrRequestedURL
, ::rtl::OUString
& ustrValidURL
)
129 return static_cast< RC
>( osl_getCanonicalName( ustrRequestedURL
.pData
, &ustrValidURL
.pData
) );
132 /** Convert a path relative to a given directory into an full qualified file URL.
134 Convert a path relative to a given directory into an full qualified file URL.
135 The function resolves symbolic links if possible and path ellipses, so on success
136 the resulting absolute path is fully resolved.
138 @param[in] ustrBaseDirectoryURL
139 Base directory URL to which the relative path is related to.
141 @param[in] ustrRelativeFileURL
142 A URL of a file or directory relative to the directory path specified by ustrBaseDirectoryURL
144 If ustrRelativeFileURL denotes an absolute path ustrBaseDirectoryURL will be ignored.
146 @param[out] ustrAbsoluteFileURL
147 On success it receives the full qualified absolute file URL.
149 @retval E_None on success
150 @retval E_INVAL the format of the parameters was not valid
151 @retval E_NOMEM not enough memory for allocating structures
152 @retval E_NOTDIR not a directory
153 @retval E_ACCES permission denied
154 @retval E_NOENT no such file or directory
155 @retval E_NAMETOOLONG file name too long
156 @retval E_OVERFLOW value too large for defined data type
157 @retval E_FAULT bad address
158 @retval E_INTR function call was interrupted
159 @retval E_LOOP too many symbolic links encountered
160 @retval E_MULTIHOP multihop attempted
161 @retval E_NOLINK link has been severed
163 @see DirectoryItem::getFileStatus()
166 static RC
getAbsoluteFileURL( const ::rtl::OUString
& ustrBaseDirectoryURL
, const ::rtl::OUString
& ustrRelativeFileURL
, ::rtl::OUString
& ustrAbsoluteFileURL
)
168 return static_cast< RC
>( osl_getAbsoluteFileURL( ustrBaseDirectoryURL
.pData
, ustrRelativeFileURL
.pData
, &ustrAbsoluteFileURL
.pData
) );
171 /** Convert a file URL into a system dependent path.
173 @param[in] ustrFileURL
176 @param[out] ustrSystemPath
177 On success it receives the system path.
179 @retval E_None on success
180 @retval E_INVAL the format of the parameters was not valid
182 @see getFileURLFromSystemPath()
185 static RC
getSystemPathFromFileURL( const ::rtl::OUString
& ustrFileURL
, ::rtl::OUString
& ustrSystemPath
)
187 return static_cast< RC
>( osl_getSystemPathFromFileURL( ustrFileURL
.pData
, &ustrSystemPath
.pData
) );
190 /** Convert a system dependent path into a file URL.
192 @param[in] ustrSystemPath
193 A System dependent path of a file or directory.
195 @param[out] ustrFileURL
196 On success it receives the file URL.
198 @retval E_None on success
199 @retval E_INVAL the format of the parameters was not valid
201 @see getSystemPathFromFileURL()
204 static RC
getFileURLFromSystemPath( const ::rtl::OUString
& ustrSystemPath
, ::rtl::OUString
& ustrFileURL
)
206 return static_cast< RC
>( osl_getFileURLFromSystemPath( ustrSystemPath
.pData
, &ustrFileURL
.pData
) );
209 /** Searche a full qualified system path or a file URL.
211 @param[in] ustrFileName
212 A system dependent path, a file URL, a file or relative directory
214 @param[in] ustrSearchPath
215 A list of system paths, in which a given file has to be searched. The Notation of a path list is
216 system dependent, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
217 These paths are only for the search of a file or a relative path, otherwise it will be ignored.
218 If ustrSearchPath is NULL or while using the search path the search failed, the function searches for
219 a matching file in all system directories and in the directories listed in the PATH environment
221 The value of an environment variable should be used (e.g. LD_LIBRARY_PATH) if the caller is not
222 aware of the Operating System and so doesn't know which path list delimiter to use.
224 @param[out] ustrFileURL
225 On success it receives the full qualified file URL.
227 @retval E_None on success
228 @retval E_INVAL the format of the parameters was not valid
229 @retval E_NOTDIR not a directory
230 @retval E_NOENT no such file or directory not found
232 @see getFileURLFromSystemPath()
233 @see getSystemPathFromFileURL()
236 static RC
searchFileURL( const ::rtl::OUString
& ustrFileName
, const ::rtl::OUString
& ustrSearchPath
, ::rtl::OUString
& ustrFileURL
)
238 return static_cast< RC
>( osl_searchFileURL( ustrFileName
.pData
, ustrSearchPath
.pData
, &ustrFileURL
.pData
) );
241 /** Retrieves the file URL of the system's temporary directory path.
243 @param[out] ustrTempDirURL
244 On success receives the URL of system's temporary directory path.
246 @retval E_None on success
247 @retval E_NOENT no such file or directory not found
250 static RC
getTempDirURL( ::rtl::OUString
& ustrTempDirURL
)
252 return static_cast< RC
>( osl_getTempDirURL( &ustrTempDirURL
.pData
) );
255 /** Creates a temporary file in the directory provided by the caller or the
256 directory returned by getTempDirURL.
257 Under UNIX Operating Systems the file will be created with read and write
258 access for the user exclusively.
259 If the caller requests only a handle to the open file but not the name of
260 it, the file will be automatically removed on close else the caller is
261 responsible for removing the file on success.<br><br>
263 @param[in] pustrDirectoryURL
264 Specifies the full qualified URL where the temporary file should be created.
265 If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
268 On success receives a handle to the open file.
269 If pHandle is 0 the file will be closed on return, in this case
270 pustrTempFileURL must not be 0.
272 @param[out] pustrTempFileURL
273 On success receives the full qualified URL of the temporary file.
274 If pustrTempFileURL is 0 the file will be automatically removed
275 on close, in this case pHandle must not be 0.
276 If pustrTempFileURL is not 0 the caller receives the name of the
277 created file and is responsible for removing the file.
279 Description of the different pHandle, ppustrTempFileURL parameter combinations.
280 pHandle is 0 and pustrTempDirURL is 0 - this combination is invalid<br>
281 pHandle is not 0 and pustrTempDirURL is 0 - a handle to the open file
282 will be returned on success and the file will be automatically removed on close<br>
283 pHandle is 0 and pustrTempDirURL is not 0 - the name of the file will be
284 returned, the caller is responsible for opening, closing and removing the file.<br>
285 pHandle is not 0 and pustrTempDirURL is not 0 - a handle to the open file as well as
286 the file name will be returned, the caller is responsible for closing and removing
289 @retval E_None on success
290 @retval E_INVAL the format of the parameter is invalid
291 @retval E_NOMEM not enough memory for allocating structures
292 @retval E_ACCES Permission denied
293 @retval E_NOENT No such file or directory
294 @retval E_NOTDIR Not a directory
295 @retval E_ROFS Read-only file system
296 @retval E_NOSPC No space left on device
297 @retval E_DQUOT Quota exceeded
302 static RC
createTempFile(
303 ::rtl::OUString
* pustrDirectoryURL
,
304 oslFileHandle
* pHandle
,
305 ::rtl::OUString
* pustrTempFileURL
)
307 rtl_uString
* pustr_dir_url
= pustrDirectoryURL
? pustrDirectoryURL
->pData
: NULL
;
308 rtl_uString
** ppustr_tmp_file_url
= pustrTempFileURL
? &pustrTempFileURL
->pData
: NULL
;
310 return static_cast< RC
>( osl_createTempFile(pustr_dir_url
, pHandle
, ppustr_tmp_file_url
) );
315 /** The VolumeDevice class.
320 class VolumeDevice
: public FileBase
322 oslVolumeDeviceHandle _aHandle
;
329 VolumeDevice() : _aHandle( NULL
)
333 /** Copy constructor.
336 The other volume device.
339 VolumeDevice( const VolumeDevice
& rDevice
)
341 _aHandle
= rDevice
._aHandle
;
343 osl_acquireVolumeDeviceHandle( _aHandle
);
352 osl_releaseVolumeDeviceHandle( _aHandle
);
355 /** Assignment operator.
358 The other volume device.
361 VolumeDevice
& operator =( const VolumeDevice
& rDevice
)
363 oslVolumeDeviceHandle newHandle
= rDevice
._aHandle
;
366 osl_acquireVolumeDeviceHandle( newHandle
);
369 osl_releaseVolumeDeviceHandle( _aHandle
);
371 _aHandle
= newHandle
;
376 /** Get the full qualified URL where a device is mounted to.
379 The full qualified URL where the device is mounted to.
381 rtl::OUString
getMountPath()
384 osl_getVolumeDeviceMountPath( _aHandle
, &aPath
.pData
);
388 friend class VolumeInfo
;
394 /** The VolumeInfo class.
396 Neither copy nor assignment is allowed for this class.
398 @see Directory::getVolumeInfo
404 oslVolumeInfo _aInfo
;
406 VolumeDevice _aDevice
;
408 /** Copy constructor.
411 VolumeInfo( VolumeInfo
& ) SAL_DELETED_FUNCTION
;
413 /** Assignment operator.
416 VolumeInfo
& operator = ( VolumeInfo
& ) SAL_DELETED_FUNCTION
;
423 Set of flags describing the demanded information.
425 VolumeInfo( sal_uInt32 nMask
)
428 memset( &_aInfo
, 0, sizeof( oslVolumeInfo
));
429 _aInfo
.uStructSize
= sizeof( oslVolumeInfo
);
430 _aInfo
.pDeviceHandle
= &_aDevice
._aHandle
;
435 if( _aInfo
.ustrFileSystemName
)
436 rtl_uString_release( _aInfo
.ustrFileSystemName
);
439 /** Check if specified fields are valid.
442 Set of flags for the fields to check.
444 @return true if all fields are valid else false.
446 bool isValid( sal_uInt32 nMask
) const
448 return ( nMask
& _aInfo
.uValidFields
) == nMask
;
451 /** Check the remote flag.
454 true if Attributes are valid and the volume is remote else false.
456 bool getRemoteFlag() const
458 return (_aInfo
.uAttributes
& osl_Volume_Attribute_Remote
) != 0;
461 /** Check the removable flag.
464 true if attributes are valid and the volume is removable else false.
466 bool getRemoveableFlag() const
468 return (_aInfo
.uAttributes
& osl_Volume_Attribute_Removeable
) != 0;
471 /** Check the compact disc flag.
474 true if attributes are valid and the volume is a CDROM else false.
477 bool getCompactDiscFlag() const
479 return (_aInfo
.uAttributes
& osl_Volume_Attribute_CompactDisc
) != 0;
482 /** Check the floppy disc flag.
485 true if attributes are valid and the volume is a floppy disk else false.
488 bool getFloppyDiskFlag() const
490 return (_aInfo
.uAttributes
& osl_Volume_Attribute_FloppyDisk
) != 0;
493 /** Check the fixed disk flag.
496 true if attributes are valid and the volume is a fixed disk else false.
499 bool getFixedDiskFlag() const
501 return (_aInfo
.uAttributes
& osl_Volume_Attribute_FixedDisk
) != 0;
504 /** Check the RAM disk flag.
507 true if attributes are valid and the volume is a RAM disk else false.
510 bool getRAMDiskFlag() const
512 return (_aInfo
.uAttributes
& osl_Volume_Attribute_RAMDisk
) != 0;
515 /** Determine the total space of a volume device.
518 The total diskspace of this volume if this information is valid,
522 sal_uInt64
getTotalSpace() const
524 return _aInfo
.uTotalSpace
;
527 /** Determine the free space of a volume device.
530 The free diskspace of this volume if this information is valid,
534 sal_uInt64
getFreeSpace() const
536 return _aInfo
.uFreeSpace
;
539 /** Determine the used space of a volume device.
542 The used diskspace of this volume if this information is valid,
546 sal_uInt64
getUsedSpace() const
548 return _aInfo
.uUsedSpace
;
551 /** Determine the maximal length of a file name.
554 The maximal length of a file name if this information is valid,
558 sal_uInt32
getMaxNameLength() const
560 return _aInfo
.uMaxNameLength
;
563 /** Determine the maximal length of a path name.
566 The maximal length of a path if this information is valid,
570 sal_uInt32
getMaxPathLength() const
572 return _aInfo
.uMaxPathLength
;
575 /** Determine the name of the volume device's File System.
578 The name of the volume's filesystem if this information is valid,
579 otherwise an empty string.
582 ::rtl::OUString
getFileSystemName() const
584 return _aInfo
.ustrFileSystemName
? ::rtl::OUString( _aInfo
.ustrFileSystemName
) : ::rtl::OUString();
588 /** Get the volume device handle.
591 The device handle of the volume if this information is valid,
592 otherwise returns NULL;
595 VolumeDevice
getDeviceHandle() const
600 /** Return whether the file system is case sensitive or
604 true if the file system is case sensitive false otherwise
606 bool isCaseSensitiveFileSystem() const
608 return (_aInfo
.uAttributes
& osl_Volume_Attribute_Case_Sensitive
) != 0;
611 /** Return whether the file system preserves the case of
612 file and directory names or not
615 true if the file system preserves the case of file and
616 directory names false otherwise
618 bool isCasePreservingFileSystem() const
620 return (_aInfo
.uAttributes
& osl_Volume_Attribute_Case_Is_Preserved
) != 0;
623 friend class Directory
;
629 /** The FileStatus class.
631 @see DirectoryItem::getFileStatus
636 oslFileStatus _aStatus
;
639 /** Copy constructor.
642 FileStatus( FileStatus
& ) SAL_DELETED_FUNCTION
;
644 /** Assignment operator.
647 FileStatus
& operator = ( FileStatus
& ) SAL_DELETED_FUNCTION
;
652 Directory
= osl_File_Type_Directory
,
653 Volume
= osl_File_Type_Volume
,
654 Regular
= osl_File_Type_Regular
,
655 Fifo
= osl_File_Type_Fifo
,
656 Socket
= osl_File_Type_Socket
,
657 Link
= osl_File_Type_Link
,
658 Special
= osl_File_Type_Special
,
659 Unknown
= osl_File_Type_Unknown
665 Set of flags describing the demanded information.
667 FileStatus(sal_uInt32 nMask
)
670 memset(&_aStatus
, 0, sizeof(_aStatus
));
671 _aStatus
.uStructSize
= sizeof(_aStatus
);
678 if ( _aStatus
.ustrFileURL
)
679 rtl_uString_release( _aStatus
.ustrFileURL
);
680 if ( _aStatus
.ustrLinkTargetURL
)
681 rtl_uString_release( _aStatus
.ustrLinkTargetURL
);
682 if ( _aStatus
.ustrFileName
)
683 rtl_uString_release( _aStatus
.ustrFileName
);
686 /** Check if specified fields are valid.
689 Set of flags for the fields to check.
692 true if all fields are valid else false.
695 bool isValid( sal_uInt32 nMask
) const
697 return ( nMask
& _aStatus
.uValidFields
) == nMask
;
700 /** Get the file type.
705 Type
getFileType() const
708 !isValid(osl_FileStatus_Mask_Type
), "sal.osl",
709 "no FileStatus Type determined");
710 return isValid(osl_FileStatus_Mask_Type
)
711 ? static_cast< Type
>(_aStatus
.eType
) : Unknown
;
714 /** Is it a directory?
715 This method returns True for both directories, and volumes.
718 True if it's a directory, False otherwise.
721 @since LibreOffice 3.6
723 bool isDirectory() const
725 return ( getFileType() == Directory
|| getFileType() == Volume
);
728 /** Is it a regular file?
731 True if it's a regular file, False otherwise.
736 @since LibreOffice 3.6
738 bool isRegular() const
740 return ( getFileType() == Regular
);
746 True if it's a link, False otherwise.
749 @since LibreOffice 3.6
753 return ( getFileType() == Link
);
756 /** Get the file attributes.
759 The set of attribute flags of this file.
762 sal_uInt64
getAttributes() const
765 !isValid(osl_FileStatus_Mask_Attributes
), "sal.osl",
766 "no FileStatus Attributes determined");
767 return _aStatus
.uAttributes
;
770 /** Get the creation time of this file.
773 The creation time if this information is valid, an uninitialized
777 TimeValue
getCreationTime() const
780 !isValid(osl_FileStatus_Mask_CreationTime
), "sal.osl",
781 "no FileStatus CreationTime determined");
782 return _aStatus
.aCreationTime
;
785 /** Get the file access time.
788 The last access time if this information is valid, an uninitialized
792 TimeValue
getAccessTime() const
795 !isValid(osl_FileStatus_Mask_AccessTime
), "sal.osl",
796 "no FileStatus AccessTime determined");
797 return _aStatus
.aAccessTime
;
800 /** Get the file modification time.
803 The last modified time if this information is valid, an uninitialized
807 TimeValue
getModifyTime() const
810 !isValid(osl_FileStatus_Mask_ModifyTime
), "sal.osl",
811 "no FileStatus ModifyTime determined");
812 return _aStatus
.aModifyTime
;
815 /** Get the size of the file.
818 The actual file size if this information is valid, 0 otherwise.
821 sal_uInt64
getFileSize() const
824 !isValid(osl_FileStatus_Mask_FileSize
), "sal.osl",
825 "no FileStatus FileSize determined");
826 return _aStatus
.uFileSize
;
829 /** Get the file name.
832 The file name if this information is valid, an empty string otherwise.
835 ::rtl::OUString
getFileName() const
838 !isValid(osl_FileStatus_Mask_FileName
), "sal.osl",
839 "no FileStatus FileName determined");
840 return isValid(osl_FileStatus_Mask_FileName
)
841 ? rtl::OUString(_aStatus
.ustrFileName
) : rtl::OUString();
845 /** Get the URL of the file.
848 The full qualified URL of the file if this information is valid, an
849 empty string otherwise.
852 ::rtl::OUString
getFileURL() const
855 !isValid(osl_FileStatus_Mask_FileURL
), "sal.osl",
856 "no FileStatus FileURL determined");
857 return isValid(osl_FileStatus_Mask_FileURL
)
858 ? rtl::OUString(_aStatus
.ustrFileURL
) : rtl::OUString();
861 /** Get the link target URL.
864 The link target URL if this information is valid, an empty string
868 ::rtl::OUString
getLinkTargetURL() const
871 !isValid(osl_FileStatus_Mask_LinkTargetURL
), "sal.osl",
872 "no FileStatus LinkTargetURL determined");
873 return isValid(osl_FileStatus_Mask_LinkTargetURL
)
874 ? rtl::OUString(_aStatus
.ustrLinkTargetURL
) : rtl::OUString();
877 friend class DirectoryItem
;
881 /** The file class object provides access to file contents and attributes.
887 class File
: public FileBase
889 oslFileHandle _pData
;
890 ::rtl::OUString _aPath
;
892 /** Copy constructor.
895 File( File
& ) SAL_DELETED_FUNCTION
;
897 /** Assignment operator.
900 File
& operator = ( File
& ) SAL_DELETED_FUNCTION
;
906 @param[in] ustrFileURL
907 The full qualified URL of the file. Relative paths are not allowed.
910 File( const ::rtl::OUString
& ustrFileURL
): _pData( NULL
), _aPath( ustrFileURL
) {}
923 the URL with which this File instance was created.
925 @since LibreOffice 4.1
927 rtl::OUString
getURL() const { return _aPath
; }
929 /** Open a regular file.
931 Open a file. Only regular files can be opened.
934 Specifies the open mode.
936 @retval E_None on success
937 @retval E_NOMEM not enough memory for allocating structures
938 @retval E_INVAL the format of the parameters was not valid
939 @retval E_NAMETOOLONG pathname was too long
940 @retval E_NOENT no such file or directory
941 @retval E_ACCES permission denied
942 @retval E_AGAIN a write lock could not be established
943 @retval E_NOTDIR not a directory
944 @retval E_NXIO no such device or address
945 @retval E_NODEV no such device
946 @retval E_ROFS read-only file system
947 @retval E_TXTBSY text file busy
948 @retval E_FAULT bad address
949 @retval E_LOOP too many symbolic links encountered
950 @retval E_NOSPC no space left on device
951 @retval E_ISDIR is a directory
952 @retval E_MFILE too many open files used by the process
953 @retval E_NFILE too many open files in the system
954 @retval E_DQUOT quota exceeded
955 @retval E_EXIST file exists
956 @retval E_INTR function call was interrupted
957 @retval E_IO on I/O errors
958 @retval E_MULTIHOP multihop attempted
959 @retval E_NOLINK link has been severed
960 @retval E_EOVERFLOW value too large for defined data type
971 RC
open( sal_uInt32 uFlags
)
973 return static_cast< RC
>( osl_openFile( _aPath
.pData
, &_pData
, uFlags
) );
976 /** Close an open file.
978 @retval E_None on success
979 @retval E_INVAL the format of the parameters was not valid
980 @retval E_BADF Bad file
981 @retval E_INTR function call was interrupted
982 @retval E_NOLINK link has been severed
983 @retval E_NOSPC no space left on device
984 @retval E_IO on I/O errors
991 oslFileError Error
= osl_File_E_BADF
;
995 Error
=osl_closeFile( _pData
);
999 return static_cast< RC
>( Error
);
1002 /** Set the internal position pointer of an open file.
1005 Distance to move the internal position pointer (from uPos).
1008 Absolute position from the beginning of the file.
1010 @retval E_None on success
1011 @retval E_INVAL the format of the parameters was not valid
1012 @retval E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1018 SAL_WARN_UNUSED_RESULT RC
setPos( sal_uInt32 uHow
, sal_Int64 uPos
)
1020 return static_cast< RC
>( osl_setFilePos( _pData
, uHow
, uPos
) );
1023 /** Retrieve the current position of the internal pointer of an open file.
1026 On success receives the current position of the file pointer.
1028 @retval E_None on success
1029 @retval E_INVAL the format of the parameters was not valid
1030 @retval E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1038 RC
getPos( sal_uInt64
& uPos
)
1040 return static_cast< RC
>( osl_getFilePos( _pData
, &uPos
) );
1043 /** Test if the end of a file is reached.
1046 Points to a variable that receives the end-of-file status.
1048 @retval E_None on success
1049 @retval E_INVAL the format of the parameters was not valid
1050 @retval E_INTR function call was interrupted
1051 @retval E_IO on I/O errors
1052 @retval E_ISDIR is a directory
1053 @retval E_BADF bad file
1054 @retval E_FAULT bad address
1055 @retval E_AGAIN operation would block
1056 @retval E_NOLINK link has been severed
1064 RC
isEndOfFile( sal_Bool
*pIsEOF
)
1066 return static_cast< RC
>( osl_isEndOfFile( _pData
, pIsEOF
) );
1069 /** Set the file size of an open file.
1071 Sets the file size of an open file. The file can be truncated or enlarged by the function.
1072 The position of the file pointer is not affeced by this function.
1077 @retval E_None on success
1078 @retval E_INVAL the format of the parameters was not valid
1079 @retval E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1086 RC
setSize( sal_uInt64 uSize
)
1088 return static_cast< RC
>( osl_setFileSize( _pData
, uSize
) );
1091 /** Get the file size of an open file.
1093 Gets the file size of an open file.
1094 The position of the file pointer is not affeced by this function.
1097 Current size in bytes.
1099 @retval E_None on success
1100 @retval E_INVAL the format of the parameters was not valid
1101 @retval E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
1110 RC
getSize( sal_uInt64
&rSize
)
1112 return static_cast< RC
>( osl_getFileSize( _pData
, &rSize
) );
1115 /** Read a number of bytes from a file.
1117 Reads a number of bytes from a file. The internal file pointer is
1118 increased by the number of bytes read.
1121 Points to a buffer which receives data. The buffer must be large enough
1122 to hold uBytesRequested bytes.
1124 @param[in] uBytesRequested
1125 Number of bytes which should be retrieved.
1127 @param[out] rBytesRead
1128 On success the number of bytes which have actually been retrieved.
1130 @retval E_None on success
1131 @retval E_INVAL the format of the parameters was not valid
1132 @retval E_INTR function call was interrupted
1133 @retval E_IO on I/O errors
1134 @retval E_ISDIR is a directory
1135 @retval E_BADF bad file
1136 @retval E_FAULT bad address
1137 @retval E_AGAIN operation would block
1138 @retval E_NOLINK link has been severed
1146 RC
read( void *pBuffer
, sal_uInt64 uBytesRequested
, sal_uInt64
& rBytesRead
)
1148 return static_cast< RC
>( osl_readFile( _pData
, pBuffer
, uBytesRequested
, &rBytesRead
) );
1151 /** Write a number of bytes to a file.
1153 Writes a number of bytes to a file.
1154 The internal file pointer is increased by the number of bytes read.
1157 Points to a buffer which contains the data.
1159 @param[in] uBytesToWrite
1160 Number of bytes which should be written.
1162 @param[out] rBytesWritten
1163 On success the number of bytes which have actually been written.
1165 @retval E_None on success
1166 @retval E_INVAL the format of the parameters was not valid
1167 @retval E_FBIG file too large
1168 @retval E_DQUOT quota exceeded
1169 @retval E_AGAIN operation would block
1170 @retval E_BADF bad file
1171 @retval E_FAULT bad address
1172 @retval E_INTR function call was interrupted
1173 @retval E_IO on I/O errosr
1174 @retval E_NOLCK no record locks available
1175 @retval E_NOLINK link has been severed
1176 @retval E_NOSPC no space left on device
1177 @retval E_NXIO no such device or address
1184 RC
write(const void *pBuffer
, sal_uInt64 uBytesToWrite
, sal_uInt64
& rBytesWritten
)
1186 return static_cast< RC
>( osl_writeFile( _pData
, pBuffer
, uBytesToWrite
, &rBytesWritten
) );
1190 /** Read a line from a file.
1192 Reads a line from a file. The new line delimiter is NOT returned!
1195 A reference to a ::rtl::ByteSequence that will hold the line read on success.
1197 @retval E_None on success
1198 @retval E_INVAL the format of the parameters was not valid
1199 @retval E_INTR function call was interrupted
1200 @retval E_IO on I/O errors
1201 @retval E_ISDIR is a directory
1202 @retval E_BADF bad file
1203 @retval E_FAULT bad address
1204 @retval E_AGAIN operation would block
1205 @retval E_NOLINK link has been severed
1213 RC
readLine( ::rtl::ByteSequence
& aSeq
)
1215 return static_cast< RC
>( osl_readLine( _pData
, reinterpret_cast<sal_Sequence
**>(&aSeq
) ) );
1218 /** Synchronize the memory representation of a file with that on the physical medium.
1220 The function ensures that all modified data and attributes of the file associated with
1221 the given file handle have been written to the physical medium.
1222 In case the hard disk has a write cache enabled, the data may not really be on
1223 permanent storage when osl_syncFile returns.
1225 @retval E_None On success
1226 @retval E_INVAL The value of the input parameter is invalid
1227 @retval E_BADF The file is not open for writing
1228 @retval E_IO An I/O error occurred
1229 @retval E_NOSPC There is no enough space on the target device
1230 @retval E_ROFS The file is located on a read only file system
1231 @retval E_TIMEDOUT A remote connection timed out. This may happen when a file is on a remote location
1239 OSL_PRECOND(_pData
, "File::sync(): File not open");
1240 return static_cast< RC
>(osl_syncFile(_pData
));
1243 /** Copy a file to a new destination.
1245 Copies a file to a new destination. Copies only files not directories.
1246 No assumptions should be made about preserving attributes or file time.
1248 @param[in] ustrSourceFileURL
1249 Full qualified URL of the source file.
1251 @param[in] ustrDestFileURL
1252 Full qualified URL of the destination file. A directory is NOT a valid destination file!
1254 @retval E_None on success
1255 @retval E_INVAL the format of the parameters was not valid
1256 @retval E_NOMEM not enough memory for allocating structures
1257 @retval E_ACCES permission denied
1258 @retval E_PERM operation not permitted
1259 @retval E_NAMETOOLONG file name too long
1260 @retval E_NOENT no such file or directory
1261 @retval E_ISDIR is a directory
1262 @retval E_ROFS read-only file system
1268 static RC
copy( const ::rtl::OUString
& ustrSourceFileURL
, const ::rtl::OUString
& ustrDestFileURL
)
1270 return static_cast< RC
>( osl_copyFile( ustrSourceFileURL
.pData
, ustrDestFileURL
.pData
) );
1273 /** Move a file or directory to a new destination or renames it.
1275 Moves a file or directory to a new destination or renames it.
1276 File time and attributes are preserved.
1278 @param[in] ustrSourceFileURL
1279 Full qualified URL of the source file.
1281 @param[in] ustrDestFileURL
1282 Full qualified URL of the destination file. An existing directory is NOT a valid destination !
1284 @retval E_None on success
1285 @retval E_INVAL the format of the parameters was not valid
1286 @retval E_NOMEM not enough memory for allocating structures
1287 @retval E_ACCES permission denied
1288 @retval E_PERM operation not permitted
1289 @retval E_NAMETOOLONG file name too long
1290 @retval E_NOENT no such file or directory
1291 @retval E_ROFS read-only file system
1296 static RC
move( const ::rtl::OUString
& ustrSourceFileURL
, const ::rtl::OUString
& ustrDestFileURL
)
1298 return static_cast< RC
>( osl_moveFile( ustrSourceFileURL
.pData
, ustrDestFileURL
.pData
) );
1301 /** Move a file to a new destination or rename it, taking old file's identity (if exists).
1303 Moves or renames a file, replacing an existing file if exist. If the old file existed,
1304 moved file's metadata, e.g. creation time (on FSes which keep files' creation time) or
1305 ACLs, are set to old one's (to keep the old file's identity) - currently this is only
1306 implemented fully on Windows; on other platforms, this is mostly equivalent to osl_moveFile.
1308 @param[in] ustrSourceFileURL
1309 Full qualified URL of the source file.
1311 @param[in] ustrDestFileURL
1312 Full qualified URL of the destination file.
1314 @retval E_None on success
1315 @retval E_INVAL the format of the parameters was not valid
1316 @retval E_NOMEM not enough memory for allocating structures
1317 @retval E_ACCES permission denied
1318 @retval E_PERM operation not permitted
1319 @retval E_NAMETOOLONG file name too long
1320 @retval E_NOENT no such file
1321 @retval E_ROFS read-only file system
1322 @retval E_BUSY device or resource busy
1326 @since LibreOffice 6.2
1328 static RC
replace(const ::rtl::OUString
& ustrSourceFileURL
,
1329 const ::rtl::OUString
& ustrDestFileURL
)
1331 return static_cast<RC
>(osl_replaceFile(ustrSourceFileURL
.pData
, ustrDestFileURL
.pData
));
1334 /** Remove a regular file.
1336 @param[in] ustrFileURL
1337 Full qualified URL of the file to remove.
1339 @retval E_None on success
1340 @retval E_INVAL the format of the parameters was not valid
1341 @retval E_NOMEM not enough memory for allocating structures
1342 @retval E_ACCES permission denied
1343 @retval E_PERM operation not permitted
1344 @retval E_NAMETOOLONG file name too long
1345 @retval E_NOENT no such file or directory
1346 @retval E_ISDIR is a directory
1347 @retval E_ROFS read-only file system
1348 @retval E_FAULT bad address
1349 @retval E_LOOP too many symbolic links encountered
1350 @retval E_IO on I/O errors
1351 @retval E_BUSY device or resource busy
1352 @retval E_INTR function call was interrupted
1353 @retval E_LOOP too many symbolic links encountered
1354 @retval E_MULTIHOP multihop attempted
1355 @retval E_NOLINK link has been severed
1356 @retval E_TXTBSY text file busy
1361 static RC
remove( const ::rtl::OUString
& ustrFileURL
)
1363 return static_cast< RC
>( osl_removeFile( ustrFileURL
.pData
) );
1366 /** Set file attributes.
1368 @param[in] ustrFileURL
1369 The full qualified file URL.
1371 @param[in] uAttributes
1372 Attributes of the file to be set.
1375 @retval E_None on success
1376 @retval E_INVAL the format of the parameters was not valid
1381 static RC
setAttributes( const ::rtl::OUString
& ustrFileURL
, sal_uInt64 uAttributes
)
1383 return static_cast< RC
>( osl_setFileAttributes( ustrFileURL
.pData
, uAttributes
) );
1386 /** Set the file time.
1388 @param[in] ustrFileURL
1389 The full qualified URL of the file.
1391 @param[in] rCreationTime
1392 Creation time of the given file.
1394 @param[in] rLastAccessTime
1395 Time of the last access of the given file.
1397 @param[in] rLastWriteTime
1398 Time of the last modifying of the given file.
1400 @retval E_None on success
1401 @retval E_INVAL the format of the parameters was not valid
1402 @retval E_NOENT no such file or directory not found
1408 const ::rtl::OUString
& ustrFileURL
,
1409 const TimeValue
& rCreationTime
,
1410 const TimeValue
& rLastAccessTime
,
1411 const TimeValue
& rLastWriteTime
)
1413 return static_cast< RC
>( osl_setFileTime(
1417 &rLastWriteTime
) );
1420 friend class DirectoryItem
;
1424 /** The directory item class object provides access to file status information.
1429 class DirectoryItem
: public FileBase
1431 oslDirectoryItem _pData
;
1438 DirectoryItem(): _pData( NULL
)
1442 /** Copy constructor.
1445 DirectoryItem( const DirectoryItem
& rItem
): _pData( rItem
._pData
)
1448 osl_acquireDirectoryItem( _pData
);
1457 osl_releaseDirectoryItem( _pData
);
1460 /** Assignment operator.
1463 DirectoryItem
& operator=(const DirectoryItem
& rItem
)
1468 osl_releaseDirectoryItem( _pData
);
1470 _pData
= rItem
._pData
;
1473 osl_acquireDirectoryItem( _pData
);
1478 /** Check for validity of this instance.
1481 true if object is valid directory item else false.
1486 return _pData
!= NULL
;
1489 /** Retrieve a single directory item.
1491 Retrieves a single directory item. The returned handle has an initial refcount of 1.
1492 Due to performance issues it is not recommended to use this function while
1493 enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
1495 @param[in] ustrFileURL
1496 An absolute file URL.
1499 On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
1500 The handle has to be released by a call to osl_releaseDirectoryItem().
1502 @retval E_None on success
1503 @retval E_INVAL the format of the parameters was not valid
1504 @retval E_NOMEM not enough memory for allocating structures
1505 @retval E_ACCES permission denied
1506 @retval E_MFILE too many open files used by the process
1507 @retval E_NFILE too many open files in the system
1508 @retval E_NOENT no such file or directory
1509 @retval E_LOOP too many symbolic links encountered
1510 @retval E_NAMETOOLONG the file name is too long
1511 @retval E_NOTDIR a component of the path prefix of path is not a directory
1512 @retval E_IO on I/O errors
1513 @retval E_MULTIHOP multihop attempted
1514 @retval E_NOLINK link has been severed
1515 @retval E_FAULT bad address
1516 @retval E_INTR the function call was interrupted
1519 @see Directory::getNextItem()
1522 static RC
get( const ::rtl::OUString
& ustrFileURL
, DirectoryItem
& rItem
)
1526 osl_releaseDirectoryItem( rItem
._pData
);
1527 rItem
._pData
= NULL
;
1530 return static_cast< RC
>( osl_getDirectoryItem( ustrFileURL
.pData
, &rItem
._pData
) );
1533 /** Retrieve information about a single file or directory.
1535 @param[in,out] rStatus
1536 Reference to a class which receives the information of the file or directory
1537 represented by this directory item.
1539 @retval E_None on success
1540 @retval E_NOMEM not enough memory for allocating structures
1541 @retval E_INVAL the format of the parameters was not valid
1542 @retval E_LOOP too many symbolic links encountered
1543 @retval E_ACCES permission denied
1544 @retval E_NOENT no such file or directory
1545 @retval E_NAMETOOLONG file name too long
1546 @retval E_BADF invalid oslDirectoryItem parameter
1547 @retval E_FAULT bad address
1548 @retval E_OVERFLOW value too large for defined data type
1549 @retval E_INTR function call was interrupted
1550 @retval E_NOLINK link has been severed
1551 @retval E_MULTIHOP components of path require hopping to multiple remote machines and the file system does not allow it
1552 @retval E_MFILE too many open files used by the process
1553 @retval E_NFILE too many open files in the system
1554 @retval E_NOSPC no space left on device
1555 @retval E_NXIO no such device or address
1556 @retval E_IO on I/O errors
1557 @retval E_NOSYS function not implemented
1560 @see Directory::getNextItem()
1564 RC
getFileStatus( FileStatus
& rStatus
)
1566 return static_cast< RC
>( osl_getFileStatus( _pData
, &rStatus
._aStatus
, rStatus
._nMask
) );
1569 /** Determine if a directory item point the same underlying file
1571 The comparison is done first by URL, and then by resolving links to
1572 find the target, and finally by comparing inodes on unix.
1575 A directory handle to compare with the underlying object's item
1577 @retval true if the items point to an identical resource<br>
1578 @retval false if the items point to a different resource, or a fatal error occurred<br>
1580 @see osl_getDirectoryItem()
1582 @since LibreOffice 3.6
1584 bool isIdenticalTo( const DirectoryItem
&pOther
)
1586 return osl_identicalDirectoryItem( _pData
, pOther
._pData
);
1589 friend class Directory
;
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
1601 @see Directory::createPath
1603 class DirectoryCreationObserver
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;
1621 // This just an internal helper function for
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 an enumeration of DirectoryItems.
1634 class Directory
: public FileBase
1636 oslDirectory _pData
;
1637 ::rtl::OUString _aPath
;
1639 /** Copy constructor.
1642 Directory( Directory
& ) SAL_DELETED_FUNCTION
;
1644 /** Assignment operator.
1647 Directory
& operator = ( Directory
& ) SAL_DELETED_FUNCTION
;
1654 The full qualified URL of the directory.
1655 Relative URLs are not allowed.
1658 Directory( const ::rtl::OUString
& strPath
): _pData( NULL
), _aPath( strPath
)
1673 the URL with which this Directory instance was created.
1675 @since LibreOffice 4.1
1677 rtl::OUString
getURL() const { return _aPath
; }
1679 /** Open a directory for enumerating its contents.
1681 @retval E_None on success
1682 @retval E_INVAL the format of the parameters was not valid
1683 @retval E_NOENT the specified path doesn't exist
1684 @retval E_NOTDIR the specified path is not a directory
1685 @retval E_NOMEM not enough memory for allocating structures
1686 @retval E_ACCES permission denied
1687 @retval E_MFILE too many open files used by the process
1688 @retval E_NFILE too many open files in the system
1689 @retval E_NAMETOOLONG File name too long
1690 @retval E_LOOP Too many symbolic links encountered
1698 return static_cast< RC
>( osl_openDirectory( _aPath
.pData
, &_pData
) );
1701 /** Query if directory is open.
1703 Query if directory is open and so item enumeration is valid.
1705 @retval true if the directory is open else false.
1711 bool isOpen() { return _pData
!= NULL
; }
1713 /** Close a directory.
1715 @retval E_None on success
1716 @retval E_INVAL the format of the parameters was not valid
1717 @retval E_NOMEM not enough memory for allocating structures
1718 @retval E_BADF invalid oslDirectory parameter
1719 @retval E_INTR the function call was interrupted
1726 oslFileError Error
= osl_File_E_BADF
;
1730 Error
=osl_closeDirectory( _pData
);
1734 return static_cast< RC
>( Error
);
1738 /** Resets the directory item enumeration to the beginning.
1740 @retval E_None on success
1741 @retval E_INVAL the format of the parameters was not valid
1742 @retval E_NOENT the specified path doesn't exist
1743 @retval E_NOTDIR the specified path is not a directory
1744 @retval E_NOMEM not enough memory for allocating structures
1745 @retval E_ACCES permission denied
1746 @retval E_MFILE too many open files used by the process
1747 @retval E_NFILE too many open files in the system
1748 @retval E_NAMETOOLONG File name too long
1749 @retval E_LOOP Too many symbolic links encountered
1760 /** Retrieve the next item of a previously opened directory.
1762 Retrieves the next item of a previously opened directory.
1765 On success a valid DirectoryItem.
1768 With this parameter the caller can tell the implementation that (s)he
1769 is going to call this function uHint times afterwards. This enables the implementation to
1770 get the information for more than one file and cache it until the next calls.
1772 @retval E_None on success
1773 @retval E_INVAL the format of the parameters was not valid
1774 @retval E_NOMEM not enough memory for allocating structures
1775 @retval E_NOENT no more entries in this directory
1776 @retval E_BADF invalid oslDirectory parameter
1777 @retval E_OVERFLOW the value too large for defined data type
1782 RC
getNextItem( DirectoryItem
& rItem
, sal_uInt32 nHint
= 0 )
1786 osl_releaseDirectoryItem( rItem
._pData
);
1787 rItem
._pData
= NULL
;
1789 return static_cast<RC
>(osl_getNextDirectoryItem( _pData
, &rItem
._pData
, nHint
));
1793 /** Retrieve information about a volume.
1795 Retrieves information about a volume. A volume can either be a mount point, a network
1796 resource or a drive depending on Operating System and File System.
1798 @param[in] ustrDirectoryURL
1799 Full qualified URL of the volume
1802 On success it receives information about the volume.
1804 @retval E_None on success
1805 @retval E_NOMEM not enough memory for allocating structures
1806 @retval E_INVAL the format of the parameters was not valid
1807 @retval E_NOTDIR not a directory
1808 @retval E_NAMETOOLONG file name too long
1809 @retval E_NOENT no such file or directory
1810 @retval E_ACCES permission denied
1811 @retval E_LOOP too many symbolic links encountered
1812 @retval E_FAULT Bad address
1813 @retval E_IO on I/O errors
1814 @retval E_NOSYS function not implemented
1815 @retval E_MULTIHOP multihop attempted
1816 @retval E_NOLINK link has been severed
1817 @retval E_INTR function call was interrupted
1823 static RC
getVolumeInfo( const ::rtl::OUString
& ustrDirectoryURL
, VolumeInfo
& rInfo
)
1825 return static_cast< RC
>( osl_getVolumeInformation( ustrDirectoryURL
.pData
, &rInfo
._aInfo
, rInfo
._nMask
) );
1828 /** Create a directory.
1830 @param[in] ustrDirectoryURL
1831 Full qualified URL of the directory to create.
1834 Optional flags, see osl_createDirectoryWithFlags for details. This
1835 defaulted parameter is new since LibreOffice 4.3.
1837 @retval E_None on success
1838 @retval E_INVAL the format of the parameters was not valid
1839 @retval E_NOMEM not enough memory for allocating structures
1840 @retval E_EXIST file exists
1841 @retval E_ACCES permission denied
1842 @retval E_NAMETOOLONG file name too long
1843 @retval E_NOENT no such file or directory
1844 @retval E_NOTDIR not a directory
1845 @retval E_ROFS read-only file system
1846 @retval E_NOSPC no space left on device
1847 @retval E_DQUOT quota exceeded
1848 @retval E_LOOP too many symbolic links encountered
1849 @retval E_FAULT bad address
1850 @retval E_IO on I/O errors
1851 @retval E_MLINK too many links
1852 @retval E_MULTIHOP multihop attempted
1853 @retval E_NOLINK link has been severed
1859 const ::rtl::OUString
& ustrDirectoryURL
,
1860 sal_uInt32 flags
= osl_File_OpenFlag_Read
| osl_File_OpenFlag_Write
)
1862 return static_cast< RC
>(
1863 osl_createDirectoryWithFlags( ustrDirectoryURL
.pData
, flags
) );
1866 /** Remove an empty directory.
1868 @param[in] ustrDirectoryURL
1869 Full qualified URL of the directory.
1871 @retval E_None on success
1872 @retval E_INVAL the format of the parameters was not valid
1873 @retval E_NOMEM not enough memory for allocating structures
1874 @retval E_PERM operation not permitted
1875 @retval E_ACCES permission denied
1876 @retval E_NOENT no such file or directory
1877 @retval E_NOTDIR not a directory
1878 @retval E_NOTEMPTY directory not empty
1879 @retval E_FAULT bad address
1880 @retval E_NAMETOOLONG file name too long
1881 @retval E_BUSY device or resource busy
1882 @retval E_ROFS read-only file system
1883 @retval E_LOOP too many symbolic links encountered
1884 @retval E_BUSY device or resource busy
1885 @retval E_EXIST file exists
1886 @retval E_IO on I/O errors
1887 @retval E_MULTIHOP multihop attempted
1888 @retval E_NOLINK link has been severed
1893 static RC
remove( const ::rtl::OUString
& ustrDirectoryURL
)
1895 return static_cast< RC
>( osl_removeDirectory( ustrDirectoryURL
.pData
) );
1898 /** Create a directory path.
1900 The osl_createDirectoryPath function creates a specified directory path.
1901 All nonexisting sub directories will be created.
1903 @attention You cannot rely on getting the error code E_EXIST for existing
1904 directories. Programming against this error code is in general a strong
1905 indication of a wrong usage of osl_createDirectoryPath.
1907 @param aDirectoryUrl
1908 [in] The absolute file URL of the directory path to create.
1909 A relative file URL will not be accepted.
1911 @param aDirectoryCreationObserver
1912 [in] Pointer to an instance of type DirectoryCreationObserver that will
1913 be informed about the creation of a directory. The value of this
1914 parameter may be NULL, in this case notifications will not be sent.
1916 @retval E_None On success
1917 @retval E_INVAL The format of the parameters was not valid
1918 @retval E_ACCES Permission denied
1919 @retval E_EXIST The final node of the specified directory path already exist
1920 @retval E_NAMETOOLONG The name of the specified directory path exceeds the maximum allowed length
1921 @retval E_NOTDIR A component of the specified directory path already exist as file in any part of the directory path
1922 @retval E_ROFS Read-only file system
1923 @retval E_NOSPC No space left on device
1924 @retval E_DQUOT Quota exceeded
1925 @retval E_FAULT Bad address
1926 @retval E_IO I/O error
1927 @retval E_LOOP Too many symbolic links encountered
1928 @retval E_NOLINK Link has been severed
1929 @retval E_invalidError An unknown error occurred
1931 @see DirectoryCreationObserver
1934 static RC
createPath(
1935 const ::rtl::OUString
& aDirectoryUrl
,
1936 DirectoryCreationObserver
* aDirectoryCreationObserver
= NULL
)
1938 return static_cast< RC
>(osl_createDirectoryPath(
1939 aDirectoryUrl
.pData
,
1940 aDirectoryCreationObserver
? onDirectoryCreated
: NULL
,
1941 aDirectoryCreationObserver
));
1945 } /* namespace osl */
1947 #endif // INCLUDED_OSL_FILE_HXX
1949 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */