VirtualBox

Changeset 33973 in vbox for trunk/include/iprt/vfs.h


Ignore:
Timestamp:
Nov 11, 2010 11:10:10 AM (14 years ago)
Author:
vboxsync
Message:

vfs: the gunzip stream works, except for some double frees somewhere.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/vfs.h

    r33948 r33973  
    3131#include <iprt/dir.h>
    3232#include <iprt/fs.h>
     33#include <iprt/handle.h>
    3334#include <iprt/symlink.h>
    3435#include <iprt/sg.h>
     
    5657 * @{
    5758 */
    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)
    10759
    10860/**
     
    13991
    14092
    141 
    14293/** @name RTVfsCreate flags
    14394 * @{ */
     
    293244
    294245/**
     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 */
     256RTDECL(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 */
     269RTDECL(int)         RTVfsIoStrmFromStdHandle(RTHANDLESTD enmStdHandle, uint32_t fOpen, bool fLeaveOpen,
     270                                             PRTVFSIOSTREAM phVfsIos);
     271
     272/**
    295273 * Retains a reference to the VFS I/O stream handle.
    296274 *
     
    316294 * @sa      RTVfsFileToIoStream
    317295 */
    318 RTDECL(RTVFSFILE)   RTVfsIoStrmToFile(RTVFSIOSTREAM hVfsIos);
     296RTDECL(RTVFSFILE) RTVfsIoStrmToFile(RTVFSIOSTREAM hVfsIos);
    319297
    320298/**
     
    327305 * @sa      RTFileQueryInfo
    328306 */
    329 RTDECL(int)         RTVfsIoStrmQueryInfo(RTVFSIOSTREAM hVfsIos, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
     307RTDECL(int) RTVfsIoStrmQueryInfo(RTVFSIOSTREAM hVfsIos, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
    330308
    331309/**
    332310 * Read bytes from the I/O stream.
    333  *
    334  * @returns IPRT status code.
    335  * @param   hVfsIos         The VFS I/O stream handle.
    336  * @param   pvBuf           Where to store the read bytes.
    337  * @param   cbToRead        The number of bytes to read.
    338  * @param   pcbRead         Where to always store the number of bytes actually
    339  *                          read.  If this is NULL, the call will block until
    340  *                          @a cbToRead bytes are available.  If this is
    341  *                          non-NULL, the call will not block and return what
    342  *                          is currently avaiable.
    343  * @sa      RTFileRead, RTPipeRead, RTPipeReadBlocking, RTSocketRead
    344  */
    345 RTDECL(int)         RTVfsIoStrmRead(RTVFSIOSTREAM hVfsIos, void *pvBuf, size_t cbToRead, size_t *pcbRead);
    346 
    347 /**
    348  * Write bytes to the I/O stream.
    349  *
    350  * @returns IPRT status code.
    351  * @param   hVfsIos         The VFS I/O stream handle.
    352  * @param   pvBuf           The bytes to write.
    353  * @param   cbToWrite       The number of bytes to write.
    354  * @param   pcbWritten      Where to always store the number of bytes actually
    355  *                          written.  If this is NULL, the call will block
    356  *                          until
    357  *                          @a cbToWrite bytes are available.  If this is
    358  *                          non-NULL, the call will not block and return after
    359  *                          writing what is possible.
    360  * @sa      RTFileWrite, RTPipeWrite, RTPipeWriteBlocking, RTSocketWrite
    361  */
    362 RTDECL(int)         RTVfsIoStrmWrite(RTVFSIOSTREAM hVfsIos, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
    363 
    364 /**
    365  * Reads bytes from the I/O stream into a scatter buffer.
    366311 *
    367312 * @returns IPRT status code.
     
    380325 *
    381326 * @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 */
     335RTDECL(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 */
     350RTDECL(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.
    382370 * @param   pSgBuf          Pointer to a scatter buffer descriptor.  The number
    383371 *                          of bytes described by the segments is what will be
     
    550538RTDECL(int) RTVfsChainOpenIoStream( const char *pszSpec, uint32_t fOpen, PRTVFSIOSTREAM  phVfsIos,  const char **ppszError);
    551539
     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 */
     546RTDECL(bool)    RTVfsChainIsSpec(const char *pszSpec);
     547
    552548/** @}  */
    553549
Note: See TracChangeset for help on using the changeset viewer.

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