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