VirtualBox

source: vbox/trunk/include/iprt/file.h@ 22516

Last change on this file since 22516 was 22516, checked in by vboxsync, 15 years ago

IPRT: Added RTFileExists

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 46.7 KB
Line 
1/** @file
2 * IPRT - File I/O.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___iprt_file_h
31#define ___iprt_file_h
32
33#include <iprt/cdefs.h>
34#include <iprt/types.h>
35#ifdef IN_RING3
36# include <iprt/fs.h>
37#endif
38
39RT_C_DECLS_BEGIN
40
41/** @defgroup grp_rt_fileio RTFile - File I/O
42 * @ingroup grp_rt
43 * @{
44 */
45
46/** Platform specific text line break.
47 * @deprecated Use text I/O streams and '\\n'. See iprt/stream.h. */
48#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
49# define RTFILE_LINEFEED "\r\n"
50#else
51# define RTFILE_LINEFEED "\n"
52#endif
53
54
55#ifdef IN_RING3
56
57/**
58 * Checks if the specified file name exists and is a regular file.
59 *
60 * Symbolic links will be resolved.
61 *
62 * @returns true if it's a regular file, false if it isn't.
63 * @param pszPath The path to the file.
64 *
65 * @sa RTDirExists, RTPathExists, RTSymlinkExists.
66 */
67RTDECL(bool) RTFileExists(const char *pszPath);
68
69
70/** @name Open flags
71 * @{ */
72/** Open the file with read access. */
73#define RTFILE_O_READ 0x00000001
74/** Open the file with write access. */
75#define RTFILE_O_WRITE 0x00000002
76/** Open the file with read & write access. */
77#define RTFILE_O_READWRITE 0x00000003
78/** The file access mask.
79 * @remarks The value 0 is invalid. */
80#define RTFILE_O_ACCESS_MASK 0x00000003
81
82/** Open file in APPEND mode, so all writes to the file handle will
83 * append data at the end of the file.
84 * @remarks It is ignored if write access is not requested, that is
85 * RTFILE_O_WRITE is not set. */
86#define RTFILE_O_APPEND 0x00000004
87 /* 0x00000008 is unused atm. */
88
89/** Sharing mode: deny none (the default mode). */
90#define RTFILE_O_DENY_NONE 0x00000000
91/** Sharing mode: deny read. */
92#define RTFILE_O_DENY_READ 0x00000010
93/** Sharing mode: deny write. */
94#define RTFILE_O_DENY_WRITE 0x00000020
95/** Sharing mode: deny read and write. */
96#define RTFILE_O_DENY_READWRITE 0x00000030
97/** Sharing mode: deny all. */
98#define RTFILE_O_DENY_ALL RTFILE_O_DENY_READWRITE
99/** Sharing mode: do NOT deny delete (NT).
100 * @remarks This might not be implemented on all platforms, and will be
101 * defaulted & ignored on those.
102 */
103#define RTFILE_O_DENY_NOT_DELETE 0x00000040
104/** Sharing mode mask. */
105#define RTFILE_O_DENY_MASK 0x00000070
106
107/** Action: Open an existing file (the default action). */
108#define RTFILE_O_OPEN 0x00000000
109/** Action: Create a new file or open an existing one. */
110#define RTFILE_O_OPEN_CREATE 0x00000100
111/** Action: Create a new a file. */
112#define RTFILE_O_CREATE 0x00000200
113/** Action: Create a new file or replace an existing one. */
114#define RTFILE_O_CREATE_REPLACE 0x00000300
115/** Action mask. */
116#define RTFILE_O_ACTION_MASK 0x00000300
117
118 /*0x00000400
119 and 0x00000800 are unused atm. */
120/** Turns off indexing of files on Windows hosts, *CREATE* only.
121 * @remarks Window only. */
122#define RTFILE_O_NOT_CONTENT_INDEXED 0x00000800
123/** Truncate the file.
124 * @remarks This will not truncate files opened for read-only.
125 * @remarks The trunction doesn't have to be atomically, so anyone else opening
126 * the file may be racing us. The caller is responsible for not causing
127 * this race. */
128#define RTFILE_O_TRUNCATE 0x00001000
129/** Make the handle inheritable on RTProcessCreate(/exec). */
130#define RTFILE_O_INHERIT 0x00002000
131/** Open file in non-blocking mode - non-portable.
132 * @remarks This flag may not be supported on all platforms, in which case it's
133 * considered an invalid parameter. */
134#define RTFILE_O_NON_BLOCK 0x00004000
135/** Write through directly to disk. Workaround to avoid iSCSI
136 * initiator deadlocks on Windows hosts.
137 * @remarks This might not be implemented on all platforms, and will be ignored
138 * on those. */
139#define RTFILE_O_WRITE_THROUGH 0x00008000
140
141/** Attribute access: Attributes can be read if the file is being opened with
142 * read access, and can be written with write access. */
143#define RTFILE_O_ACCESS_ATTR_DEFAULT 0x00000000
144/** Attribute access: Attributes can be read.
145 * @remarks Windows only. */
146#define RTFILE_O_ACCESS_ATTR_READ 0x00010000
147/** Attribute access: Attributes can be written.
148 * @remarks Windows only. */
149#define RTFILE_O_ACCESS_ATTR_WRITE 0x00020000
150/** Attribute access: Attributes can be both read & written.
151 * @remarks Windows only. */
152#define RTFILE_O_ACCESS_ATTR_READWRITE 0x00030000
153/** Attribute access: The file attributes access mask.
154 * @remarks Windows only. */
155#define RTFILE_O_ACCESS_ATTR_MASK 0x00030000
156
157/** Open file for async I/O
158 * @remarks This flag may not be needed on all platforms, and will be ignored on
159 * those. */
160#define RTFILE_O_ASYNC_IO 0x00040000
161
162/** Disables caching.
163 *
164 * Useful when using very big files which might bring the host I/O scheduler to
165 * its knees during high I/O load.
166 *
167 * @remarks This flag might impose restrictions
168 * on the buffer alignment, start offset and/or transfer size.
169 *
170 * On Linux the buffer needs to be aligned to the 512 sector
171 * boundary.
172 *
173 * On Windows the FILE_FLAG_NO_BUFFERING is used (see
174 * http://msdn.microsoft.com/en-us/library/cc644950(VS.85).aspx ).
175 * The buffer address, the transfer size and offset needs to be
176 * aligned to the sector size of the volume.
177 *
178 * @remarks This might not be implemented on all platforms,
179 * and will be ignored on those.
180 */
181#define RTFILE_O_NO_CACHE 0x00080000
182
183/** Unix file mode mask for use when creating files. */
184#define RTFILE_O_CREATE_MODE_MASK 0x1ff00000
185/** The number of bits to shift to get the file mode mask.
186 * To extract it: (fFlags & RTFILE_O_CREATE_MODE_MASK) >> RTFILE_O_CREATE_MODE_SHIFT.
187 */
188#define RTFILE_O_CREATE_MODE_SHIFT 20
189
190 /*0x20000000,
191 0x40000000
192 and 0x80000000 are unused atm. */
193
194/** Mask of all valid flags.
195 * @remark This doesn't validate the access mode properly.
196 */
197#define RTFILE_O_VALID_MASK 0x1ffFFB77
198
199/** @} */
200
201
202/**
203 * Force the use of open flags for all files opened after the setting is
204 * changed. The caller is responsible for not causing races with RTFileOpen().
205 *
206 * @returns iprt status code.
207 * @param fOpenForAccess Access mode to which the set/mask settings apply.
208 * @param fSet Open flags to be forced set.
209 * @param fMask Open flags to be masked out.
210 */
211RTR3DECL(int) RTFileSetForceFlags(unsigned fOpenForAccess, unsigned fSet, unsigned fMask);
212
213/**
214 * Open a file.
215 *
216 * @returns iprt status code.
217 * @param pFile Where to store the handle to the opened file.
218 * @param pszFilename Path to the file which is to be opened. (UTF-8)
219 * @param fOpen Open flags, i.e a combination of the RTFILE_O_* defines.
220 */
221RTR3DECL(int) RTFileOpen(PRTFILE pFile, const char *pszFilename, unsigned fOpen);
222
223/**
224 * Close a file opened by RTFileOpen().
225 *
226 * @returns iprt status code.
227 * @param File The file handle to close.
228 */
229RTR3DECL(int) RTFileClose(RTFILE File);
230
231/**
232 * Creates an IPRT file handle from a native one.
233 *
234 * @returns IPRT status code.
235 * @param pFile Where to store the IPRT file handle.
236 * @param uNative The native handle.
237 */
238RTR3DECL(int) RTFileFromNative(PRTFILE pFile, RTHCINTPTR uNative);
239
240/**
241 * Gets the native handle for an IPRT file handle.
242 *
243 * @return The native handle.
244 * @params File The IPRT file handle.
245 */
246RTR3DECL(RTHCINTPTR) RTFileToNative(RTFILE File);
247
248/**
249 * Delete a file.
250 *
251 * @returns iprt status code.
252 * @param pszFilename Path to the file which is to be deleted. (UTF-8)
253 * @todo This is a RTPath api!
254 */
255RTR3DECL(int) RTFileDelete(const char *pszFilename);
256
257/** @name Seek flags.
258 * @{ */
259/** Seek from the start of the file. */
260#define RTFILE_SEEK_BEGIN 0x00
261/** Seek from the current file position. */
262#define RTFILE_SEEK_CURRENT 0x01
263/** Seek from the end of the file. */
264#define RTFILE_SEEK_END 0x02
265/** @internal */
266#define RTFILE_SEEK_FIRST RTFILE_SEEK_BEGIN
267/** @internal */
268#define RTFILE_SEEK_LAST RTFILE_SEEK_END
269/** @} */
270
271
272/**
273 * Changes the read & write position in a file.
274 *
275 * @returns iprt status code.
276 * @param File Handle to the file.
277 * @param offSeek Offset to seek.
278 * @param uMethod Seek method, i.e. one of the RTFILE_SEEK_* defines.
279 * @param poffActual Where to store the new file position.
280 * NULL is allowed.
281 */
282RTR3DECL(int) RTFileSeek(RTFILE File, int64_t offSeek, unsigned uMethod, uint64_t *poffActual);
283
284/**
285 * Read bytes from a file.
286 *
287 * @returns iprt status code.
288 * @param File Handle to the file.
289 * @param pvBuf Where to put the bytes we read.
290 * @param cbToRead How much to read.
291 * @param *pcbRead How much we actually read .
292 * If NULL an error will be returned for a partial read.
293 */
294RTR3DECL(int) RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRead);
295
296/**
297 * Read bytes from a file at a given offset.
298 * This function may modify the file position.
299 *
300 * @returns iprt status code.
301 * @param File Handle to the file.
302 * @param off Where to read.
303 * @param pvBuf Where to put the bytes we read.
304 * @param cbToRead How much to read.
305 * @param *pcbRead How much we actually read .
306 * If NULL an error will be returned for a partial read.
307 */
308RTR3DECL(int) RTFileReadAt(RTFILE File, RTFOFF off, void *pvBuf, size_t cbToRead, size_t *pcbRead);
309
310/**
311 * Write bytes to a file.
312 *
313 * @returns iprt status code.
314 * @param File Handle to the file.
315 * @param pvBuf What to write.
316 * @param cbToWrite How much to write.
317 * @param *pcbWritten How much we actually wrote.
318 * If NULL an error will be returned for a partial write.
319 */
320RTR3DECL(int) RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
321
322/**
323 * Write bytes to a file at a given offset.
324 * This function may modify the file position.
325 *
326 * @returns iprt status code.
327 * @param File Handle to the file.
328 * @param off Where to write.
329 * @param pvBuf What to write.
330 * @param cbToWrite How much to write.
331 * @param *pcbWritten How much we actually wrote.
332 * If NULL an error will be returned for a partial write.
333 */
334RTR3DECL(int) RTFileWriteAt(RTFILE File, RTFOFF off, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
335
336/**
337 * Flushes the buffers for the specified file.
338 *
339 * @returns iprt status code.
340 * @param File Handle to the file.
341 */
342RTR3DECL(int) RTFileFlush(RTFILE File);
343
344/**
345 * Set the size of the file.
346 *
347 * @returns iprt status code.
348 * @param File Handle to the file.
349 * @param cbSize The new file size.
350 */
351RTR3DECL(int) RTFileSetSize(RTFILE File, uint64_t cbSize);
352
353/**
354 * Query the size of the file.
355 *
356 * @returns iprt status code.
357 * @param File Handle to the file.
358 * @param pcbSize Where to store the filesize.
359 */
360RTR3DECL(int) RTFileGetSize(RTFILE File, uint64_t *pcbSize);
361
362/**
363 * Determine the maximum file size.
364 *
365 * @returns The max size of the file.
366 * -1 on failure, the file position is undefined.
367 * @param File Handle to the file.
368 * @see RTFileGetMaxSizeEx.
369 */
370RTR3DECL(RTFOFF) RTFileGetMaxSize(RTFILE File);
371
372/**
373 * Determine the maximum file size.
374 *
375 * @returns IPRT status code.
376 * @param File Handle to the file.
377 * @param pcbMax Where to store the max file size.
378 * @see RTFileGetMaxSize.
379 */
380RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE File, PRTFOFF pcbMax);
381
382/**
383 * Determine the maximum file size depending on the file system the file is stored on.
384 *
385 * @returns The max size of the file.
386 * -1 on failure.
387 * @param File Handle to the file.
388 */
389RTR3DECL(RTFOFF) RTFileGetMaxSize(RTFILE File);
390
391/**
392 * Gets the current file position.
393 *
394 * @returns File offset.
395 * @returns ~0UUL on failure.
396 * @param File Handle to the file.
397 */
398RTDECL(uint64_t) RTFileTell(RTFILE File);
399
400/**
401 * Checks if the supplied handle is valid.
402 *
403 * @returns true if valid.
404 * @returns false if invalid.
405 * @param File The file handle
406 */
407RTR3DECL(bool) RTFileIsValid(RTFILE File);
408
409/**
410 * Copies a file.
411 *
412 * @returns VERR_ALREADY_EXISTS if the destination file exists.
413 * @returns VBox Status code.
414 *
415 * @param pszSrc The path to the source file.
416 * @param pszDst The path to the destination file.
417 * This file will be created.
418 */
419RTDECL(int) RTFileCopy(const char *pszSrc, const char *pszDst);
420
421/**
422 * Copies a file given the handles to both files.
423 *
424 * @returns VBox Status code.
425 *
426 * @param FileSrc The source file. The file position is unaltered.
427 * @param FileDst The destination file.
428 * On successful returns the file position is at the end of the file.
429 * On failures the file position and size is undefined.
430 */
431RTDECL(int) RTFileCopyByHandles(RTFILE FileSrc, RTFILE FileDst);
432
433/** Flags for RTFileCopyEx().
434 * @{ */
435/** Do not use RTFILE_O_DENY_WRITE on the source file to allow for copying files opened for writing. */
436#define RTFILECOPY_FLAGS_NO_SRC_DENY_WRITE RT_BIT(0)
437/** Do not use RTFILE_O_DENY_WRITE on the target file. */
438#define RTFILECOPY_FLAGS_NO_DST_DENY_WRITE RT_BIT(1)
439/** Do not use RTFILE_O_DENY_WRITE on either of the two files. */
440#define RTFILECOPY_FLAGS_NO_DENY_WRITE ( RTFILECOPY_FLAGS_NO_SRC_DENY_WRITE | RTFILECOPY_FLAGS_NO_DST_DENY_WRITE )
441/** */
442#define RTFILECOPY_FLAGS_MASK UINT32_C(0x00000003)
443/** @} */
444
445/**
446 * Copies a file.
447 *
448 * @returns VERR_ALREADY_EXISTS if the destination file exists.
449 * @returns VBox Status code.
450 *
451 * @param pszSrc The path to the source file.
452 * @param pszDst The path to the destination file.
453 * This file will be created.
454 * @param fFlags Flags (RTFILECOPY_*).
455 * @param pfnProgress Pointer to callback function for reporting progress.
456 * @param pvUser User argument to pass to pfnProgress along with the completion precentage.
457 */
458RTDECL(int) RTFileCopyEx(const char *pszSrc, const char *pszDst, uint32_t fFlags, PFNRTPROGRESS pfnProgress, void *pvUser);
459
460/**
461 * Copies a file given the handles to both files and
462 * provide progress callbacks.
463 *
464 * @returns IPRT status code.
465 *
466 * @param FileSrc The source file. The file position is unaltered.
467 * @param FileDst The destination file.
468 * On successful returns the file position is at the end of the file.
469 * On failures the file position and size is undefined.
470 * @param pfnProgress Pointer to callback function for reporting progress.
471 * @param pvUser User argument to pass to pfnProgress along with the completion precentage.
472 */
473RTDECL(int) RTFileCopyByHandlesEx(RTFILE FileSrc, RTFILE FileDst, PFNRTPROGRESS pfnProgress, void *pvUser);
474
475/**
476 * Renames a file.
477 *
478 * Identical to RTPathRename except that it will ensure that the source is not a directory.
479 *
480 * @returns IPRT status code.
481 * @returns VERR_ALREADY_EXISTS if the destination file exists.
482 *
483 * @param pszSrc The path to the source file.
484 * @param pszDst The path to the destination file.
485 * This file will be created.
486 * @param fRename See RTPathRename.
487 */
488RTDECL(int) RTFileRename(const char *pszSrc, const char *pszDst, unsigned fRename);
489
490
491/** @name RTFileMove flags (bit masks).
492 * @{ */
493/** Replace destination file if present. */
494#define RTFILEMOVE_FLAGS_REPLACE 0x1
495/** @} */
496
497/**
498 * Moves a file.
499 *
500 * RTFileMove differs from RTFileRename in that it works across volumes.
501 *
502 * @returns IPRT status code.
503 * @returns VERR_ALREADY_EXISTS if the destination file exists.
504 *
505 * @param pszSrc The path to the source file.
506 * @param pszDst The path to the destination file.
507 * This file will be created.
508 * @param fMove A combination of the RTFILEMOVE_* flags.
509 */
510RTDECL(int) RTFileMove(const char *pszSrc, const char *pszDst, unsigned fMove);
511
512
513/** @page pg_rt_filelock RT File locking API description
514 *
515 * File locking general rules:
516 *
517 * Region to lock or unlock can be located beyond the end of file, this can be used for
518 * growing files.
519 * Read (or Shared) locks can be acquired held by an unlimited number of processes at the
520 * same time, but a Write (or Exclusive) lock can only be acquired by one process, and
521 * cannot coexist with a Shared lock. To acquire a Read lock, a process must wait until
522 * there are no processes holding any Write locks. To acquire a Write lock, a process must
523 * wait until there are no processes holding either kind of lock.
524 * By default, RTFileLock and RTFileChangeLock calls returns error immediately if the lock
525 * can't be acquired due to conflict with other locks, however they can be called in wait mode.
526 *
527 * Differences in implementation:
528 *
529 * Win32, OS/2: Locking is mandatory, since locks are enforced by the operating system.
530 * I.e. when file region is locked in Read mode, any write in it will fail; in case of Write
531 * lock - region can be readed and writed only by lock's owner.
532 *
533 * Win32: File size change (RTFileSetSize) is not controlled by locking at all (!) in the
534 * operation system. Also see comments to RTFileChangeLock API call.
535 *
536 * Linux/Posix: By default locks in Unixes are advisory. This means that cooperating processes
537 * may use locks to coordinate access to a file between themselves, but programs are also free
538 * to ignore locks and access the file in any way they choose to.
539 *
540 * Additional reading:
541 * http://en.wikipedia.org/wiki/File_locking
542 * http://unixhelp.ed.ac.uk/CGI/man-cgi?fcntl+2
543 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/lockfileex.asp
544 */
545
546/** @name Lock flags (bit masks).
547 * @{ */
548/** Read access, can be shared with others. */
549#define RTFILE_LOCK_READ 0x00
550/** Write access, one at a time. */
551#define RTFILE_LOCK_WRITE 0x01
552/** Don't wait for other locks to be released. */
553#define RTFILE_LOCK_IMMEDIATELY 0x00
554/** Wait till conflicting locks have been released. */
555#define RTFILE_LOCK_WAIT 0x02
556/** Valid flags mask */
557#define RTFILE_LOCK_MASK 0x03
558/** @} */
559
560
561/**
562 * Locks a region of file for read (shared) or write (exclusive) access.
563 *
564 * @returns iprt status code.
565 * @returns VERR_FILE_LOCK_VIOLATION if lock can't be acquired.
566 * @param File Handle to the file.
567 * @param fLock Lock method and flags, see RTFILE_LOCK_* defines.
568 * @param offLock Offset of lock start.
569 * @param cbLock Length of region to lock, may overlap the end of file.
570 */
571RTR3DECL(int) RTFileLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock);
572
573/**
574 * Changes a lock type from read to write or from write to read.
575 * The region to type change must correspond exactly to an existing locked region.
576 * If change can't be done due to locking conflict and non-blocking mode is used, error is
577 * returned and lock keeps its state (see next warning).
578 *
579 * WARNING: win32 implementation of this call is not atomic, it transforms to a pair of
580 * calls RTFileUnlock and RTFileLock. Potentially the previously acquired lock can be
581 * lost, i.e. function is called in non-blocking mode, previous lock is freed, new lock can't
582 * be acquired, and old lock (previous state) can't be acquired back too. This situation
583 * may occurs _only_ if the other process is acquiring a _write_ lock in blocking mode or
584 * in race condition with the current call.
585 * In this very bad case special error code VERR_FILE_LOCK_LOST will be returned.
586 *
587 * @returns iprt status code.
588 * @returns VERR_FILE_NOT_LOCKED if region was not locked.
589 * @returns VERR_FILE_LOCK_VIOLATION if lock type can't be changed, lock remains its type.
590 * @returns VERR_FILE_LOCK_LOST if lock was lost, we haven't this lock anymore :(
591 * @param File Handle to the file.
592 * @param fLock Lock method and flags, see RTFILE_LOCK_* defines.
593 * @param offLock Offset of lock start.
594 * @param cbLock Length of region to lock, may overlap the end of file.
595 */
596RTR3DECL(int) RTFileChangeLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock);
597
598/**
599 * Unlocks previously locked region of file.
600 * The region to unlock must correspond exactly to an existing locked region.
601 *
602 * @returns iprt status code.
603 * @returns VERR_FILE_NOT_LOCKED if region was not locked.
604 * @param File Handle to the file.
605 * @param offLock Offset of lock start.
606 * @param cbLock Length of region to unlock, may overlap the end of file.
607 */
608RTR3DECL(int) RTFileUnlock(RTFILE File, int64_t offLock, uint64_t cbLock);
609
610
611/**
612 * Query information about an open file.
613 *
614 * @returns iprt status code.
615 *
616 * @param File Handle to the file.
617 * @param pObjInfo Object information structure to be filled on successful return.
618 * @param enmAdditionalAttribs Which set of additional attributes to request.
619 * Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
620 */
621RTR3DECL(int) RTFileQueryInfo(RTFILE File, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs);
622
623/**
624 * Changes one or more of the timestamps associated of file system object.
625 *
626 * @returns iprt status code.
627 * @returns VERR_NOT_SUPPORTED is returned if the operation isn't supported by the OS.
628 *
629 * @param File Handle to the file.
630 * @param pAccessTime Pointer to the new access time. NULL if not to be changed.
631 * @param pModificationTime Pointer to the new modifcation time. NULL if not to be changed.
632 * @param pChangeTime Pointer to the new change time. NULL if not to be changed.
633 * @param pBirthTime Pointer to the new time of birth. NULL if not to be changed.
634 *
635 * @remark The file system might not implement all these time attributes,
636 * the API will ignore the ones which aren't supported.
637 *
638 * @remark The file system might not implement the time resolution
639 * employed by this interface, the time will be chopped to fit.
640 *
641 * @remark The file system may update the change time even if it's
642 * not specified.
643 *
644 * @remark POSIX can only set Access & Modification and will always set both.
645 */
646RTR3DECL(int) RTFileSetTimes(RTFILE File, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
647 PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime);
648
649/**
650 * Gets one or more of the timestamps associated of file system object.
651 *
652 * @returns iprt status code.
653 * @param File Handle to the file.
654 * @param pAccessTime Where to store the access time. NULL is ok.
655 * @param pModificationTime Where to store the modifcation time. NULL is ok.
656 * @param pChangeTime Where to store the change time. NULL is ok.
657 * @param pBirthTime Where to store the time of birth. NULL is ok.
658 *
659 * @remark This is wrapper around RTFileQueryInfo() and exists to complement RTFileSetTimes().
660 */
661RTR3DECL(int) RTFileGetTimes(RTFILE File, PRTTIMESPEC pAccessTime, PRTTIMESPEC pModificationTime,
662 PRTTIMESPEC pChangeTime, PRTTIMESPEC pBirthTime);
663
664/**
665 * Changes the mode flags of an open file.
666 *
667 * The API requires at least one of the mode flag sets (Unix/Dos) to
668 * be set. The type is ignored.
669 *
670 * @returns iprt status code.
671 * @param File Handle to the file.
672 * @param fMode The new file mode, see @ref grp_rt_fs for details.
673 */
674RTR3DECL(int) RTFileSetMode(RTFILE File, RTFMODE fMode);
675
676/**
677 * Gets the mode flags of an open file.
678 *
679 * @returns iprt status code.
680 * @param File Handle to the file.
681 * @param pfMode Where to store the file mode, see @ref grp_rt_fs for details.
682 *
683 * @remark This is wrapper around RTFileQueryInfo()
684 * and exists to complement RTFileSetMode().
685 */
686RTR3DECL(int) RTFileGetMode(RTFILE File, uint32_t *pfMode);
687
688/**
689 * Changes the owner and/or group of an open file.
690 *
691 * @returns iprt status code.
692 * @param File Handle to the file.
693 * @param uid The new file owner user id. Use -1 (or ~0) to leave this unchanged.
694 * @param gid The new group id. Use -1 (or ~0) to leave this unchanged.
695 */
696RTR3DECL(int) RTFileSetOwner(RTFILE File, uint32_t uid, uint32_t gid);
697
698/**
699 * Gets the owner and/or group of an open file.
700 *
701 * @returns iprt status code.
702 * @param File Handle to the file.
703 * @param pUid Where to store the owner user id. NULL is ok.
704 * @param pGid Where to store the group id. NULL is ok.
705 *
706 * @remark This is wrapper around RTFileQueryInfo() and exists to complement RTFileGetOwner().
707 */
708RTR3DECL(int) RTFileGetOwner(RTFILE File, uint32_t *pUid, uint32_t *pGid);
709
710/**
711 * Executes an IOCTL on a file descriptor.
712 *
713 * This function is currently only available in L4 and posix environments.
714 * Attemps at calling it from code shared with any other platforms will break things!
715 *
716 * The rational for defining this API is to simplify L4 porting of audio drivers,
717 * and to remove some of the assumptions on RTFILE being a file descriptor on
718 * platforms using the posix file implementation.
719 *
720 * @returns iprt status code.
721 * @param File Handle to the file.
722 * @param iRequest IOCTL request to carry out.
723 * @param pvData IOCTL data.
724 * @param cbData Size of the IOCTL data.
725 * @param piRet Return value of the IOCTL request.
726 */
727RTR3DECL(int) RTFileIoCtl(RTFILE File, int iRequest, void *pvData, unsigned cbData, int *piRet);
728
729/**
730 * Reads the file into memory.
731 *
732 * The caller must free the memory using RTFileReadAllFree().
733 *
734 * @returns IPRT status code.
735 * @param pszFilename The name of the file.
736 * @param ppvFile Where to store the pointer to the memory on successful return.
737 * @param pcbFile Where to store the size of the returned memory.
738 *
739 * @remarks Note that this function may be implemented using memory mapping, which means
740 * that the file may remain open until RTFileReadAllFree() is called. It also
741 * means that the return memory may reflect the state of the file when it's
742 * accessed instead of when this call was done. So, in short, don't use this
743 * API for volatile files, then rather use the extended variant with a
744 * yet-to-be-defined.
745 */
746RTDECL(int) RTFileReadAll(const char *pszFilename, void **ppvFile, size_t *pcbFile);
747
748/**
749 * Reads the file into memory.
750 *
751 * The caller must free the memory using RTFileReadAllFree().
752 *
753 * @returns IPRT status code.
754 * @param pszFilename The name of the file.
755 * @param off The offset to start reading at.
756 * @param cbMax The maximum number of bytes to read into memory. Specify RTFOFF_MAX
757 * to read to the end of the file.
758 * @param fFlags See RTFILE_RDALL_*.
759 * @param ppvFile Where to store the pointer to the memory on successful return.
760 * @param pcbFile Where to store the size of the returned memory.
761 *
762 * @remarks See the remarks for RTFileReadAll.
763 */
764RTDECL(int) RTFileReadAllEx(const char *pszFilename, RTFOFF off, RTFOFF cbMax, uint32_t fFlags, void **ppvFile, size_t *pcbFile);
765
766/**
767 * Reads the file into memory.
768 *
769 * The caller must free the memory using RTFileReadAllFree().
770 *
771 * @returns IPRT status code.
772 * @param File The handle to the file.
773 * @param ppvFile Where to store the pointer to the memory on successful return.
774 * @param pcbFile Where to store the size of the returned memory.
775 *
776 * @remarks See the remarks for RTFileReadAll.
777 */
778RTDECL(int) RTFileReadAllByHandle(RTFILE File, void **ppvFile, size_t *pcbFile);
779
780/**
781 * Reads the file into memory.
782 *
783 * The caller must free the memory using RTFileReadAllFree().
784 *
785 * @returns IPRT status code.
786 * @param File The handle to the file.
787 * @param off The offset to start reading at.
788 * @param cbMax The maximum number of bytes to read into memory. Specify RTFOFF_MAX
789 * to read to the end of the file.
790 * @param fFlags See RTFILE_RDALL_*.
791 * @param ppvFile Where to store the pointer to the memory on successful return.
792 * @param pcbFile Where to store the size of the returned memory.
793 *
794 * @remarks See the remarks for RTFileReadAll.
795 */
796RTDECL(int) RTFileReadAllByHandleEx(RTFILE File, RTFOFF off, RTFOFF cbMax, uint32_t fFlags, void **ppvFile, size_t *pcbFile);
797
798/**
799 * Frees the memory returned by one of the RTFileReadAll(), RTFileReadAllEx(),
800 * RTFileReadAllByHandle() and RTFileReadAllByHandleEx() functions.
801 *
802 * @param pvFile Pointer to the memory.
803 * @param cbFile The size of the memory.
804 */
805RTDECL(void) RTFileReadAllFree(void *pvFile, size_t cbFile);
806
807/** @name RTFileReadAllEx and RTFileReadAllHandleEx flags
808 * The open flags are ignored by RTFileReadAllHandleEx.
809 * @{ */
810#define RTFILE_RDALL_O_DENY_NONE RTFILE_O_DENY_NONE
811#define RTFILE_RDALL_O_DENY_READ RTFILE_O_DENY_READ
812#define RTFILE_RDALL_O_DENY_WRITE RTFILE_O_DENY_WRITE
813#define RTFILE_RDALL_O_DENY_READWRITE RTFILE_O_DENY_READWRITE
814#define RTFILE_RDALL_O_DENY_ALL RTFILE_O_DENY_ALL
815#define RTFILE_RDALL_O_DENY_NOT_DELETE RTFILE_O_DENY_NOT_DELETE
816#define RTFILE_RDALL_O_DENY_MASK RTFILE_O_DENY_MASK
817/** Mask of valid flags. */
818#define RTFILE_RDALL_VALID_MASK RTFILE_RDALL_O_DENY_MASK
819/** @} */
820
821
822/** @page pg_rt_asyncio RT File async I/O API
823 *
824 * File operations are usually blocking the calling thread until
825 * they completed making it impossible to let the thread do anything
826 * else inbetween.
827 * The RT File async I/O API provides an easy and efficient way to
828 * access files asynchronously using the native facilities provided
829 * by each operating system.
830 *
831 * @section sec_rt_asyncio_objects Objects
832 *
833 * There are two objects used in this API.
834 * The first object is the request. A request contains every information
835 * needed two complete the file operation successfully like the start offset
836 * and pointer to the source or destination buffer.
837 * Requests are created with RTFileAioReqCreate() and destroyed with
838 * RTFileAioReqDestroy().
839 * Because creating a request may require allocating various operating
840 * system dependent ressources and may be quite expensive it is possible
841 * to use a request more than once to save CPU cycles.
842 * A request is constructed with either RTFileAioReqPrepareRead()
843 * which will set up a request to read from the given file or
844 * RTFileAioReqPrepareWrite() which will write to a given file.
845 *
846 * The second object is the context. A file is associated with a context
847 * and requests for this file may complete only on the context the file
848 * was associated with and not on the context given in RTFileAioCtxSubmit()
849 * (see below for further information).
850 * RTFileAioCtxWait() is used to wait for completion of requests which were
851 * associated with the context. While waiting for requests the thread can not
852 * respond to global state changes. Thatswhy the API provides a way to let
853 * RTFileAioCtxWait() return immediately no matter how many requests
854 * have finished through RTFileAioCtxWakeup(). The return code is
855 * VERR_INTERRUPTED to let the thread know that he got interrupted.
856 *
857 * @section sec_rt_asyncio_request_states Request states
858 *
859 * Created:
860 * After a request was created with RTFileAioReqCreate() it is in the same state
861 * like it just completed successfully. RTFileAioReqGetRC() will return VINF_SUCCESS
862 * and a transfer size of 0. RTFileAioReqGetUser() will return NULL. The request can be
863 * destroyed RTFileAioReqDestroy(). It is also allowed to prepare a the request
864 * for a data transfer with the RTFileAioReqPrepare* methods.
865 * Calling any other method like RTFileAioCtxSubmit() will return VERR_FILE_AIO_NOT_PREPARED
866 * and RTFileAioReqCancel() returns VERR_FILE_AIO_NOT_SUBMITTED.
867 *
868 * Prepared:
869 * A request will enter this state if one of the RTFileAioReqPrepare* methods
870 * is called. In this state you can still destroy and retrieve the user data
871 * associated with the request but trying to cancel the request or getting
872 * the result of the operation will return VERR_FILE_AIO_NOT_SUBMITTED.
873 *
874 * Submitted:
875 * A prepared request can be submitted with RTFileAioCtxSubmit(). If the operation
876 * succeeds it is not allowed to touch the request or free any ressources until
877 * it completed through RTFileAioCtxWait(). The only allowed method is RTFileAioReqCancel()
878 * which tries to cancel the request. The request will go into the completed state
879 * and RTFileAioReqGetRC() will return VERR_FILE_AIO_CANCELED.
880 * If the request completes not matter if successfully or with an error it will
881 * switch into the completed state. RTFileReqDestroy() fails if the given request
882 * is in this state.
883 *
884 * Completed:
885 * The request will be in this state after it completed and returned through
886 * RTFileAioCtxWait(). RTFileAioReqGetRC() returns the final result code
887 * and the number of bytes transfered.
888 * The request can be used for new data transfers.
889 *
890 * @section sec_rt_asyncio_threading Threading
891 *
892 * The API is a thin wrapper around the specific host OS APIs and therefore
893 * relies on the thread safety of the underlying API.
894 * The interesting functions with regards to thread safety are RTFileAioCtxSubmit()
895 * and RTFileAioCtxWait(). RTFileAioCtxWait() must not be called from different
896 * threads at the same time with the same context handle. The same applies to
897 * RTFileAioCtxSubmit(). However it is possible to submit new requests from a different
898 * thread while waiting for completed requests on another thread with RTFileAioCtxWait().
899 *
900 * @section sec_rt_asyncio_implementations Differences in implementation
901 *
902 * Because the host APIs are quite different on every OS and every API has other limitations
903 * there are some things to consider to make the code as portable as possible.
904 *
905 * The first restriction at the moment is that every buffer has to be aligned to a 512 byte boundary.
906 * This limitation comes from the Linux io_* interface. To use the interface the file
907 * must be opened with O_DIRECT. This flag disables the kernel cache too which may
908 * degrade performance but is unfortunately the only way to make asynchronous
909 * I/O work till today (if O_DIRECT is omitted io_submit will revert to sychronous behavior
910 * and will return when the requests finished and when they are queued).
911 * It is mostly used by DBMS which do theire own caching.
912 * Furthermore there is no filesystem independent way to discover the restrictions at least
913 * for the 2.4 kernel series. Since 2.6 the 512 byte boundary seems to be used by all
914 * file systems. So Linus comment about this flag is comprehensible but Linux
915 * lacks an alternative at the moment.
916 *
917 * The next limitation applies only to Windows. Requests are not associated with the
918 * I/O context they are associated with but with the file the request is for.
919 * The file needs to be associated with exactly one I/O completion port and requests
920 * for this file will only arrive at that context after they completed and not on
921 * the context the request was submitted.
922 * To associate a file with a specific context RTFileAioCtxAssociateWithFile() is
923 * used. It is only implemented on Windows and does nothing on the other platforms.
924 * If the file needs to be associated with different context for some reason
925 * the file must be closed first. After it was opened again the new context
926 * can be associated with the other context.
927 * This can't be done by the API because there is no way to retrieve the flags
928 * the file was opened with.
929 */
930
931/**
932 * Global limits for the AIO API.
933 */
934typedef struct RTFILEAIOLIMITS
935{
936 /** Global number of simultaneous outstanding requests allowed.
937 * RTFILEAIO_UNLIMITED_REQS means no limit. */
938 uint32_t cReqsOutstandingMax;
939 /** The alignment data buffers need to have.
940 * 0 means no alignment restrictions. */
941 uint32_t cbBufferAlignment;
942} RTFILEAIOLIMITS;
943/** A pointer to a AIO limits structure. */
944typedef RTFILEAIOLIMITS *PRTFILEAIOLIMITS;
945
946/**
947 * Returns the global limits for the AIO API.
948 *
949 * @returns IPRT status code.
950 * @retval VERR_NOT_SUPPORTED if the host does not support the async I/O API.
951 *
952 * @param pAioLimits Where to store the global limit information.
953 */
954RTDECL(int) RTFileAioGetLimits(PRTFILEAIOLIMITS pAioLimits);
955
956/**
957 * Creates an async I/O request handle.
958 *
959 * @returns IPRT status code.
960 * @param phReq Where to store the request handle.
961 */
962RTDECL(int) RTFileAioReqCreate(PRTFILEAIOREQ phReq);
963
964/**
965 * Destroys an async I/O request handle.
966 *
967 * @returns IPRT status code.
968 * @retval VERR_FILE_AIO_IN_PROGRESS if the request is still in progress.
969 *
970 * @param hReq The request handle.
971 */
972RTDECL(int) RTFileAioReqDestroy(RTFILEAIOREQ hReq);
973
974/**
975 * Prepares an async read request.
976 *
977 * @returns IPRT status code.
978 * @retval VERR_FILE_AIO_IN_PROGRESS if the request is still in progress.
979 *
980 * @param hReq The request handle.
981 * @param hFile The file to read from.
982 * @param off The offset to start reading at.
983 * @param pvBuf Where to store the read bits.
984 * @param cbRead Number of bytes to read.
985 * @param pvUser Opaque user data associated with this request which
986 * can be retrieved with RTFileAioReqGetUser().
987 */
988RTDECL(int) RTFileAioReqPrepareRead(RTFILEAIOREQ hReq, RTFILE hFile, RTFOFF off,
989 void *pvBuf, size_t cbRead, void *pvUser);
990
991/**
992 * Prepares an async write request.
993 *
994 * @returns IPRT status code.
995 * @retval VERR_FILE_AIO_IN_PROGRESS if the request is still in progress.
996 *
997 * @param hReq The request handle.
998 * @param hFile The file to write to.
999 * @param off The offset to start writing at.
1000 * @param pvBuf Where to store the written bits.
1001 * @param cbRead Number of bytes to write.
1002 * @param pvUser Opaque user data associated with this request which
1003 * can be retrieved with RTFileAioReqGetUser().
1004 */
1005RTDECL(int) RTFileAioReqPrepareWrite(RTFILEAIOREQ hReq, RTFILE hFile, RTFOFF off,
1006 void *pvBuf, size_t cbWrite, void *pvUser);
1007
1008/**
1009 * Prepares an async flush of all cached data associated with a file handle.
1010 *
1011 * @returns IPRT status code.
1012 * @retval VERR_FILE_AIO_IN_PROGRESS if the request is still in progress.
1013 *
1014 * @param hReq The request handle.
1015 * @param hFile The file to flush.
1016 * @param pvUser Opaque user data associated with this request which
1017 * can be retrieved with RTFileAioReqGetUser().
1018 *
1019 * @remarks May also flush other caches on some platforms.
1020 */
1021RTDECL(int) RTFileAioReqPrepareFlush(RTFILEAIOREQ hReq, RTFILE hFile, void *pvUser);
1022
1023/**
1024 * Gets the opaque user data associated with the given request.
1025 *
1026 * @returns Opaque user data.
1027 * @retval NULL if the request hasn't been prepared yet.
1028 *
1029 * @param hReq The request handle.
1030 */
1031RTDECL(void *) RTFileAioReqGetUser(RTFILEAIOREQ hReq);
1032
1033/**
1034 * Cancels a pending request.
1035 *
1036 * @returns IPRT status code.
1037 * @retval VINF_SUCCESS If the request was canceled.
1038 * @retval VERR_FILE_AIO_NOT_SUBMITTED If the request wasn't submitted yet.
1039 * @retval VERR_FILE_AIO_IN_PROGRESS If the request could not be canceled because it is already processed.
1040 * @retval VERR_FILE_AIO_COMPLETED If the request could not be canceled because it already completed.
1041 *
1042 * @param hReq The request to cancel.
1043 */
1044RTDECL(int) RTFileAioReqCancel(RTFILEAIOREQ hReq);
1045
1046/**
1047 * Gets the status of a completed request.
1048 *
1049 * @returns The IPRT status code of the given request.
1050 * @retval VERR_FILE_AIO_NOT_SUBMITTED if the request wasn't submitted yet.
1051 * @retval VERR_FILE_AIO_CANCELED if the request was canceled.
1052 * @retval VERR_FILE_AIO_IN_PROGRESS if the request isn't yet completed.
1053 *
1054 * @param hReq The request handle.
1055 * @param pcbTransferred Where to store the number of bytes transfered.
1056 * Optional since it is not relevant for all kinds of
1057 * requests.
1058 */
1059RTDECL(int) RTFileAioReqGetRC(RTFILEAIOREQ hReq, size_t *pcbTransfered);
1060
1061
1062
1063/**
1064 * Creates an async I/O context.
1065 *
1066 * @todo briefly explain what an async context is here or in the page
1067 * above.
1068 *
1069 * @returns IPRT status code.
1070 * @param phAioCtx Where to store the async I/O context handle.
1071 * @param cAioReqsMax How many async I/O requests the context should be capable
1072 * to handle. Pass RTFILEAIO_UNLIMITED_REQS if the
1073 * context should support an unlimited number of
1074 * requests.
1075 */
1076RTDECL(int) RTFileAioCtxCreate(PRTFILEAIOCTX phAioCtx, uint32_t cAioReqsMax);
1077
1078/** Unlimited number of requests.
1079 * Used with RTFileAioCtxCreate and RTFileAioCtxGetMaxReqCount. */
1080#define RTFILEAIO_UNLIMITED_REQS UINT32_MAX
1081
1082/**
1083 * Destroys an async I/O context.
1084 *
1085 * @returns IPRT status code.
1086 * @param hAioCtx The async I/O context handle.
1087 */
1088RTDECL(int) RTFileAioCtxDestroy(RTFILEAIOCTX hAioCtx);
1089
1090/**
1091 * Get the maximum number of requests one aio context can handle.
1092 *
1093 * @returns Maximum number of tasks the context can handle.
1094 * RTFILEAIO_UNLIMITED_REQS if there is no limit.
1095 *
1096 * @param hAioCtx The async I/O context handle.
1097 * If NIL_RTAIOCONTEXT is passed the maximum value
1098 * which can be passed to RTFileAioCtxCreate()
1099 * is returned.
1100 */
1101RTDECL(uint32_t) RTFileAioCtxGetMaxReqCount(RTFILEAIOCTX hAioCtx);
1102
1103/**
1104 * Associates a file with a async I/O context.
1105 * Requests for this file will arrive at the completion port
1106 * associated with the file.
1107 *
1108 * @returns IPRT status code.
1109 *
1110 * @param hAioCtx The async I/O context handle.
1111 * @param hFile The file handle.
1112 */
1113RTDECL(int) RTFileAioCtxAssociateWithFile(RTFILEAIOCTX hAioCtx, RTFILE hFile);
1114
1115/**
1116 * Submits a set of requests to an async I/O context for processing.
1117 *
1118 * @returns IPRT status code.
1119 * @returns VERR_FILE_AIO_INSUFFICIENT_RESSOURCES if the maximum number of
1120 * simultaneous outstanding requests would be exceeded.
1121 *
1122 * @param hAioCtx The async I/O context handle.
1123 * @param pahReqs Pointer to an array of request handles.
1124 * @param cReqs The number of entries in the array.
1125 *
1126 * @remarks It is possible that some requests could be submitted successfully
1127 * even if the method returns an error code. In that case RTFileAioReqGetRC()
1128 * can be used to determine the status of a request.
1129 * If it returns VERR_FILE_AIO_IN_PROGRESS it was submitted successfully.
1130 * Any other error code may indicate why the request failed.
1131 * VERR_FILE_AIO_NOT_SUBMITTED indicates that a request wasn't submitted
1132 * probably because the previous request encountered an error.
1133 *
1134 * @remarks @a cReqs uses the type size_t while it really is a uint32_t, this is
1135 * to avoid annoying warnings when using RT_ELEMENTS and similar
1136 * macros.
1137 */
1138RTDECL(int) RTFileAioCtxSubmit(RTFILEAIOCTX hAioCtx, PRTFILEAIOREQ pahReqs, size_t cReqs);
1139
1140/**
1141 * Waits for request completion.
1142 *
1143 * Only one thread at a time may call this API on a context.
1144 *
1145 * @returns IPRT status code.
1146 * @retval VERR_INVALID_POINTER If pcReqs or/and pahReqs are invalid.
1147 * @retval VERR_INVALID_HANDLE If hAioCtx is invalid.
1148 * @retval VERR_OUT_OF_RANGE If cMinReqs is larger than cReqs.
1149 * @retval VERR_INVALID_PARAMETER If cReqs is 0.
1150 * @retval VERR_TIMEOUT If cMinReqs didn't complete before the
1151 * timeout expired.
1152 * @retval VERR_INTERRUPTED If the completion context was interrupted
1153 * by RTFileAioCtxWakeup().
1154 * @retval VERR_FILE_AIO_NO_REQUEST If there are no pending request.
1155 *
1156 * @param hAioCtx The async I/O context handle to wait and get
1157 * completed requests from.
1158 * @param cMinReqs The minimum number of requests which have to
1159 * complete before this function returns.
1160 * @param cMillisTimeout The number of milliseconds to wait before returning
1161 * VERR_TIMEOUT. Use RT_INDEFINITE_WAIT to wait
1162 * forever.
1163 * @param pahReqs Pointer to an array where the handles of the
1164 * completed requests will be stored on success.
1165 * @param cReqs The number of entries @a pahReqs can hold.
1166 * @param pcReqs Where to store the number of returned (complete)
1167 * requests. This will always be set.
1168 *
1169 * @remarks The wait will be resume if interrupted by a signal. An
1170 * RTFileAioCtxWaitNoResume variant can be added later if it becomes
1171 * necessary.
1172 *
1173 * @remarks @a cMinReqs and @a cReqs use the type size_t while they really are
1174 * uint32_t's, this is to avoid annoying warnings when using
1175 * RT_ELEMENTS and similar macros.
1176 */
1177RTDECL(int) RTFileAioCtxWait(RTFILEAIOCTX hAioCtx, size_t cMinReqs, unsigned cMillisTimeout,
1178 PRTFILEAIOREQ pahReqs, size_t cReqs, uint32_t *pcReqs);
1179
1180/**
1181 * Forces any RTFileAioCtxWait() call on another thread to return immediately.
1182 *
1183 * @returns IPRT status code.
1184 *
1185 * @param hAioCtx The handle of the async I/O context to wakeup.
1186 */
1187RTDECL(int) RTFileAioCtxWakeup(RTFILEAIOCTX hAioCtx);
1188
1189#endif /* IN_RING3 */
1190
1191/** @} */
1192
1193RT_C_DECLS_END
1194
1195#endif
1196
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette