tdf#151073 - enable firebird for appstore build w/o experimental mode
[LibreOffice.git] / include / osl / file.h
blob07d2beb2ae1f64cc8df75607172448e2ad312ea0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 * This file is part of LibreOffice published API.
24 #ifndef INCLUDED_OSL_FILE_H
25 #define INCLUDED_OSL_FILE_H
27 #include "sal/config.h"
29 #include "osl/time.h"
30 #include "rtl/ustring.h"
31 #include "sal/saldllapi.h"
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 /** @file
39 Main goals and usage hints
41 The main intention of this interface is to provide a universal portable and
42 high performance access to file system functionality on any operating
43 system.
45 There are a few main goals:
47 1. The path specifications always has to be absolute. Any usage of relative
48 path specifications is forbidden. Exceptions are osl_getSystemPathFromFileURL,
49 osl_getFileURLFromSystemPath and osl_getAbsoluteFileURL. Most operating
50 systems provide a "Current Directory" per process. This is the reason why
51 relative path specifications can cause problems in multithreading
52 environments.
54 2. Proprietary notations of file paths are not supported. Every path notation
55 must the file URL specification. File URLs must be encoded in UTF8 and after
56 that escaped. Although the URL parameter is a unicode string, the must
57 contain only ASCII characters.
59 3. The caller cannot get any information whether a file system is case
60 sensitive, case preserving or not. The operating system implementation
61 itself should determine if it can map case-insensitive paths. The case
62 correct notation of a filename or file path is part of the "File Info". This
63 case correct name can be used as a unique key if necessary.
65 4. Obtaining information about files or volumes is controlled by a bitmask
66 which specifies which fields are of interest. Due to performance reasons it
67 is not recommended to obtain information which is not needed. But if the
68 operating system provides more information anyway the implementation can set
69 more fields on output as were requested. It is in the responsibility of the
70 caller to decide if they use this additional information or not. But they
71 should do so to prevent further unnecessary calls if the information is
72 already there.
74 The input bitmask supports a flag osl_FileStatus_Mask_Validate which can be
75 used to force retrieving uncached validated information. Setting this flag
76 when calling osl_getFileStatus in combination with no other flag is a synonym
77 for a "FileExists". This should only be done when processing a single file
78 (i.e. before opening) and NEVER during enumeration of directory contents on
79 any step of information processing. This would change the runtime behaviour
80 from O(n) to O(n*n/2) on nearly every file system. On Windows NT reading the
81 contents of a directory with 7000 entries and getting full information about
82 every file only takes 0.6 seconds. Specifying the flag
83 osl_FileStatus_Mask_Validate for each entry will increase the time to 180
84 seconds (!!!).
88 /* Error codes according to errno */
89 typedef enum {
90 osl_File_E_None, /*!< on success */
91 osl_File_E_PERM, /*!< operation not permitted */
92 osl_File_E_NOENT, /*!< no such file or directory */
93 osl_File_E_SRCH, /*!< no process matches the PID */
94 osl_File_E_INTR, /*!< function call was interrupted */
95 osl_File_E_IO, /*!< I/O error occurred */
96 osl_File_E_NXIO, /*!< no such device or address */
97 osl_File_E_2BIG, /*!< argument list too long */
98 osl_File_E_NOEXEC, /*!< invalid executable file format */
99 osl_File_E_BADF, /*!< bad file descriptor */
100 osl_File_E_CHILD, /*!< there are no child processes */
101 osl_File_E_AGAIN, /*!< resource temp unavailable, try again later */
102 osl_File_E_NOMEM, /*!< no memory available */
103 osl_File_E_ACCES, /*!< file permissions do not allow operation */
104 osl_File_E_FAULT, /*!< bad address; an invalid pointer detected */
105 osl_File_E_BUSY, /*!< resource busy */
106 osl_File_E_EXIST, /*!< file exists where should only be created */
107 osl_File_E_XDEV, /*!< improper link across file systems detected */
108 osl_File_E_NODEV, /*!< wrong device type specified */
109 osl_File_E_NOTDIR, /*!< file isn't a directory where one is needed */
110 osl_File_E_ISDIR, /*!< file is a directory, invalid operation */
111 osl_File_E_INVAL, /*!< invalid argument to library function */
112 osl_File_E_NFILE, /*!< too many distinct file openings */
113 osl_File_E_MFILE, /*!< process has too many distinct files open */
114 osl_File_E_NOTTY, /*!< inappropriate I/O control operation */
115 osl_File_E_FBIG, /*!< file too large */
116 osl_File_E_NOSPC, /*!< no space left on device, write failed */
117 osl_File_E_SPIPE, /*!< invalid seek operation (such as on pipe) */
118 osl_File_E_ROFS, /*!< illegal modification to read-only filesystem */
119 osl_File_E_MLINK, /*!< too many links to file */
120 osl_File_E_PIPE, /*!< broken pipe; no process reading from other end of pipe */
121 osl_File_E_DOM, /*!< domain error (mathematical error) */
122 osl_File_E_RANGE, /*!< range error (mathematical error) */
123 osl_File_E_DEADLK, /*!< deadlock avoided */
124 osl_File_E_NAMETOOLONG, /*!< filename too long */
125 osl_File_E_NOLCK, /*!< no locks available */
126 osl_File_E_NOSYS, /*!< function not implemented */
127 osl_File_E_NOTEMPTY, /*!< directory not empty */
128 osl_File_E_LOOP, /*!< too many levels of symbolic links found during name lookup */
129 osl_File_E_ILSEQ, /*!< invalid or incomplete byte sequence of multibyte char found */
130 osl_File_E_NOLINK, /*!< link has been severed */
131 osl_File_E_MULTIHOP, /*!< remote resource is not directly available */
132 osl_File_E_USERS, /*!< file quote system is confused as there are too many users */
133 osl_File_E_OVERFLOW, /*!< value too large for defined data type */
134 osl_File_E_NOTREADY, /*!< device not ready */
135 osl_File_E_invalidError, /*!< unmapped error: always last entry in enum! */
136 osl_File_E_TIMEDOUT, /*!< socket operation timed out */
137 osl_File_E_NETWORK, /*!< unexpected network error occurred (Windows) - could be a
138 user session was deleted, or an unexpected network error
139 occurred */
140 osl_File_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
141 } oslFileError;
143 typedef void *oslDirectory;
144 typedef void *oslDirectoryItem;
146 /** Open a directory for enumerating its contents.
148 @param[in] pustrDirectoryURL
149 The full qualified URL of the directory.
151 @param[out] pDirectory
152 On success it receives a handle used for subsequent calls by osl_getNextDirectoryItem().
153 The handle has to be released by a call to osl_closeDirectory().
155 @retval osl_File_E_None on success
156 @retval osl_File_E_INVAL the format of the parameters was not valid
157 @retval osl_File_E_NOENT the specified path doesn't exist
158 @retval osl_File_E_NOTDIR the specified path is not a directory
159 @retval osl_File_E_NOMEM not enough memory for allocating structures
160 @retval osl_File_E_ACCES permission denied
161 @retval osl_File_E_MFILE too many open files used by the process
162 @retval osl_File_E_NFILE too many open files in the system
163 @retval osl_File_E_NAMETOOLONG File name too long
164 @retval osl_File_E_LOOP Too many symbolic links encountered
166 @see osl_getNextDirectoryItem()
167 @see osl_closeDirectory()
169 SAL_DLLPUBLIC oslFileError SAL_CALL osl_openDirectory(
170 rtl_uString *pustrDirectoryURL, oslDirectory *pDirectory);
172 /** Retrieve the next item of a previously opened directory.
174 Retrieves the next item of a previously opened directory.
175 All handles have an initial refcount of 1.
177 @param[in] Directory
178 A directory handle received from a previous call to osl_openDirectory().
180 @param[out] pItem
181 On success it receives a handle that can be used for subsequent calls to osl_getFileStatus().
182 The handle has to be released by a call to osl_releaseDirectoryItem().
184 @param[in] uHint
185 With this parameter the caller can tell the implementation that (s)he
186 is going to call this function uHint times afterwards. This enables the implementation to
187 get the information for more than one file and cache it until the next calls.
189 @retval osl_File_E_None on success
190 @retval osl_File_E_INVAL the format of the parameters was not valid
191 @retval osl_File_E_NOMEM not enough memory for allocating structures
192 @retval osl_File_E_NOENT no more entries in this directory
193 @retval osl_File_E_BADF invalid oslDirectory parameter
194 @retval osl_File_E_OVERFLOW the value too large for defined data type
196 @see osl_releaseDirectoryItem()
197 @see osl_acquireDirectoryItem()
198 @see osl_getDirectoryItem()
199 @see osl_getFileStatus()
201 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getNextDirectoryItem(
202 oslDirectory Directory,
203 oslDirectoryItem *pItem,
204 sal_uInt32 uHint
207 /** Release a directory handle.
209 @param[in] Directory
210 A handle received by a call to osl_openDirectory().
212 @retval osl_File_E_None on success
213 @retval osl_File_E_INVAL the format of the parameters was not valid
214 @retval osl_File_E_NOMEM not enough memory for allocating structures
215 @retval osl_File_E_BADF invalid oslDirectory parameter
216 @retval osl_File_E_INTR the function call was interrupted
218 @see osl_openDirectory()
220 SAL_DLLPUBLIC oslFileError SAL_CALL osl_closeDirectory(
221 oslDirectory Directory);
223 /** Retrieve a single directory item.
225 Retrieves a single directory item. The returned handle has an initial refcount of 1.
226 Due to performance issues it is not recommended to use this function while
227 enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
229 @param[in] pustrFileURL
230 An absolute file URL.
232 @param[out] pItem
233 On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
234 The handle has to be released by a call to osl_releaseDirectoryItem().
236 @retval osl_File_E_None on success
237 @retval osl_File_E_INVAL the format of the parameters was not valid
238 @retval osl_File_E_NOMEM not enough memory for allocating structures
239 @retval osl_File_E_ACCES permission denied
240 @retval osl_File_E_MFILE too many open files used by the process
241 @retval osl_File_E_NFILE too many open files in the system
242 @retval osl_File_E_NOENT no such file or directory
243 @retval osl_File_E_LOOP too many symbolic links encountered
244 @retval osl_File_E_NAMETOOLONG the file name is too long
245 @retval osl_File_E_NOTDIR a component of the path prefix of path is not a directory
246 @retval osl_File_E_IO on I/O errors
247 @retval osl_File_E_MULTIHOP multihop attempted
248 @retval osl_File_E_NOLINK link has been severed
249 @retval osl_File_E_FAULT bad address
250 @retval osl_File_E_INTR the function call was interrupted
252 @see osl_releaseDirectoryItem()
253 @see osl_acquireDirectoryItem()
254 @see osl_getFileStatus()
255 @see osl_getNextDirectoryItem()
257 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getDirectoryItem(
258 rtl_uString *pustrFileURL,
259 oslDirectoryItem *pItem
262 /** Increase the refcount of a directory item handle.
264 The caller responsible for releasing the directory item handle using osl_releaseDirectoryItem().
266 @param[in] Item
267 A handle received by a call to osl_getDirectoryItem() or osl_getNextDirectoryItem().
269 @retval osl_File_E_None on success
270 @retval osl_File_E_NOMEM not enough memory for allocating structures
271 @retval osl_File_E_INVAL the format of the parameters was not valid
273 @see osl_getDirectoryItem()
274 @see osl_getNextDirectoryItem()
275 @see osl_releaseDirectoryItem()
277 SAL_DLLPUBLIC oslFileError SAL_CALL osl_acquireDirectoryItem(
278 oslDirectoryItem Item );
281 /** Decrease the refcount of a directory item handle.
283 Decreases the refcount of a directory item handle.
284 If the refcount reaches 0 the data associated with
285 this directory item handle will be released.
287 @param[in] Item
288 A handle received by a call to osl_getDirectoryItem() or osl_getNextDirectoryItem().
290 @retval osl_File_E_None on success
291 @retval osl_File_E_NOMEM not enough memory for allocating structures
292 @retval osl_File_E_INVAL the format of the parameters was not valid
294 @see osl_getDirectoryItem()
295 @see osl_getNextDirectoryItem()
296 @see osl_acquireDirectoryItem()
298 SAL_DLLPUBLIC oslFileError SAL_CALL osl_releaseDirectoryItem(
299 oslDirectoryItem Item );
301 /** Determine if two directory items point the same underlying file
303 The comparison is done first by URL, and then by resolving links to
304 find the target, and finally by comparing inodes on unix.
306 @param[in] pItemA
307 A directory handle to compare with another handle
309 @param[in] pItemB
310 A directory handle to compare with pItemA
312 @retval sal_True if the items point to an identical resource
313 @retval sal_False if the items point to a different resource, or a fatal error occurred
315 @see osl_getDirectoryItem()
317 @since LibreOffice 3.6
319 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_identicalDirectoryItem(
320 oslDirectoryItem pItemA,
321 oslDirectoryItem pItemB );
324 @defgroup filetype File types
328 typedef enum {
329 osl_File_Type_Directory, /*< directory */
330 osl_File_Type_Volume, /*< volume (e.g. C:, A:) */
331 osl_File_Type_Regular, /*< regular file */
332 osl_File_Type_Fifo, /*< named pipe */
333 osl_File_Type_Socket, /*< socket */
334 osl_File_Type_Link, /*< file link */
335 osl_File_Type_Special, /*< special device file */
336 osl_File_Type_Unknown /*< unknown file type */
337 } oslFileType;
338 /** @} */
341 @defgroup fileattrs File attributes
345 #define osl_File_Attribute_ReadOnly 0x00000001
346 #define osl_File_Attribute_Hidden 0x00000002
347 #define osl_File_Attribute_Executable 0x00000010
348 #define osl_File_Attribute_GrpWrite 0x00000020
349 #define osl_File_Attribute_GrpRead 0x00000040
350 #define osl_File_Attribute_GrpExe 0x00000080
351 #define osl_File_Attribute_OwnWrite 0x00000100
352 #define osl_File_Attribute_OwnRead 0x00000200
353 #define osl_File_Attribute_OwnExe 0x00000400
354 #define osl_File_Attribute_OthWrite 0x00000800
355 #define osl_File_Attribute_OthRead 0x00001000
356 #define osl_File_Attribute_OthExe 0x00002000
357 /** @} */
360 @defgroup filestatus Flags specifying which fields to retrieve by osl_getFileStatus
364 #define osl_FileStatus_Mask_Type 0x00000001
365 #define osl_FileStatus_Mask_Attributes 0x00000002
366 #define osl_FileStatus_Mask_CreationTime 0x00000010
367 #define osl_FileStatus_Mask_AccessTime 0x00000020
368 #define osl_FileStatus_Mask_ModifyTime 0x00000040
369 #define osl_FileStatus_Mask_FileSize 0x00000080
370 #define osl_FileStatus_Mask_FileName 0x00000100
371 #define osl_FileStatus_Mask_FileURL 0x00000200
372 #define osl_FileStatus_Mask_LinkTargetURL 0x00000400
373 #define osl_FileStatus_Mask_All 0x7FFFFFFF
374 #define osl_FileStatus_Mask_Validate 0x80000000
375 /** @} */
377 /** Structure containing information about files and directories
379 @see osl_getFileStatus()
380 @see oslFileType
382 typedef struct _oslFileStatus {
383 /** Must be initialized with the size in bytes of the structure before passing it to any function */
384 sal_uInt32 uStructSize;
385 /** Determines which members of the structure contain valid data */
386 sal_uInt32 uValidFields;
387 /** The type of the file (file, directory, volume). */
388 oslFileType eType;
389 /** File attributes */
390 sal_uInt64 uAttributes;
391 /** First creation time in nanoseconds since 1/1/1970. Can be the last modify time depending on
392 platform or file system. */
393 TimeValue aCreationTime;
394 /** Last access time in nanoseconds since 1/1/1970. Can be the last modify time depending on
395 platform or file system. */
396 TimeValue aAccessTime;
397 /** Last modify time in nanoseconds since 1/1/1970. */
398 TimeValue aModifyTime;
399 /** Size in bytes of the file. Zero for directories and volumes. */
400 sal_uInt64 uFileSize;
401 /** Case correct name of the file. Should be set to zero before calling osl_getFileStatus
402 and released after usage. */
403 rtl_uString *ustrFileName;
404 /** Full URL of the file. Should be set to zero before calling osl_getFileStatus
405 and released after usage. */
406 rtl_uString *ustrFileURL;
407 /** Full URL of the target file if the file itself is a link.
408 Should be set to zero before calling osl_getFileStatus
409 and released after usage. */
410 rtl_uString *ustrLinkTargetURL;
411 } oslFileStatus;
413 /** Retrieve information about a single file or directory.
415 @param[in] Item
416 A handle received by a previous call to osl_getDirectoryItem() or osl_getNextDirectoryItem().
418 @param[in,out] pStatus
419 Points to a structure which receives the information of the file or directory
420 represented by the handle Item. The member uStructSize has to be initialized to
421 sizeof(oslFileStatus) before calling this function.
423 @param[in] uFieldMask
424 Specifies which fields of the structure pointed to by pStatus are of interest to the caller.
426 @retval osl_File_E_None on success
427 @retval osl_File_E_NOMEM not enough memory for allocating structures
428 @retval osl_File_E_INVAL the format of the parameters was not valid
429 @retval osl_File_E_LOOP too many symbolic links encountered
430 @retval osl_File_E_ACCES permission denied
431 @retval osl_File_E_NOENT no such file or directory
432 @retval osl_File_E_NAMETOOLONG file name too long
433 @retval osl_File_E_BADF invalid oslDirectoryItem parameter
434 @retval osl_File_E_FAULT bad address
435 @retval osl_File_E_OVERFLOW value too large for defined data type
436 @retval osl_File_E_INTR function call was interrupted
437 @retval osl_File_E_NOLINK link has been severed
438 @retval osl_File_E_MULTIHOP components of path require hopping to multiple
439 remote machines and the file system does not allow it
440 @retval osl_File_E_MFILE too many open files used by the process
441 @retval osl_File_E_NFILE too many open files in the system
442 @retval osl_File_E_NOSPC no space left on device
443 @retval osl_File_E_NXIO no such device or address
444 @retval osl_File_E_IO on I/O errors
445 @retval osl_File_E_NOSYS function not implemented
447 @see osl_getDirectoryItem()
448 @see osl_getNextDirectoryItem()
449 @see oslFileStatus
451 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getFileStatus(
452 oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask );
454 typedef void *oslVolumeDeviceHandle;
456 /** Release a volume device handle.
458 Releases the given oslVolumeDeviceHandle which was acquired by a call to
459 osl_getVolumeInformation() or osl_acquireVolumeDeviceHandle().
461 @param[in] Handle
462 An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
464 @retval
465 osl_File_E_None on success
467 @todo
468 specify all error codes that may be returned
470 @see osl_acquireVolumeDeviceHandle()
471 @see osl_getVolumeInformation()
473 SAL_DLLPUBLIC oslFileError SAL_CALL osl_releaseVolumeDeviceHandle(
474 oslVolumeDeviceHandle Handle );
476 /** Acquire a volume device handle.
478 Acquires the given oslVolumeDeviceHandle which was acquired by a call to
479 osl_getVolumeInformation(). The caller is responsible for releasing the
480 acquired handle by calling osl_releaseVolumeDeviceHandle().
482 @param[in] Handle
483 An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
485 @retval
486 osl_File_E_None on success
488 @todo
489 specify all error codes that may be returned
491 @see osl_getVolumeInformation()
493 SAL_DLLPUBLIC oslFileError SAL_CALL osl_acquireVolumeDeviceHandle(
494 oslVolumeDeviceHandle Handle );
496 /** Get the full qualified URL where a device is mounted to.
498 @param[in] Handle
499 An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
501 @param[out] ppustrDirectoryURL
502 Receives the full qualified URL where the device is mounted to.
504 @retval osl_File_E_None on success
505 @retval osl_File_E_NOMEM not enough memory for allocating structures
506 @retval osl_File_E_INVAL the format of the parameters was not valid
507 @retval osl_File_E_ACCES permission denied
508 @retval osl_File_E_NXIO no such device or address
509 @retval osl_File_E_NODEV no such device
510 @retval osl_File_E_NOENT no such file or directory
511 @retval osl_File_E_FAULT bad address
512 @retval osl_FilE_E_INTR function call was interrupted
513 @retval osl_File_E_IO on I/O errors
514 @retval osl_File_E_MULTIHOP multihop attempted
515 @retval osl_File_E_NOLINK link has been severed
516 @retval osl_File_E_EOVERFLOW value too large for defined data type
518 @see osl_getVolumeInformation()
520 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getVolumeDeviceMountPath(
521 oslVolumeDeviceHandle Handle, rtl_uString **ppustrDirectoryURL);
524 @defgroup volattrs Volume attributes
528 #define osl_Volume_Attribute_Removeable 0x00000001
529 #define osl_Volume_Attribute_Remote 0x00000002
530 #define osl_Volume_Attribute_CompactDisc 0x00000004
531 #define osl_Volume_Attribute_FixedDisk 0x00000008
532 #define osl_Volume_Attribute_RAMDisk 0x00000010
533 #define osl_Volume_Attribute_FloppyDisk 0x00000020
535 #define osl_Volume_Attribute_Case_Is_Preserved 0x00000040
536 #define osl_Volume_Attribute_Case_Sensitive 0x00000080
538 /** @} */
541 @defgroup volinfoflags Flags specifying which fields to retrieve by osl_getVolumeInfo
546 #define osl_VolumeInfo_Mask_Attributes 0x00000001
547 #define osl_VolumeInfo_Mask_TotalSpace 0x00000002
548 #define osl_VolumeInfo_Mask_UsedSpace 0x00000004
549 #define osl_VolumeInfo_Mask_FreeSpace 0x00000008
550 #define osl_VolumeInfo_Mask_MaxNameLength 0x00000010
551 #define osl_VolumeInfo_Mask_MaxPathLength 0x00000020
552 #define osl_VolumeInfo_Mask_FileSystemName 0x00000040
553 #define osl_VolumeInfo_Mask_DeviceHandle 0x00000080
554 #define osl_VolumeInfo_Mask_FileSystemCaseHandling 0x00000100
556 /** @} */
558 /** Structure containing information about volumes
560 @see osl_getVolumeInformation()
561 @see oslFileType
564 typedef struct _oslVolumeInfo {
565 /** Must be initialized with the size in bytes of the structure before
566 passing it to any function */
567 sal_uInt32 uStructSize;
568 /** Determines which members of the structure contain valid data */
569 sal_uInt32 uValidFields;
570 /** Attributes of the volume (remote and/or removable) */
571 sal_uInt32 uAttributes;
572 /** Total available space on the volume for the current process/user */
573 sal_uInt64 uTotalSpace;
574 /** Used space on the volume for the current process/user */
575 sal_uInt64 uUsedSpace;
576 /** Free space on the volume for the current process/user */
577 sal_uInt64 uFreeSpace;
578 /** Maximum length of file name of a single item */
579 sal_uInt32 uMaxNameLength;
580 /** Maximum length of a full qualified path in system notation */
581 sal_uInt32 uMaxPathLength;
582 /** Points to a string that receives the name of the file system type. String
583 should be set to zero before calling osl_getVolumeInformation and released
584 after usage. */
585 rtl_uString *ustrFileSystemName;
586 /** Pointer to handle the receives underlying device. Handle should be set to
587 zero before calling osl_getVolumeInformation */
588 oslVolumeDeviceHandle *pDeviceHandle;
589 } oslVolumeInfo;
591 /** Retrieve information about a volume.
593 Retrieves information about a volume. A volume can either be a mount point, a network
594 resource or a drive depending on Operating System and File System. Before calling this
595 function osl_getFileStatus() should be called to determine if the type is
596 osl_file_Type_Volume.
598 @param[in] pustrDirectoryURL
599 Full qualified URL of the volume
601 @param[out] pInfo
602 On success it receives information about the volume.
604 @param[in] uFieldMask
605 Specifies which members of the structure should be filled
607 @retval osl_File_E_None on success
608 @retval osl_File_E_NOMEM not enough memory for allocating structures
609 @retval osl_File_E_INVAL the format of the parameters was not valid
610 @retval osl_File_E_NOTDIR not a directory
611 @retval osl_File_E_NAMETOOLONG file name too long
612 @retval osl_File_E_NOENT no such file or directory
613 @retval osl_File_E_ACCES permission denied
614 @retval osl_File_E_LOOP too many symbolic links encountered
615 @retval ols_File_E_FAULT Bad address
616 @retval osl_File_E_IO on I/O errors
617 @retval osl_File_E_NOSYS function not implemented
618 @retval osl_File_E_MULTIHOP multihop attempted
619 @retval osl_File_E_NOLINK link has been severed
620 @retval osl_File_E_INTR function call was interrupted
622 @see osl_getFileStatus()
623 @see oslVolumeInfo
625 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getVolumeInformation(
626 rtl_uString *pustrDirectoryURL,
627 oslVolumeInfo *pInfo,
628 sal_uInt32 uFieldMask );
630 typedef void *oslFileHandle;
632 /* Open flags */
634 #define osl_File_OpenFlag_Read 0x00000001
635 #define osl_File_OpenFlag_Write 0x00000002
636 #define osl_File_OpenFlag_Create 0x00000004
637 #define osl_File_OpenFlag_NoLock 0x00000008
638 /* larger bit-fields reserved for internal use cf. detail/file.h */
640 /** Open a regular file.
642 Open a file. Only regular files can be opened.
644 @param[in] pustrFileURL
645 The full qualified URL of the file to open.
647 @param[out] pHandle
648 On success it receives a handle to the open file.
650 @param[in] uFlags
651 Specifies the open mode.
653 On Android, if the file path is below the /assets folder, the file
654 exists only as a hopefully uncompressed element inside the app
655 package (.apk), which has been mapped into memory as a whole by
656 the LibreOffice Android bootstrapping code. So files "opened" from
657 there aren't actually files in the OS sense.
659 @retval osl_File_E_None on success
660 @retval osl_File_E_NOMEM not enough memory for allocating structures
661 @retval osl_File_E_INVAL the format of the parameters was not valid
662 @retval osl_File_E_NAMETOOLONG pathname was too long
663 @retval osl_File_E_NOENT no such file or directory
664 @retval osl_File_E_ACCES permission denied
665 @retval osl_File_E_AGAIN a write lock could not be established
666 @retval osl_File_E_NOTDIR not a directory
667 @retval osl_File_E_NXIO no such device or address
668 @retval osl_File_E_NODEV no such device
669 @retval osl_File_E_ROFS read-only file system
670 @retval osl_File_E_TXTBSY text file busy
671 @retval osl_File_E_FAULT bad address
672 @retval osl_File_E_LOOP too many symbolic links encountered
673 @retval osl_File_E_NOSPC no space left on device
674 @retval osl_File_E_ISDIR is a directory
675 @retval osl_File_E_MFILE too many open files used by the process
676 @retval osl_File_E_NFILE too many open files in the system
677 @retval osl_File_E_DQUOT quota exceeded
678 @retval osl_File_E_EXIST file exists
679 @retval osl_FilE_E_INTR function call was interrupted
680 @retval osl_File_E_IO on I/O errors
681 @retval osl_File_E_MULTIHOP multihop attempted
682 @retval osl_File_E_NOLINK link has been severed
683 @retval osl_File_E_EOVERFLOW value too large for defined data type
685 @see osl_closeFile()
686 @see osl_setFilePos()
687 @see osl_getFilePos()
688 @see osl_readFile()
689 @see osl_writeFile()
690 @see osl_setFileSize()
691 @see osl_getFileSize()
693 SAL_DLLPUBLIC oslFileError SAL_CALL osl_openFile(
694 rtl_uString *pustrFileURL, oslFileHandle *pHandle, sal_uInt32 uFlags );
696 #define osl_Pos_Absolut 1
697 #define osl_Pos_Current 2
698 #define osl_Pos_End 3
700 /** Set the internal position pointer of an open file.
702 @param[in] Handle
703 Handle to a file received by a previous call to osl_openFile().
705 @param[in] uHow
706 How to calculate the offset - osl_Pos_Absolut means start at the
707 beginning of the file, osl_Pos_Current means offset from the current
708 seek position and osl_Pos_End means the offset will be negative and
709 the position will be calculated backwards from the end of the file by
710 the offset provided.
712 @param[in] uPos
713 Seek offset, depending on uHow. If uHow is osl_Pos_End then the value must be negative.
715 @retval osl_File_E_None on success
716 @retval osl_File_E_INVAL the format of the parameters was not valid
717 (e.g. if uHow is osl_Pos_End then must be negative)
718 @retval osl_File_E_OVERFLOW the resulting file offset would be a
719 value which cannot be represented correctly for regular files
721 @see osl_openFile()
722 @see osl_getFilePos()
724 SAL_WARN_UNUSED_RESULT SAL_DLLPUBLIC oslFileError SAL_CALL osl_setFilePos(
725 oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos );
727 /** Retrieve the current position of the internal pointer of an open file.
729 @param[in] Handle
730 Handle to a file received by a previous call to osl_openFile().
732 @param[out] pPos
733 On success receives the current position of the file pointer.
735 @retval osl_File_E_None on success
736 @retval osl_File_E_INVAL the format of the parameters was not valid
737 @retval osl_File_E_OVERFLOW the resulting file offset would be a value
738 which cannot be represented correctly for regular files
740 @see osl_openFile()
741 @see osl_setFilePos()
742 @see osl_readFile()
743 @see osl_writeFile()
745 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getFilePos(
746 oslFileHandle Handle, sal_uInt64 *pPos );
748 /** Set the file size of an open file.
750 Sets the file size of an open file. The file can be truncated or enlarged by the function.
751 The position of the file pointer is not affeced by this function.
753 @param[in] Handle
754 Handle to a file received by a previous call to osl_openFile().
756 @param[in] uSize
757 New size in bytes.
759 @retval osl_File_E_None on success
760 @retval osl_File_E_INVAL the format of the parameters was not valid
761 @retval osl_File_E_OVERFLOW the resulting file offset would be a value
762 which cannot be represented correctly for regular files
764 @see osl_openFile()
765 @see osl_setFilePos()
766 @see osl_getFileStatus()
767 @see osl_getFileSize()
769 SAL_DLLPUBLIC oslFileError SAL_CALL osl_setFileSize(
770 oslFileHandle Handle, sal_uInt64 uSize );
772 /** Get the file size of an open file.
774 Gets the file size of an open file.
775 The position of the file pointer is not affeced by this function.
777 @param[in] Handle
778 Handle to a file received by a previous call to osl_openFile().
780 @param[out] pSize
781 Current size in bytes.
783 @retval osl_File_E_None on success
784 @retval osl_File_E_INVAL the format of the parameters was not valid
785 @retval osl_File_E_OVERFLOW the resulting file offset would be a value
786 which cannot be represented correctly for regular files
788 @see osl_openFile()
789 @see osl_setFilePos()
790 @see osl_getFileStatus()
792 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getFileSize(
793 oslFileHandle Handle, sal_uInt64 *pSize );
795 /** Indicate that the file can be accessed randomly (i.e. there is no sequential
796 reading). Basically it means that the first byte of every page in the
797 file-mapping will be read.
799 @since UDK 3.2.10
801 #define osl_File_MapFlag_RandomAccess ((sal_uInt32)(0x1))
803 /** Map flag denoting that the mapped address space will be accessed by the
804 process soon (and it is advantageous for the operating system to already
805 start paging in the data).
807 @attention As this assumes that madvise() with the WILLREAD flag is
808 asynchronous (which is I'm afraid an incorrect assumption), Linux systems
809 will ignore this flag.
811 @since UDK 3.2.12
813 #define osl_File_MapFlag_WillNeed ((sal_uInt32)(0x2))
815 /** Map a shared file into memory.
817 Files can be mapped into memory to allow multiple processes to use
818 this memory-mapped file to share data.
820 On Android, if the Handle refers to a file that is actually inside
821 the app package (.apk zip archive), no new mapping is created,
822 just a pointer to the file inside the already mapped .apk is
823 returned.
825 @param[in] Handle Handle of the file to be mapped.
826 @param[in,out] ppAddr Memory address of the mapped file
827 @param[in] uLength Amount to map of the file from the offset
828 @param[in] uOffset Offset into the file to map
829 @param[in] uFlags osl_File_MapFlag_RandomAccess or
830 osl_File_MapFlag_WillNeed
832 @retval osl_File_E_None on success
833 @retval osl_File_E_INVAL invalid file handle, on Unix systems also
834 can mean that the address, length of the file or the
835 file offset are too large or not aligned on a page
836 boundary; on Linux can also mean after Linux 2.6.12
837 that the length was set to 0 (illogical).
838 @retval osl_File_E_OVERFLOW requested mapping size too large,
839 or the file offset was too large
840 @retval osl_File_E_ACCES file descriptor to non-regular file, or
841 file descriptor not open for reading, or the file
842 descriptor is not open in read/write mode
843 @retval osl_File_E_AGAIN file has been locked, or too much memory
844 has been locked
845 @retval osl_File_E_NODEV underlying filesystem of specified file
846 does not support memory mapping
847 @retval osl_File_E_TXTBSY on Linux means that writing to the mapped
848 file is denied, but the file descriptor points to a file
849 open for writing
850 @retval osl_File_E_NOMEM process's maximum number of mappings have
851 been exceeded
853 @since UDK 3.2.10
855 SAL_DLLPUBLIC oslFileError SAL_CALL osl_mapFile (
856 oslFileHandle Handle,
857 void** ppAddr,
858 sal_uInt64 uLength,
859 sal_uInt64 uOffset,
860 sal_uInt32 uFlags
864 #ifndef ANDROID
866 /** Unmap a shared file from memory.
868 This function just won't work on Android in general where for
869 (uncompressed) files inside the .apk, per SDK conventions in the
870 /assets folder, osl_mapFile() returns a pointer to the file inside
871 the already by LibreOffice Android-specific bootstrapping code
872 mmapped .apk archive. We can't go and randomly munmap part of the
873 .apk archive. So this function is not present on Android.
875 @since UDK 3.2.10
877 SAL_DLLPUBLIC oslFileError SAL_CALL osl_unmapFile (
878 void* pAddr,
879 sal_uInt64 uLength
882 #endif
884 /** Unmap a file segment from memory.
886 Like osl_unmapFile(), but takes also the oslFileHandle argument
887 passed to osl_mapFile() when creating this mapping.
889 On Android, for files below /assets, i.e. located inside the app
890 archive (.apk), this won't actually unmap anything; all the .apk
891 stays mapped.
893 @since UDK 3.6
895 SAL_DLLPUBLIC oslFileError SAL_CALL osl_unmapMappedFile (
896 oslFileHandle Handle,
897 void* pAddr,
898 sal_uInt64 uLength
901 /** Read a number of bytes from a file.
903 Reads a number of bytes from a file. The internal file pointer is
904 increased by the number of bytes read.
906 @param[in] Handle
907 Handle to a file received by a previous call to osl_openFile().
909 @param[out] pBuffer
910 Points to a buffer which receives data. The buffer must be large enough
911 to hold uBytesRequested bytes.
913 @param[in] uBytesRequested
914 Number of bytes which should be retrieved.
916 @param[out] pBytesRead
917 On success the number of bytes which have actually been retrieved.
919 @retval osl_File_E_None on success
920 @retval osl_File_E_INVAL the format of the parameters was not valid
921 @retval osl_File_E_INTR function call was interrupted
922 @retval osl_File_E_IO on I/O errors
923 @retval osl_File_E_ISDIR is a directory
924 @retval osl_File_E_BADF bad file
925 @retval osl_File_E_FAULT bad address
926 @retval osl_File_E_AGAIN operation would block
927 @retval osl_File_E_NOLINK link has been severed
929 @see osl_openFile()
930 @see osl_writeFile()
931 @see osl_readLine()
932 @see osl_setFilePos()
934 SAL_DLLPUBLIC oslFileError SAL_CALL osl_readFile(
935 oslFileHandle Handle, void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 *pBytesRead );
937 /** Test if the end of a file is reached.
939 @param[in] Handle
940 Handle to a file received by a previous call to osl_openFile().
942 @param[out] pIsEOF
943 Points to a variable that receives the end-of-file status.
945 @retval osl_File_E_None on success
946 @retval osl_File_E_INVAL the format of the parameters was not valid
947 @retval osl_File_E_INTR function call was interrupted
948 @retval osl_File_E_IO on I/O errors
949 @retval osl_File_E_ISDIR is a directory
950 @retval osl_File_E_BADF bad file
951 @retval osl_File_E_FAULT bad address
952 @retval osl_File_E_AGAIN operation would block
953 @retval osl_File_E_NOLINK link has been severed
955 @see osl_openFile()
956 @see osl_readFile()
957 @see osl_readLine()
958 @see osl_setFilePos()
960 SAL_DLLPUBLIC oslFileError SAL_CALL osl_isEndOfFile(
961 oslFileHandle Handle, sal_Bool *pIsEOF );
963 /** Write a number of bytes to a file.
965 Writes a number of bytes to a file.
966 The internal file pointer is increased by the number of bytes read.
968 @param[in] Handle
969 Handle to a file received by a previous call to osl_openFile().
971 @param[in] pBuffer
972 Points to a buffer which contains the data.
974 @param[in] uBytesToWrite
975 Number of bytes which should be written.
977 @param[out] pBytesWritten
978 On success the number of bytes which have actually been written.
980 @retval osl_File_E_None on success
981 @retval osl_File_E_INVAL the format of the parameters was not valid
982 @retval osl_File_E_FBIG file too large
983 @retval osl_File_E_DQUOT quota exceeded
984 @retval osl_File_E_AGAIN operation would block
985 @retval osl_File_E_BADF bad file
986 @retval osl_File_E_FAULT bad address
987 @retval osl_File_E_INTR function call was interrupted
988 @retval osl_File_E_IO on I/O errors
989 @retval osl_File_E_NOLCK no record locks available
990 @retval osl_File_E_NOLINK link has been severed
991 @retval osl_File_E_NOSPC no space left on device
992 @retval osl_File_E_NXIO no such device or address
994 @see osl_openFile()
995 @see osl_readFile()
996 @see osl_setFilePos()
998 SAL_DLLPUBLIC oslFileError SAL_CALL osl_writeFile(
999 oslFileHandle Handle, const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 *pBytesWritten );
1001 /** Read a number of bytes from a specified offset in a file.
1003 The current position of the internal file pointer may or may not be changed.
1005 @param[in] Handle
1006 Handle to a file received by a previous call to osl_openFile().
1008 @param[in] uOffset
1009 Offset position from start of file where read starts
1011 @param[out] pBuffer
1012 Points to a buffer which receives data. The buffer must be large enough
1013 to hold uBytesRequested bytes.
1015 @param[in] uBytesRequested
1016 Number of bytes which should be retrieved.
1018 @param[out] pBytesRead
1019 On success the number of bytes which have actually been retrieved.
1021 @retval osl_File_E_None on success
1022 @retval osl_File_E_INVAL the format of the parameters was not valid
1023 @retval osl_File_E_INTR function call was interrupted
1024 @retval osl_File_E_IO on I/O errors
1025 @retval osl_File_E_ISDIR is a directory
1026 @retval osl_File_E_BADF bad file
1027 @retval osl_File_E_FAULT bad address
1028 @retval osl_File_E_AGAIN operation would block
1029 @retval osl_File_E_NOLINK link has been severed
1030 @since UDK 3.2.10
1032 SAL_DLLPUBLIC oslFileError SAL_CALL osl_readFileAt(
1033 oslFileHandle Handle,
1034 sal_uInt64 uOffset,
1035 void* pBuffer,
1036 sal_uInt64 uBytesRequested,
1037 sal_uInt64* pBytesRead
1040 /** Write a number of bytes to a specified offset in a file.
1042 The current position of the internal file pointer may or may not be changed.
1044 @param[in] Handle
1045 Handle to a file received by a previous call to osl_openFile().
1047 @param[in] uOffset
1048 Position of file to write into.
1050 @param[in] pBuffer
1051 Points to a buffer which contains the data.
1053 @param[in] uBytesToWrite
1054 Number of bytes which should be written.
1056 @param[out] pBytesWritten
1057 On success the number of bytes which have actually been written.
1059 @retval osl_File_E_None on success
1060 @retval osl_File_E_INVAL the format of the parameters was not valid
1061 @retval osl_File_E_FBIG file too large
1062 @retval osl_File_E_DQUOT quota exceeded
1063 @retval osl_File_E_AGAIN operation would block
1064 @retval osl_File_E_BADF bad file
1065 @retval osl_File_E_FAULT bad address
1066 @retval osl_File_E_INTR function call was interrupted
1067 @retval osl_File_E_IO on I/O errors
1068 @retval osl_File_E_NOLCK no record locks available
1069 @retval osl_File_E_NOLINK link has been severed
1070 @retval osl_File_E_NOSPC no space left on device
1071 @retval osl_File_E_NXIO no such device or address
1072 @since UDK 3.2.10
1074 SAL_DLLPUBLIC oslFileError SAL_CALL osl_writeFileAt(
1075 oslFileHandle Handle,
1076 sal_uInt64 uOffset,
1077 const void* pBuffer,
1078 sal_uInt64 uBytesToWrite,
1079 sal_uInt64* pBytesWritten
1082 /** Read a line from a file.
1084 Reads a line from a file. The new line delimiter is NOT returned!
1086 @param[in] Handle
1087 Handle to a file received by a previous call to osl_openFile().
1089 @param[in,out] ppSequence
1090 A pointer pointer to a sal_Sequence that will hold the line read on success.
1092 @retval osl_File_E_None on success
1093 @retval osl_File_E_INVAL the format of the parameters was not valid
1094 @retval osl_File_E_INTR function call was interrupted
1095 @retval osl_File_E_IO on I/O errors
1096 @retval osl_File_E_ISDIR is a directory
1097 @retval osl_File_E_BADF bad file
1098 @retval osl_File_E_FAULT bad address
1099 @retval osl_File_E_AGAIN operation would block
1100 @retval osl_File_E_NOLINK link has been severed
1102 @see osl_openFile()
1103 @see osl_readFile()
1104 @see osl_writeFile()
1105 @see osl_setFilePos()
1107 SAL_DLLPUBLIC oslFileError SAL_CALL osl_readLine(
1108 oslFileHandle Handle, sal_Sequence** ppSequence );
1110 /** Synchronize the memory representation of a file with that on the physical medium.
1112 The function ensures that all modified data and attributes of the file associated with
1113 the given file handle have been written to the physical medium.
1114 In case the hard disk has a write cache enabled, the data may not really be on
1115 permanent storage when osl_syncFile returns.
1117 @param Handle
1118 [in] Handle to a file received by a previous call to osl_openFile().
1120 @retval osl_File_E_None On success
1121 @retval osl_File_E_INVAL The value of the input parameter is invalid
1122 @retval osl_File_E_BADF The file associated with the given file handle is not open for writing
1123 @retval osl_File_E_IO An I/O error occurred
1124 @retval osl_File_E_NOSPC There is no enough space on the target device
1125 @retval osl_File_E_ROFS The file associated with the given file handle is located on a read only file system
1126 @retval osl_File_E_TIMEDOUT A remote connection timed out. This may happen when a file is on a remote location
1128 @see osl_openFile()
1129 @see osl_writeFile()
1131 SAL_DLLPUBLIC oslFileError SAL_CALL osl_syncFile( oslFileHandle Handle );
1133 /** Close an open file.
1135 @param[in] Handle
1136 Handle to a file received by a previous call to osl_openFile().
1138 @retval osl_File_E_None on success
1139 @retval osl_File_E_INVAL the format of the parameters was not valid
1140 @retval osl_File_E_BADF Bad file
1141 @retval osl_File_E_INTR function call was interrupted
1142 @retval osl_File_E_NOLINK link has been severed
1143 @retval osl_File_E_NOSPC no space left on device
1144 @retval osl_File_E_IO on I/O errors
1146 @see osl_openFile()
1148 SAL_DLLPUBLIC oslFileError SAL_CALL osl_closeFile( oslFileHandle Handle );
1150 /** Create a directory.
1152 @param[in] pustrDirectoryURL
1153 Full qualified URL of the directory to create.
1155 @retval osl_File_E_None on success
1156 @retval osl_File_E_INVAL the format of the parameters was not valid
1157 @retval osl_File_E_NOMEM not enough memory for allocating structures
1158 @retval osl_File_E_EXIST file exists
1159 @retval osl_File_E_ACCES permission denied
1160 @retval osl_File_E_NAMETOOLONG file name too long
1161 @retval osl_File_E_NOENT no such file or directory
1162 @retval osl_File_E_NOTDIR not a directory
1163 @retval osl_File_E_ROFS read-only file system
1164 @retval osl_File_E_NOSPC no space left on device
1165 @retval osl_File_E_DQUOT quota exceeded
1166 @retval osl_File_E_LOOP too many symbolic links encountered
1167 @retval osl_File_E_FAULT bad address
1168 @retval osl_FileE_IO on I/O errors
1169 @retval osl_File_E_MLINK too many links
1170 @retval osl_File_E_MULTIHOP multihop attempted
1171 @retval osl_File_E_NOLINK link has been severed
1173 @see osl_removeDirectory()
1175 SAL_DLLPUBLIC oslFileError SAL_CALL osl_createDirectory( rtl_uString* pustrDirectoryURL );
1177 /** Create a directory, passing flags.
1179 @param url
1180 File URL of the directory to create.
1182 @param flags
1183 A combination of the same osl_File_OpenFlag_*s used by osl_openFile,
1184 except that osl_File_OpenFlag_Create is implied and ignored. Support for
1185 the various flags can differ across operating systems.
1187 @see osl_createDirectory()
1189 @since LibreOffice 4.3
1191 SAL_DLLPUBLIC oslFileError SAL_CALL osl_createDirectoryWithFlags(
1192 rtl_uString * url, sal_uInt32 flags);
1194 /** Remove an empty directory.
1196 @param[in] pustrDirectoryURL
1197 Full qualified URL of the directory.
1199 @retval osl_File_E_None on success
1200 @retval osl_File_E_INVAL the format of the parameters was not valid
1201 @retval osl_File_E_NOMEM not enough memory for allocating structures
1202 @retval osl_File_E_PERM operation not permitted
1203 @retval osl_File_E_ACCES permission denied
1204 @retval osl_File_E_NOENT no such file or directory
1205 @retval osl_File_E_NOTDIR not a directory
1206 @retval osl_File_E_NOTEMPTY directory not empty
1207 @retval osl_File_E_FAULT bad address
1208 @retval osl_File_E_NAMETOOLONG file name too long
1209 @retval osl_File_E_BUSY device or resource busy
1210 @retval osl_File_E_ROFS read-only file system
1211 @retval osl_File_E_LOOP too many symbolic links encountered
1212 @retval osl_File_E_EXIST file exists
1213 @retval osl_File_E_IO on I/O errors
1214 @retval osl_File_E_MULTIHOP multihop attempted
1215 @retval osl_File_E_NOLINK link has been severed
1217 @see osl_createDirectory()
1219 SAL_DLLPUBLIC oslFileError SAL_CALL osl_removeDirectory( rtl_uString* pustrDirectoryURL );
1221 /** Function pointer representing a function that will be called by osl_createDirectoryPath
1222 if a directory has been created.
1224 To avoid unpredictable results the callee must not access the directory whose
1225 creation is just notified.
1227 @param pData
1228 [in] User specified data given in osl_createDirectoryPath.
1230 @param aDirectoryUrl
1231 [in] The absolute file URL of the directory that was just created by
1232 osl_createDirectoryPath.
1234 @see osl_createDirectoryPath
1236 typedef void (SAL_CALL *oslDirectoryCreationCallbackFunc)(void* pData, rtl_uString* aDirectoryUrl);
1238 /** Create a directory path.
1240 The osl_createDirectoryPath function creates a specified directory path.
1241 All nonexisting sub directories will be created.
1243 @attention PLEASE NOTE You cannot rely on getting the error code
1244 osl_File_E_EXIST for existing directories. Programming against this error
1245 code is in general a strong indication of a wrong usage of osl_createDirectoryPath.
1247 @param aDirectoryUrl
1248 [in] The absolute file URL of the directory path to create.
1249 A relative file URL will not be accepted.
1251 @param aDirectoryCreationCallbackFunc
1252 [in] Pointer to a function that will be called synchronously
1253 for each sub directory that was created. The value of this
1254 parameter may be NULL, in this case notifications will not be
1255 sent.
1257 @param pData
1258 [in] User specified data to be passed to the directory creation
1259 callback function. The value of this parameter may be arbitrary
1260 and will not be interpreted by osl_createDirectoryPath.
1262 @retval osl_File_E_None On success
1263 @retval osl_File_E_INVAL The format of the parameters was not valid
1264 @retval osl_File_E_ACCES Permission denied
1265 @retval osl_File_E_EXIST The final node of the specified directory path already exist
1266 @retval osl_File_E_NAMETOOLONG The name of the specified directory path exceeds the maximum allowed length
1267 @retval osl_File_E_NOTDIR A component of the specified directory path already exist as file in any part of the directory path
1268 @retval osl_File_E_ROFS Read-only file system
1269 @retval osl_File_E_NOSPC No space left on device
1270 @retval osl_File_E_DQUOT Quota exceeded
1271 @retval osl_File_E_FAULT Bad address
1272 @retval osl_File_E_IO I/O error
1273 @retval osl_File_E_LOOP Too many symbolic links encountered
1274 @retval osl_File_E_NOLINK Link has been severed
1275 @retval osl_File_E_invalidError An unknown error occurred
1277 @see oslDirectoryCreationFunc
1278 @see oslFileError
1279 @see osl_createDirectory
1281 SAL_DLLPUBLIC oslFileError SAL_CALL osl_createDirectoryPath(
1282 rtl_uString* aDirectoryUrl,
1283 oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
1284 void* pData);
1286 /** Remove a regular file.
1288 @param[in] pustrFileURL
1289 Full qualified URL of the file to remove.
1291 @retval osl_File_E_None on success
1292 @retval osl_File_E_INVAL the format of the parameters was not valid
1293 @retval osl_File_E_NOMEM not enough memory for allocating structures
1294 @retval osl_File_E_ACCES permission denied
1295 @retval osl_File_E_PERM operation not permitted
1296 @retval osl_File_E_NAMETOOLONG file name too long
1297 @retval osl_File_E_NOENT no such file or directory
1298 @retval osl_File_E_ISDIR is a directory
1299 @retval osl_File_E_ROFS read-only file system
1300 @retval osl_File_E_FAULT bad address
1301 @retval osl_File_E_LOOP too many symbolic links encountered
1302 @retval osl_File_E_IO on I/O errors
1303 @retval osl_File_E_BUSY device or resource busy
1304 @retval osl_File_E_INTR function call was interrupted
1305 @retval osl_File_E_MULTIHOP multihop attempted
1306 @retval osl_File_E_NOLINK link has been severed
1307 @retval osl_File_E_TXTBSY text file busy
1309 @see osl_openFile()
1311 SAL_DLLPUBLIC oslFileError SAL_CALL osl_removeFile(
1312 rtl_uString* pustrFileURL );
1314 /** Copy a file to a new destination.
1316 Copies a file to a new destination. Copies only files not directories.
1317 No assumptions should be made about preserving attributes or file time.
1319 @param[in] pustrSourceFileURL
1320 Full qualified URL of the source file.
1322 @param[in] pustrDestFileURL
1323 Full qualified URL of the destination file. A directory is NOT a valid destination file!
1325 @retval osl_File_E_None on success
1326 @retval osl_File_E_INVAL the format of the parameters was not valid
1327 @retval osl_File_E_NOMEM not enough memory for allocating structures
1328 @retval osl_File_E_ACCES permission denied
1329 @retval osl_File_E_PERM operation not permitted
1330 @retval osl_File_E_NAMETOOLONG file name too long
1331 @retval osl_File_E_NOENT no such file or directory
1332 @retval osl_File_E_ISDIR is a directory
1333 @retval osl_File_E_ROFS read-only file system
1334 @retval osl_File_E_BUSY if the implementation internally requires resources that are
1335 (temporarily) unavailable (added with LibreOffice 4.4)
1337 @see osl_moveFile()
1338 @see osl_removeFile()
1340 SAL_DLLPUBLIC oslFileError SAL_CALL osl_copyFile(
1341 rtl_uString* pustrSourceFileURL, rtl_uString *pustrDestFileURL );
1343 /** Move a file or directory to a new destination or renames it.
1345 Moves a file or directory to a new destination or renames it.
1346 File time and attributes are preserved.
1348 @param[in] pustrSourceFileURL
1349 Full qualified URL of the source file.
1351 @param[in] pustrDestFileURL
1352 Full qualified URL of the destination file. An existing directory is NOT a valid destination !
1354 @retval osl_File_E_None on success
1355 @retval osl_File_E_INVAL the format of the parameters was not valid
1356 @retval osl_File_E_NOMEM not enough memory for allocating structures
1357 @retval osl_File_E_ACCES permission denied
1358 @retval osl_File_E_PERM operation not permitted
1359 @retval osl_File_E_NAMETOOLONG file name too long
1360 @retval osl_File_E_NOENT no such file or directory
1361 @retval osl_File_E_ROFS read-only file system
1362 @retval osl_File_E_BUSY if the implementation internally requires resources that are
1363 (temporarily) unavailable (added with LibreOffice 4.4)
1365 @see osl_copyFile()
1367 SAL_DLLPUBLIC oslFileError SAL_CALL osl_moveFile(
1368 rtl_uString* pustrSourceFileURL, rtl_uString *pustrDestFileURL );
1370 /** Determine a valid unused canonical name for a requested name.
1372 Determines a valid unused canonical name for a requested name.
1373 Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
1374 If a file or directory with the requested name already exists a new name is generated following
1375 the common rules on the actual Operating System and File System.
1377 @param[in] pustrRequestedURL
1378 Requested name of a file or directory.
1380 @param[out] ppustrValidURL
1381 On success receives a name which is unused and valid on the actual Operating System and
1382 File System.
1384 @retval osl_File_E_None on success
1385 @retval osl_File_E_INVAL the format of the parameters was not valid
1387 @see osl_getFileStatus()
1389 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getCanonicalName(
1390 rtl_uString *pustrRequestedURL, rtl_uString **ppustrValidURL);
1392 /** Convert a path relative to a given directory into an full qualified file URL.
1394 Convert a path relative to a given directory into an full qualified file URL.
1395 The function resolves symbolic links if possible and path ellipses, so on success
1396 the resulting absolute path is fully resolved.
1398 @param[in] pustrBaseDirectoryURL
1399 Base directory URL to which the relative path is related to.
1401 @param[in] pustrRelativeFileURL
1402 A URL of a file or directory relative to the directory path specified by pustrBaseDirectoryURL
1403 or an absolute path.
1404 If pustrRelativeFileURL denotes an absolute path pustrBaseDirectoryURL will be ignored.
1406 @param[out] ppustrAbsoluteFileURL
1407 On success it receives the full qualified absolute file URL.
1409 @retval osl_File_E_None on success
1410 @retval osl_File_E_INVAL the format of the parameters was not valid
1411 @retval osl_File_E_NOMEM not enough memory for allocating structures
1412 @retval osl_File_E_NOTDIR not a directory
1413 @retval osl_File_E_ACCES permission denied
1414 @retval osl_File_E_NOENT no such file or directory
1415 @retval osl_File_E_NAMETOOLONG file name too long
1416 @retval osl_File_E_OVERFLOW value too large for defined data type
1417 @retval osl_File_E_FAULT bad address
1418 @retval osl_File_E_INTR function call was interrupted
1419 @retval osl_File_E_LOOP too many symbolic links encountered
1420 @retval osl_File_E_MULTIHOP multihop attempted
1421 @retval osl_File_E_NOLINK link has been severed
1423 @see osl_getFileStatus()
1425 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getAbsoluteFileURL(
1426 rtl_uString* pustrBaseDirectoryURL,
1427 rtl_uString *pustrRelativeFileURL,
1428 rtl_uString **ppustrAbsoluteFileURL );
1430 /** Convert a system dependent path into a file URL.
1432 @param[in] pustrSystemPath
1433 A System dependent path of a file or directory.
1435 @param[out] ppustrFileURL
1436 On success it receives the file URL.
1438 @retval osl_File_E_None on success
1439 @retval osl_File_E_INVAL the format of the parameters was not valid
1441 @see osl_getSystemPathFromFileURL()
1443 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getFileURLFromSystemPath(
1444 rtl_uString *pustrSystemPath, rtl_uString **ppustrFileURL);
1446 /** Search a full qualified system path or a file URL.
1448 @param[in] pustrFileName
1449 A system dependent path, a file URL, a file or relative directory.
1451 @param[in] pustrSearchPath
1452 @parblock
1453 A list of system paths, in which a given file has to be searched. The Notation of a path
1454 list is system dependent, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
1455 These paths are only for the search of a file or a relative path, otherwise it will be ignored.
1456 If pustrSearchPath is NULL or while using the search path the search failed, the function
1457 searches for a matching file in all system directories and in the directories listed in the PATH
1458 environment variable.
1460 The value of an environment variable should be used (e.g.
1461 LD_LIBRARY_PATH) if the caller is not aware of the Operating System and so doesn't know which
1462 path list delimiter to use.
1463 @endparblock
1465 @param[out] ppustrFileURL
1466 On success it receives the full qualified file URL.
1468 @retval osl_File_E_None on success
1469 @retval osl_File_E_INVAL the format of the parameters was not valid
1470 @retval osl_File_E_NOTDIR not a directory
1471 @retval osl_File_E_NOENT no such file or directory not found
1473 @see osl_getFileURLFromSystemPath()
1474 @see osl_getSystemPathFromFileURL()
1476 SAL_DLLPUBLIC oslFileError SAL_CALL osl_searchFileURL(
1477 rtl_uString *pustrFileName, rtl_uString *pustrSearchPath, rtl_uString **ppustrFileURL );
1479 /** Convert a file URL into a system dependent path.
1481 @param[in] pustrFileURL
1482 A File URL.
1484 @param[out] ppustrSystemPath
1485 On success it receives the system path.
1487 @retval osl_File_E_None on success
1488 @retval osl_File_E_INVAL the format of the parameters was not valid
1490 @see osl_getFileURLFromSystemPath()
1492 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getSystemPathFromFileURL(
1493 rtl_uString *pustrFileURL, rtl_uString **ppustrSystemPath);
1495 /** Function pointer representing the function called back from osl_abbreviateSystemPath
1497 @param[in] ustrText
1498 Text to calculate the width for
1500 @return
1501 The width of the text specified by ustrText, e.g. it can return the width in pixel
1502 or the width in character count.
1504 @see osl_abbreviateSystemPath()
1506 typedef sal_uInt32 (SAL_CALL *oslCalcTextWidthFunc)( rtl_uString *ustrText );
1508 /** Abbreviate a system notation path.
1510 @param[in] ustrSystemPath
1511 The full system path to abbreviate
1513 @param[out] pustrCompacted
1514 Receives the compacted system path on output
1516 @param[in] pCalcWidth
1517 Function ptr that calculates the width of a string. Can be zero.
1519 @param[in] uMaxWidth
1520 Maximum width allowed that is returned from pCalcWidth.
1521 If pCalcWidth is zero the character count is assumed as width.
1523 @retval osl_File_E_None on success
1525 @see oslCalcTextWidthFunc
1527 SAL_DLLPUBLIC oslFileError SAL_CALL osl_abbreviateSystemPath(
1528 rtl_uString *ustrSystemPath,
1529 rtl_uString **pustrCompacted,
1530 sal_uInt32 uMaxWidth,
1531 oslCalcTextWidthFunc pCalcWidth );
1533 /** Set file attributes.
1535 @param[in] pustrFileURL
1536 The full qualified file URL.
1538 @param[in] uAttributes
1539 Attributes of the file to be set.
1541 @retval osl_File_E_None on success
1542 @retval osl_File_E_INVAL the format of the parameters was not valid
1544 @see osl_getFileStatus()
1546 SAL_DLLPUBLIC oslFileError SAL_CALL osl_setFileAttributes(
1547 rtl_uString *pustrFileURL, sal_uInt64 uAttributes );
1549 /** Set the file time.
1551 @param[in] pustrFileURL
1552 The full qualified URL of the file.
1554 @param[in] aCreationTime
1555 Creation time of the given file.
1557 @param[in] aLastAccessTime
1558 Time of the last access of the given file.
1560 @param[in] aLastWriteTime
1561 Time of the last modifying of the given file.
1563 @retval osl_File_E_None on success
1564 @retval osl_File_E_INVAL the format of the parameters was not valid
1565 @retval osl_File_E_NOENT no such file or directory not found
1567 @see osl_getFileStatus()
1569 SAL_DLLPUBLIC oslFileError SAL_CALL osl_setFileTime(
1570 rtl_uString *pustrFileURL,
1571 const TimeValue *aCreationTime,
1572 const TimeValue *aLastAccessTime,
1573 const TimeValue *aLastWriteTime);
1575 /** Retrieves the file URL of the system's temporary directory path
1577 @param[out] pustrTempDirURL
1578 On success receives the URL of system's temporary directory path.
1580 @retval osl_File_E_None on success
1581 @retval osl_File_E_NOENT no such file or directory not found
1583 SAL_DLLPUBLIC oslFileError SAL_CALL osl_getTempDirURL(
1584 rtl_uString **pustrTempDirURL );
1586 /** Creates a temporary file in the directory provided by the caller or the
1587 directory returned by osl_getTempDirURL.
1589 Creates a temporary file in the directory provided by the caller or the
1590 directory returned by osl_getTempDirURL.
1591 Under UNIX Operating Systems the file will be created with read and write
1592 access for the user exclusively.
1593 If the caller requests only a handle to the open file but not the name of
1594 it, the file will be automatically removed on close else the caller is
1595 responsible for removing the file on success.
1597 Description of the different pHandle, ppustrTempFileURL parameter combinations.
1598 pHandle is 0 and ppustrTempDirURL is 0 - this combination is invalid
1599 pHandle is not 0 and ppustrTempDirURL is 0 - a handle to the open file
1600 will be returned on success and the file will be automatically removed on close.
1601 pHandle is 0 and ppustrTempDirURL is not 0 - the name of the file will be returned,
1602 the caller is responsible for opening, closing and removing the file.
1603 pHandle is not 0 and ppustrTempDirURL is not 0 - a handle to the open file as well as
1604 the file name will be returned, the caller is responsible for closing and removing
1605 the file.
1607 @param[in] pustrDirectoryURL
1608 Specifies the full qualified URL where the temporary file should be created.
1609 If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
1611 @param[out] pHandle
1612 On success receives a handle to the open file. If pHandle is 0 the file will
1613 be closed on return, in this case ppustrTempFileURL must not be 0.
1615 @param[out] ppustrTempFileURL
1616 On success receives the full qualified URL of the temporary file.
1617 If ppustrTempFileURL is 0 the file will be automatically removed on close,
1618 in this case pHandle must not be 0.
1619 If ppustrTempFileURL is not 0 the caller receives the name of the created
1620 file and is responsible for removing the file, in this case
1621 *ppustrTempFileURL must be 0 or must point to a valid rtl_uString.
1623 @retval osl_File_E_None on success
1624 @retval osl_File_E_INVAL the format of the parameter is invalid
1625 @retval osl_File_E_NOMEM not enough memory for allocating structures
1626 @retval osl_File_E_ACCES Permission denied
1627 @retval osl_File_E_NOENT No such file or directory
1628 @retval osl_File_E_NOTDIR Not a directory
1629 @retval osl_File_E_ROFS Read-only file system
1630 @retval osl_File_E_NOSPC No space left on device
1631 @retval osl_File_E_DQUOT Quota exceeded
1633 @see osl_getTempDirURL()
1635 SAL_DLLPUBLIC oslFileError SAL_CALL osl_createTempFile(
1636 rtl_uString* pustrDirectoryURL,
1637 oslFileHandle* pHandle,
1638 rtl_uString** ppustrTempFileURL);
1640 /** Move a file to a new destination or rename it, taking old file's identity (if exists).
1642 Moves or renames a file, replacing an existing file if exist. If the old file existed,
1643 moved file's metadata, e.g. creation time (on FSes which keep files' creation time) or
1644 ACLs, are set to old one's (to keep the old file's identity) - currently this is only
1645 implemented fully on Windows; on other platforms, this is mostly equivalent to osl_moveFile.
1647 @param[in] pustrSourceFileURL
1648 Full qualified URL of the source file.
1650 @param[in] pustrDestFileURL
1651 Full qualified URL of the destination file.
1653 @retval osl_File_E_None on success
1654 @retval osl_File_E_INVAL the format of the parameters was not valid
1655 @retval osl_File_E_NOMEM not enough memory for allocating structures
1656 @retval osl_File_E_ACCES permission denied
1657 @retval osl_File_E_PERM operation not permitted
1658 @retval osl_File_E_NAMETOOLONG file name too long
1659 @retval osl_File_E_NOENT no such file
1660 @retval osl_File_E_ROFS read-only file system
1661 @retval osl_File_E_BUSY if the implementation internally requires resources that are
1662 (temporarily) unavailable
1664 @see osl_moveFile()
1666 @since LibreOffice 6.2
1668 SAL_DLLPUBLIC oslFileError SAL_CALL osl_replaceFile(rtl_uString* pustrSourceFileURL,
1669 rtl_uString* pustrDestFileURL);
1671 #ifdef __cplusplus
1673 #endif
1675 #endif // INCLUDED_OSL_FILE_H
1677 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */