1 | /** @file
|
---|
2 | * IPRT - Virtual Filesystem.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2010 Oracle Corporation
|
---|
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 |
|
---|
26 | #ifndef ___iprt_vfs_h
|
---|
27 | #define ___iprt_vfs_h
|
---|
28 |
|
---|
29 | #include <iprt/cdefs.h>
|
---|
30 | #include <iprt/types.h>
|
---|
31 | #include <iprt/dir.h>
|
---|
32 | #include <iprt/fs.h>
|
---|
33 | #include <iprt/handle.h>
|
---|
34 | #include <iprt/symlink.h>
|
---|
35 | #include <iprt/sg.h>
|
---|
36 | #include <iprt/time.h>
|
---|
37 |
|
---|
38 |
|
---|
39 | RT_C_DECLS_BEGIN
|
---|
40 |
|
---|
41 | /** @defgroup grp_rt_fs RTVfs - Virtual Filesystem
|
---|
42 | * @ingroup grp_rt
|
---|
43 | *
|
---|
44 | * The virtual filesystem APIs are intended to make it possible to work on
|
---|
45 | * container files, file system sub-trees, file system overlays and other custom
|
---|
46 | * filesystem configurations. It also makes it possible to create filters, like
|
---|
47 | * automatically gunzipping a tar.gz file before feeding it to the RTTar API for
|
---|
48 | * unpacking - or wise versa.
|
---|
49 | *
|
---|
50 | * The virtual filesystem APIs are intended to mirror the RTDir, RTFile, RTPath
|
---|
51 | * and RTFs APIs pretty closely so that rewriting a piece of code to work with
|
---|
52 | * it should be easy. However there are some differences to the way the APIs
|
---|
53 | * works and the user should heed the documentation. The differences are
|
---|
54 | * usually motivated by simplification and in some case to make the VFS more
|
---|
55 | * flexible.
|
---|
56 | *
|
---|
57 | * @{
|
---|
58 | */
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * The object type.
|
---|
62 | */
|
---|
63 | typedef enum RTVFSOBJTYPE
|
---|
64 | {
|
---|
65 | /** Invalid type. */
|
---|
66 | RTVFSOBJTYPE_INVALID = 0,
|
---|
67 | /** Pure base object.
|
---|
68 | * This is returned by the filesystem stream to represent directories,
|
---|
69 | * devices, fifos and similar that needs to be created. */
|
---|
70 | RTVFSOBJTYPE_BASE,
|
---|
71 | /** Virtual filesystem. */
|
---|
72 | RTVFSOBJTYPE_VFS,
|
---|
73 | /** Filesystem stream. */
|
---|
74 | RTVFSOBJTYPE_FS_STREAM,
|
---|
75 | /** Pure I/O stream. */
|
---|
76 | RTVFSOBJTYPE_IO_STREAM,
|
---|
77 | /** Directory. */
|
---|
78 | RTVFSOBJTYPE_DIR,
|
---|
79 | /** File. */
|
---|
80 | RTVFSOBJTYPE_FILE,
|
---|
81 | /** Symbolic link. */
|
---|
82 | RTVFSOBJTYPE_SYMLINK,
|
---|
83 | /** End of valid object types. */
|
---|
84 | RTVFSOBJTYPE_END,
|
---|
85 | /** Pure I/O stream. */
|
---|
86 | RTVFSOBJTYPE_32BIT_HACK = 0x7fffffff
|
---|
87 | } RTVFSOBJTYPE;
|
---|
88 | /** Pointer to a VFS object type. */
|
---|
89 | typedef RTVFSOBJTYPE *PRTVFSOBJTYPE;
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 | /** @name RTVfsCreate flags
|
---|
94 | * @{ */
|
---|
95 | /** Whether the file system is read-only. */
|
---|
96 | #define RTVFS_C_READONLY RT_BIT(0)
|
---|
97 | /** Whether we the VFS should be thread safe (i.e. automaticaly employ
|
---|
98 | * locks). */
|
---|
99 | #define RTVFS_C_THREAD_SAFE RT_BIT(1)
|
---|
100 | /** @} */
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * Creates an empty virtual filesystem.
|
---|
104 | *
|
---|
105 | * @returns IPRT status code.
|
---|
106 | * @param pszName Name, for logging and such.
|
---|
107 | * @param fFlags Flags, MBZ.
|
---|
108 | * @param phVfs Where to return the VFS handle. Release the returned
|
---|
109 | * reference by calling RTVfsRelease.
|
---|
110 | */
|
---|
111 | RTDECL(int) RTVfsCreate(const char *pszName, uint32_t fFlags, PRTVFS phVfs);
|
---|
112 | RTDECL(uint32_t) RTVfsRetain(RTVFS phVfs);
|
---|
113 | RTDECL(uint32_t) RTVfsRelease(RTVFS phVfs);
|
---|
114 | RTDECL(int) RTVfsAttach(RTVFS hVfs, const char *pszMountPoint, uint32_t fFlags, RTVFS hVfsAttach);
|
---|
115 | RTDECL(int) RTVfsDetach(RTVFS hVfs, const char *pszMountPoint, RTVFS hVfsToDetach, PRTVFS *phVfsDetached);
|
---|
116 | RTDECL(uint32_t) RTVfsGetAttachmentCount(RTVFS hVfs);
|
---|
117 | RTDECL(int) RTVfsGetAttachment(RTVFS hVfs, uint32_t iOrdinal, PRTVFS *phVfsAttached, uint32_t *pfFlags,
|
---|
118 | char *pszMountPoint, size_t cbMountPoint);
|
---|
119 |
|
---|
120 |
|
---|
121 | /** @defgroup grp_vfs_dir VFS Directory API
|
---|
122 | * @{
|
---|
123 | */
|
---|
124 |
|
---|
125 | RTDECL(RTVFS) RTVfsObjToVfs(RTVFSOBJ hVfsObj);
|
---|
126 | RTDECL(RTVFSFSSTREAM) RTVfsObjToFsStream(RTVFSOBJ hVfsObj);
|
---|
127 | RTDECL(RTVFSDIR) RTVfsObjToDir(RTVFSOBJ hVfsObj);
|
---|
128 | RTDECL(RTVFSIOSTREAM) RTVfsObjToIoStream(RTVFSOBJ hVfsObj);
|
---|
129 | RTDECL(RTVFSFILE) RTVfsObjToFile(RTVFSOBJ hVfsObj);
|
---|
130 | RTDECL(RTVFSSYMLINK) RTVfsObjToSymlink(RTVFSOBJ hVfsObj);
|
---|
131 |
|
---|
132 | RTDECL(RTVFSOBJ) RTVfsObjFromVfs(RTVFS hVfs);
|
---|
133 | RTDECL(RTVFSOBJ) RTVfsObjFromFsStream(RTVFSFSSTREAM hVfsFss);
|
---|
134 | RTDECL(RTVFSOBJ) RTVfsObjFromDir(RTVFSDIR hVfsDir);
|
---|
135 | RTDECL(RTVFSOBJ) RTVfsObjFromIoStream(RTVFSIOSTREAM hVfsIos);
|
---|
136 | RTDECL(RTVFSOBJ) RTVfsObjFromFile(RTVFSFILE hVfsFile);
|
---|
137 | RTDECL(RTVFSOBJ) RTVfsObjFromSymlink(RTVFSSYMLINK hVfsSym);
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * Query information about the object.
|
---|
141 | *
|
---|
142 | * @returns IPRT status code.
|
---|
143 | * @param hVfsObj The VFS object handle.
|
---|
144 | * @param pObjInfo Where to return the info.
|
---|
145 | * @param enmAddAttr Which additional attributes should be retrieved.
|
---|
146 | * @sa RTFileQueryInfo, RTPathQueryInfo
|
---|
147 | */
|
---|
148 | RTDECL(int) RTVfsObjQueryInfo(RTVFSOBJ hVfsObj, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
|
---|
149 |
|
---|
150 | /** @} */
|
---|
151 |
|
---|
152 |
|
---|
153 | /** @defgroup grp_vfs_fsstream VFS Filesystem Stream API
|
---|
154 | *
|
---|
155 | * Filesystem streams are for tar, cpio and similar. Any virtual filesystem can
|
---|
156 | * be turned into a filesystem stream using RTVfsFsStrmFromVfs.
|
---|
157 | *
|
---|
158 | * @{
|
---|
159 | */
|
---|
160 |
|
---|
161 | RTDECL(uint32_t) RTVfsFsStrmRetain(RTVFSFSSTREAM hVfsFss);
|
---|
162 | RTDECL(uint32_t) RTVfsFsStrmRelease(RTVFSFSSTREAM hVfsFss);
|
---|
163 | RTDECL(int) RTVfsFsStrmQueryInfo(RTVFSFSSTREAM hVfsFss, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * Gets the next object in the stream.
|
---|
167 | *
|
---|
168 | * This call may affect the stream posision of a previously returned object.
|
---|
169 | *
|
---|
170 | * The type of object returned here typically boils down to three types:
|
---|
171 | * - I/O streams (representing files),
|
---|
172 | * - symbolic links
|
---|
173 | * - base object
|
---|
174 | * The base objects represent anything not convered by the two other, i.e.
|
---|
175 | * directories, device nodes, fifos, sockets and whatnot. The details can be
|
---|
176 | * queried using RTVfsObjQueryInfo.
|
---|
177 | *
|
---|
178 | * That said, absolutely any object except for filesystem stream objects can be
|
---|
179 | * returned by this call. Any generic code is adviced to just deal with it all.
|
---|
180 | *
|
---|
181 | * @returns IPRT status code.
|
---|
182 | * @retval VINF_SUCCESS if a new object was retrieved.
|
---|
183 | * @retval VERR_EOF when there are no more objects.
|
---|
184 | * @param pvThis The implementation specific directory data.
|
---|
185 | * @param ppszName Where to return the object name. Must be freed by
|
---|
186 | * calling RTStrFree.
|
---|
187 | * @param penmType Where to return the object type.
|
---|
188 | * @param hVfsObj Where to return the object handle (referenced).
|
---|
189 | * This must be cast to the desired type before use.
|
---|
190 | */
|
---|
191 | RTDECL(int) RTVfsFsStrmNext(RTVFSFSSTREAM hVfsFss, char **ppszName, RTVFSOBJTYPE *penmType, PRTVFSOBJ phVfsObj);
|
---|
192 |
|
---|
193 | /** @} */
|
---|
194 |
|
---|
195 |
|
---|
196 | /** @defgroup grp_vfs_dir VFS Directory API
|
---|
197 | * @{
|
---|
198 | */
|
---|
199 |
|
---|
200 | /**
|
---|
201 | * Retains a reference to the VFS directory handle.
|
---|
202 | *
|
---|
203 | * @returns New reference count on success, UINT32_MAX on failure.
|
---|
204 | * @param hVfsDir The VFS directory handle.
|
---|
205 | */
|
---|
206 | RTDECL(uint32_t) RTVfsDirRetain(RTVFSDIR hVfsDir);
|
---|
207 |
|
---|
208 | /**
|
---|
209 | * Releases a reference to the VFS directory handle.
|
---|
210 | *
|
---|
211 | * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
|
---|
212 | * @param hVfsIos The VFS directory handle.
|
---|
213 | */
|
---|
214 | RTDECL(uint32_t) RTVfsDirRelease(RTVFSDIR hVfsDir);
|
---|
215 |
|
---|
216 | /** @} */
|
---|
217 |
|
---|
218 |
|
---|
219 | /** @defgroup grp_vfs_iostream VFS Symbolic Link API
|
---|
220 | * @{
|
---|
221 | */
|
---|
222 |
|
---|
223 | RTDECL(uint32_t) RTVfsSymlinkRetain(RTVFSSYMLINK hVfsSym);
|
---|
224 | RTDECL(uint32_t) RTVfsSymlinkRelease(RTVFSSYMLINK hVfsSym);
|
---|
225 |
|
---|
226 | /**
|
---|
227 | * Read the symbolic link target.
|
---|
228 | *
|
---|
229 | * @returns IPRT status code.
|
---|
230 | * @param hVfsSym The VFS symbolic link handle.
|
---|
231 | * @param pszTarget The target buffer.
|
---|
232 | * @param cbTarget The size of the target buffer.
|
---|
233 | * @sa RTSymlinkRead
|
---|
234 | */
|
---|
235 | RTDECL(int) RTVfsSymlinkRead(RTVFSSYMLINK hVfsSym, char *pszTarget, size_t cbTarget);
|
---|
236 |
|
---|
237 | /** @} */
|
---|
238 |
|
---|
239 |
|
---|
240 |
|
---|
241 | /** @defgroup grp_vfs_iostream VFS I/O Stream API
|
---|
242 | * @{
|
---|
243 | */
|
---|
244 |
|
---|
245 | /**
|
---|
246 | * Create a VFS I/O stream handle from a standard IPRT file handle (RTFILE).
|
---|
247 | *
|
---|
248 | * @returns IPRT status code.
|
---|
249 | * @param hFile The standard IPRT file handle.
|
---|
250 | * @param fOpen The flags the handle was opened with. Pass 0 to
|
---|
251 | * have these detected.
|
---|
252 | * @param fLeaveOpen Whether to leave the handle open when the VFS file
|
---|
253 | * is released, or to close it (@c false).
|
---|
254 | * @param phVfsIos Where to return the VFS I/O stream handle.
|
---|
255 | */
|
---|
256 | RTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint32_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos);
|
---|
257 |
|
---|
258 | /**
|
---|
259 | * Create a VFS I/O stream handle from one of the standard handles.
|
---|
260 | *
|
---|
261 | * @returns IPRT status code.
|
---|
262 | * @param enmStdHandle The standard IPRT file handle.
|
---|
263 | * @param fOpen The flags the handle was opened with. Pass 0 to
|
---|
264 | * have these detected.
|
---|
265 | * @param fLeaveOpen Whether to leave the handle open when the VFS file
|
---|
266 | * is released, or to close it (@c false).
|
---|
267 | * @param phVfsIos Where to return the VFS I/O stream handle.
|
---|
268 | */
|
---|
269 | RTDECL(int) RTVfsIoStrmFromStdHandle(RTHANDLESTD enmStdHandle, uint32_t fOpen, bool fLeaveOpen,
|
---|
270 | PRTVFSIOSTREAM phVfsIos);
|
---|
271 |
|
---|
272 | /**
|
---|
273 | * Retains a reference to the VFS I/O stream handle.
|
---|
274 | *
|
---|
275 | * @returns New reference count on success, UINT32_MAX on failure.
|
---|
276 | * @param hVfsIos The VFS I/O stream handle.
|
---|
277 | */
|
---|
278 | RTDECL(uint32_t) RTVfsIoStrmRetain(RTVFSIOSTREAM hVfsIos);
|
---|
279 |
|
---|
280 | /**
|
---|
281 | * Releases a reference to the VFS I/O stream handle.
|
---|
282 | *
|
---|
283 | * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
|
---|
284 | * @param hVfsIos The VFS I/O stream handle.
|
---|
285 | */
|
---|
286 | RTDECL(uint32_t) RTVfsIoStrmRelease(RTVFSIOSTREAM hVfsIos);
|
---|
287 |
|
---|
288 | /**
|
---|
289 | * Convert the VFS I/O stream handle to a VFS file handle.
|
---|
290 | *
|
---|
291 | * @returns The VFS file handle on success, this must be released.
|
---|
292 | * NIL_RTVFSFILE if the I/O stream handle is invalid.
|
---|
293 | * @param hVfsIos The VFS I/O stream handle.
|
---|
294 | * @sa RTVfsFileToIoStream
|
---|
295 | */
|
---|
296 | RTDECL(RTVFSFILE) RTVfsIoStrmToFile(RTVFSIOSTREAM hVfsIos);
|
---|
297 |
|
---|
298 | /**
|
---|
299 | * Query information about the I/O stream.
|
---|
300 | *
|
---|
301 | * @returns IPRT status code.
|
---|
302 | * @param hVfsIos The VFS I/O stream handle.
|
---|
303 | * @param pObjInfo Where to return the info.
|
---|
304 | * @param enmAddAttr Which additional attributes should be retrieved.
|
---|
305 | * @sa RTFileQueryInfo
|
---|
306 | */
|
---|
307 | RTDECL(int) RTVfsIoStrmQueryInfo(RTVFSIOSTREAM hVfsIos, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
|
---|
308 |
|
---|
309 | /**
|
---|
310 | * Read bytes from the I/O stream.
|
---|
311 | *
|
---|
312 | * @returns IPRT status code.
|
---|
313 | * @retval VINF_SUCCESS and the number of bytes read written to @a pcbRead.
|
---|
314 | * @retval VINF_TRY_AGAIN if @a fBlocking is @c false, @a pcbRead is not NULL,
|
---|
315 | * and no data was available. @a *pcbRead will be set to 0.
|
---|
316 | * @retval VINF_EOF when trying to read __beyond__ the end of the stream and
|
---|
317 | * @a pcbRead is not NULL (it will be set to the number of bytes read,
|
---|
318 | * or 0 if the end of the stream was reached before this call).
|
---|
319 | * When the last byte of the read request is the last byte in the
|
---|
320 | * stream, this status code will not be used. However, VINF_EOF is
|
---|
321 | * returned when attempting to read 0 bytes while standing at the end
|
---|
322 | * of the stream.
|
---|
323 | * @retval VERR_EOF when trying to read __beyond__ the end of the stream and
|
---|
324 | * @a pcbRead is NULL.
|
---|
325 | *
|
---|
326 | * @param hVfsIos The VFS I/O stream handle.
|
---|
327 | * @param pvBuf Where to store the read bytes.
|
---|
328 | * @param cbToRead The number of bytes to read.
|
---|
329 | * @param fBlocking Whether the call is blocking (@c true) or not. If
|
---|
330 | * not, the @a pcbRead parameter must not be NULL.
|
---|
331 | * @param pcbRead Where to always store the number of bytes actually
|
---|
332 | * read. This can be NULL if @a fBlocking is true.
|
---|
333 | * @sa RTFileRead, RTPipeRead, RTPipeReadBlocking, RTSocketRead
|
---|
334 | */
|
---|
335 | RTDECL(int) RTVfsIoStrmRead(RTVFSIOSTREAM hVfsIos, void *pvBuf, size_t cbToRead, bool fBlocking, size_t *pcbRead);
|
---|
336 |
|
---|
337 | /**
|
---|
338 | * Write bytes to the I/O stream.
|
---|
339 | *
|
---|
340 | * @returns IPRT status code.
|
---|
341 | * @param hVfsIos The VFS I/O stream handle.
|
---|
342 | * @param pvBuf The bytes to write.
|
---|
343 | * @param cbToWrite The number of bytes to write.
|
---|
344 | * @param fBlocking Whether the call is blocking (@c true) or not. If
|
---|
345 | * not, the @a pcbWritten parameter must not be NULL.
|
---|
346 | * @param pcbRead Where to always store the number of bytes actually
|
---|
347 | * written. This can be NULL if @a fBlocking is true.
|
---|
348 | * @sa RTFileWrite, RTPipeWrite, RTPipeWriteBlocking, RTSocketWrite
|
---|
349 | */
|
---|
350 | RTDECL(int) RTVfsIoStrmWrite(RTVFSIOSTREAM hVfsIos, const void *pvBuf, size_t cbToWrite, bool fBlocking, size_t *pcbWritten);
|
---|
351 |
|
---|
352 | /**
|
---|
353 | * Reads bytes from the I/O stream into a scatter buffer.
|
---|
354 | *
|
---|
355 | * @returns IPRT status code.
|
---|
356 | * @retval VINF_SUCCESS and the number of bytes read written to @a pcbRead.
|
---|
357 | * @retval VINF_TRY_AGAIN if @a fBlocking is @c false, @a pcbRead is not NULL,
|
---|
358 | * and no data was available. @a *pcbRead will be set to 0.
|
---|
359 | * @retval VINF_EOF when trying to read __beyond__ the end of the stream and
|
---|
360 | * @a pcbRead is not NULL (it will be set to the number of bytes read,
|
---|
361 | * or 0 if the end of the stream was reached before this call).
|
---|
362 | * When the last byte of the read request is the last byte in the
|
---|
363 | * stream, this status code will not be used. However, VINF_EOF is
|
---|
364 | * returned when attempting to read 0 bytes while standing at the end
|
---|
365 | * of the stream.
|
---|
366 | * @retval VERR_EOF when trying to read __beyond__ the end of the stream and
|
---|
367 | * @a pcbRead is NULL.
|
---|
368 | *
|
---|
369 | * @param hVfsIos The VFS I/O stream handle.
|
---|
370 | * @param pSgBuf Pointer to a scatter buffer descriptor. The number
|
---|
371 | * of bytes described by the segments is what will be
|
---|
372 | * attemted read.
|
---|
373 | * @param fBlocking Whether the call is blocking (@c true) or not. If
|
---|
374 | * not, the @a pcbRead parameter must not be NULL.
|
---|
375 | * @param pcbRead Where to always store the number of bytes actually
|
---|
376 | * read. This can be NULL if @a fBlocking is true.
|
---|
377 | * @sa RTFileSgRead, RTSocketSgRead, RTPipeRead, RTPipeReadBlocking
|
---|
378 | */
|
---|
379 | RTDECL(int) RTVfsIoStrmSgRead(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead);
|
---|
380 |
|
---|
381 | /**
|
---|
382 | * Write bytes to the I/O stream from a gather buffer.
|
---|
383 | *
|
---|
384 | * @returns IPRT status code.
|
---|
385 | * @param hVfsIos The VFS I/O stream handle.
|
---|
386 | * @param pSgBuf Pointer to a gather buffer descriptor. The number
|
---|
387 | * of bytes described by the segments is what will be
|
---|
388 | * attemted written.
|
---|
389 | * @param fBlocking Whether the call is blocking (@c true) or not. If
|
---|
390 | * not, the @a pcbWritten parameter must not be NULL.
|
---|
391 | * @param pcbRead Where to always store the number of bytes actually
|
---|
392 | * written. This can be NULL if @a fBlocking is true.
|
---|
393 | * @sa RTFileSgWrite, RTSocketSgWrite
|
---|
394 | */
|
---|
395 | RTDECL(int) RTVfsIoStrmSgWrite(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten);
|
---|
396 |
|
---|
397 | /**
|
---|
398 | * Flush any buffered data to the I/O stream.
|
---|
399 | *
|
---|
400 | * @returns IPRT status code.
|
---|
401 | * @param hVfsIos The VFS I/O stream handle.
|
---|
402 | * @sa RTFileFlush, RTPipeFlush
|
---|
403 | */
|
---|
404 | RTDECL(int) RTVfsIoStrmFlush(RTVFSIOSTREAM hVfsIos);
|
---|
405 |
|
---|
406 | /**
|
---|
407 | * Poll for events.
|
---|
408 | *
|
---|
409 | * @returns IPRT status code.
|
---|
410 | * @param hVfsIos The VFS I/O stream handle.
|
---|
411 | * @param fEvents The events to poll for (RTPOLL_EVT_XXX).
|
---|
412 | * @param cMillies How long to wait for event to eventuate.
|
---|
413 | * @param fIntr Whether the wait is interruptible and can return
|
---|
414 | * VERR_INTERRUPTED (@c true) or if this condition
|
---|
415 | * should be hidden from the caller (@c false).
|
---|
416 | * @param pfRetEvents Where to return the event mask.
|
---|
417 | * @sa RTPollSetAdd, RTPoll, RTPollNoResume.
|
---|
418 | */
|
---|
419 | RTDECL(RTFOFF) RTVfsIoStrmPoll(RTVFSIOSTREAM hVfsIos, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
|
---|
420 | uint32_t *pfRetEvents);
|
---|
421 | /**
|
---|
422 | * Tells the current I/O stream position.
|
---|
423 | *
|
---|
424 | * @returns Zero or higher - where to return the I/O stream offset. Values
|
---|
425 | * below zero are IPRT status codes (VERR_XXX).
|
---|
426 | * @param hVfsIos The VFS I/O stream handle.
|
---|
427 | * @sa RTFileTell
|
---|
428 | */
|
---|
429 | RTDECL(RTFOFF) RTVfsIoStrmTell(RTVFSIOSTREAM hVfsIos);
|
---|
430 |
|
---|
431 | /**
|
---|
432 | * Skips @a cb ahead in the stream.
|
---|
433 | *
|
---|
434 | * @returns IPRT status code.
|
---|
435 | * @param hVfsIos The VFS I/O stream handle.
|
---|
436 | * @param cb The number bytes to skip.
|
---|
437 | */
|
---|
438 | RTDECL(int) RTVfsIoStrmSkip(RTVFSIOSTREAM hVfsIos, RTFOFF cb);
|
---|
439 |
|
---|
440 | /**
|
---|
441 | * Fills the stream with @a cb zeros.
|
---|
442 | *
|
---|
443 | * @returns IPRT status code.
|
---|
444 | * @param hVfsIos The VFS I/O stream handle.
|
---|
445 | * @param cb The number of zero bytes to insert.
|
---|
446 | */
|
---|
447 | RTDECL(int) RTVfsIoStrmZeroFill(RTVFSIOSTREAM hVfsIos, RTFOFF cb);
|
---|
448 | /** @} */
|
---|
449 |
|
---|
450 |
|
---|
451 | /** @defgroup grp_vfs_file VFS File API
|
---|
452 | * @{
|
---|
453 | */
|
---|
454 | RTDECL(int) RTVfsFileOpen(RTVFS hVfs, const char *pszFilename, uint32_t fOpen, PRTVFSFILE phVfsFile);
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * Create a VFS file handle from a standard IPRT file handle (RTFILE).
|
---|
458 | *
|
---|
459 | * @returns IPRT status code.
|
---|
460 | * @param hFile The standard IPRT file handle.
|
---|
461 | * @param fOpen The flags the handle was opened with. Pass 0 to
|
---|
462 | * have these detected.
|
---|
463 | * @param fLeaveOpen Whether to leave the handle open when the VFS file
|
---|
464 | * is released, or to close it (@c false).
|
---|
465 | * @param phVfsFile Where to return the VFS file handle.
|
---|
466 | */
|
---|
467 | RTDECL(int) RTVfsFileFromRTFile(RTFILE hFile, uint32_t fOpen, bool fLeaveOpen, PRTVFSFILE phVfsFile);
|
---|
468 | RTDECL(RTHCUINTPTR) RTVfsFileToNative(RTFILE hVfsFile);
|
---|
469 |
|
---|
470 | /**
|
---|
471 | * Convert the VFS file handle to a VFS I/O stream handle.
|
---|
472 | *
|
---|
473 | * @returns The VFS I/O stream handle on success, this must be released.
|
---|
474 | * NIL_RTVFSIOSTREAM if the file handle is invalid.
|
---|
475 | * @param hVfsFile The VFS file handle.
|
---|
476 | * @sa RTVfsIoStrmToFile
|
---|
477 | */
|
---|
478 | RTDECL(RTVFSIOSTREAM) RTVfsFileToIoStream(RTVFSFILE hVfsFile);
|
---|
479 |
|
---|
480 | /**
|
---|
481 | * Retains a reference to the VFS file handle.
|
---|
482 | *
|
---|
483 | * @returns New reference count on success, UINT32_MAX on failure.
|
---|
484 | * @param hVfsFile The VFS file handle.
|
---|
485 | */
|
---|
486 | RTDECL(uint32_t) RTVfsFileRetain(RTVFSFILE hVfsFile);
|
---|
487 |
|
---|
488 | /**
|
---|
489 | * Releases a reference to the VFS file handle.
|
---|
490 | *
|
---|
491 | * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
|
---|
492 | * @param hVfsFile The VFS file handle.
|
---|
493 | */
|
---|
494 | RTDECL(uint32_t) RTVfsFileRelease(RTVFSFILE hVfsFile);
|
---|
495 |
|
---|
496 | RTDECL(int) RTVfsFileQueryInfo(RTVFSFILE hVfsFile, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
|
---|
497 | RTDECL(int) RTVfsFileRead(RTVFSFILE hVfsFile, void *pvBuf, size_t cbToRead, size_t *pcbRead);
|
---|
498 | RTDECL(int) RTVfsFileReadAt(RTVFSFILE hVfsFile, RTFOFF off, void *pvBuf, size_t cbToRead, size_t *pcbRead);
|
---|
499 | RTDECL(int) RTVfsFileWrite(RTVFSFILE hVfsFile, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
|
---|
500 | RTDECL(int) RTVfsFileWriteAt(RTVFSFILE hVfsFile, RTFOFF off, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
|
---|
501 | RTDECL(int) RTVfsFileFlush(RTVFSFILE hVfsFile);
|
---|
502 | RTDECL(RTFOFF) RTVfsFilePoll(RTVFSFILE hVfsFile, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
|
---|
503 | uint32_t *pfRetEvents);
|
---|
504 | RTDECL(RTFOFF) RTVfsFileTell(RTVFSFILE hVfsFile);
|
---|
505 |
|
---|
506 | RTDECL(int) RTVfsFileSeek(RTVFSFILE hVfsFile, RTFOFF offSeek, uint32_t uMethod, uint64_t *poffActual);
|
---|
507 | RTDECL(int) RTVfsFileSetSize(RTVFSFILE hVfsFile, uint64_t cbSize);
|
---|
508 | RTDECL(int) RTVfsFileGetSize(RTVFSFILE hVfsFile, uint64_t *pcbSize);
|
---|
509 | RTDECL(RTFOFF) RTVfsFileGetMaxSize(RTVFSFILE hVfsFile);
|
---|
510 | RTDECL(int) RTVfsFileGetMaxSizeEx(RTVFSFILE hVfsFile, PRTFOFF pcbMax);
|
---|
511 |
|
---|
512 | /** @} */
|
---|
513 |
|
---|
514 |
|
---|
515 | /** @defgroup grp_rt_vfs_chain VFS Chains
|
---|
516 | *
|
---|
517 | * VFS chains is for doing pipe like things with VFS objects from the command
|
---|
518 | * line. Imagine you want to cat the readme.gz of an ISO you could do
|
---|
519 | * something like:
|
---|
520 | * RTCat :iprtvfs:vfs(isofs,./mycd.iso)|ios(open,readme.gz)|ios(gunzip)
|
---|
521 | * or
|
---|
522 | * RTCat :iprtvfs:ios(isofs,./mycd.iso,/readme.gz)|ios(gunzip)
|
---|
523 | *
|
---|
524 | * The "isofs", "open" and "gunzip" bits in the above examples are chain
|
---|
525 | * element providers registered with IPRT. See RTVFSCHAINELEMENTREG for how
|
---|
526 | * these works.
|
---|
527 | *
|
---|
528 | * @{ */
|
---|
529 |
|
---|
530 | /** The path prefix used to identify an VFS chain specification. */
|
---|
531 | #define RTVFSCHAIN_SPEC_PREFIX ":iprtvfs:"
|
---|
532 |
|
---|
533 | RTDECL(int) RTVfsChainOpenVfs( const char *pszSpec, PRTVFS phVfs, const char **ppszError);
|
---|
534 | RTDECL(int) RTVfsChainOpenFsStream( const char *pszSpec, PRTVFSFSSTREAM phVfsFss, const char **ppszError);
|
---|
535 | RTDECL(int) RTVfsChainOpenDir( const char *pszSpec, uint32_t fOpen, PRTVFSDIR phVfsDir, const char **ppszError);
|
---|
536 | RTDECL(int) RTVfsChainOpenFile( const char *pszSpec, uint32_t fOpen, PRTVFSFILE phVfsFile, const char **ppszError);
|
---|
537 | RTDECL(int) RTVfsChainOpenSymlink( const char *pszSpec, PRTVFSSYMLINK phVfsSym, const char **ppszError);
|
---|
538 | RTDECL(int) RTVfsChainOpenIoStream( const char *pszSpec, uint32_t fOpen, PRTVFSIOSTREAM phVfsIos, const char **ppszError);
|
---|
539 |
|
---|
540 | /**
|
---|
541 | * Tests if the given string is a chain specification or not.
|
---|
542 | *
|
---|
543 | * @returns true if it is, false if it isn't.
|
---|
544 | * @param pszSpec The alleged chain spec.
|
---|
545 | */
|
---|
546 | RTDECL(bool) RTVfsChainIsSpec(const char *pszSpec);
|
---|
547 |
|
---|
548 | /** @} */
|
---|
549 |
|
---|
550 |
|
---|
551 | /** @} */
|
---|
552 |
|
---|
553 | RT_C_DECLS_END
|
---|
554 |
|
---|
555 | #endif /* !___iprt_vfs_h */
|
---|
556 |
|
---|
557 |
|
---|