VirtualBox

Changeset 33859 in vbox for trunk/include


Ignore:
Timestamp:
Nov 8, 2010 4:15:07 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67505
Message:

iprt/vfs: more code.

Location:
trunk/include/iprt
Files:
2 edited

Legend:

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

    r33822 r33859  
    120120                                       char *pszMountPoint, size_t cbMountPoint);
    121121
     122
    122123/** @defgroup grp_vfs_dir           VFS Directory API
    123124 * @{
    124125 */
     126
     127/**
     128 * Retains a reference to the VFS directory handle.
     129 *
     130 * @returns New reference count on success, UINT32_MAX on failure.
     131 * @param   hVfsDir         The VFS directory handle.
     132 */
     133RTDECL(uint32_t)    RTVfsDirRetain(RTVFSDIR hVfsDir);
     134
     135/**
     136 * Releases a reference to the VFS directory handle.
     137 *
     138 * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
     139 * @param   hVfsIos         The VFS directory handle.
     140 */
     141RTDECL(uint32_t)    RTVfsDirRelease(RTVFSDIR hVfsDir);
     142
    125143/** @}  */
    126144
    127145
    128 /** @defgroup grp_vfs_iostream      VFS I/O Stream
     146/** @defgroup grp_vfs_iostream      VFS Symbolic Link API
     147 * @{
     148 */
     149
     150/**
     151 * Read the symbolic link target.
     152 *
     153 * @returns IPRT status code.
     154 * @param   hVfsSym         The VFS symbolic link handle.
     155 * @param   pszTarget       The target buffer.
     156 * @param   cbTarget        The size of the target buffer.
     157 * @sa      RTSymlinkRead
     158 */
     159RTDECL(int)         RTVfsSymlinkRead(RTVFSSYMLINK hVfsSym, char *pszTarget, size_t cbTarget);
     160
     161/** @}  */
     162
     163
     164
     165/** @defgroup grp_vfs_iostream      VFS I/O Stream API
    129166 * @{
    130167 */
     
    264301 */
    265302RTDECL(RTFOFF)      RTVfsIoStrmTell(RTVFSIOSTREAM hVfsIos);
     303
     304/**
     305 * Skips @a cb ahead in the stream.
     306 *
     307 * @returns IPRT status code.
     308 * @param   hVfsIos         The VFS I/O stream handle.
     309 * @param   cb              The number bytes to skip.
     310 */
     311RTDECL(int)         RTVfsIoStrmSkip(RTVFSIOSTREAM hVfsIos, RTFOFF cb);
     312
     313/**
     314 * Fills the stream with @a cb zeros.
     315 *
     316 * @returns IPRT status code.
     317 * @param   hVfsIos         The VFS I/O stream handle.
     318 * @param   cb              The number of zero bytes to insert.
     319 */
     320RTDECL(int)         RTVfsIoStrmZeroFill(RTVFSIOSTREAM hVfsIos, RTFOFF cb);
    266321/** @} */
    267322
  • trunk/include/iprt/vfslowlevel.h

    r33822 r33859  
    2828
    2929#include <iprt/vfs.h>
     30#include <iprt/param.h>
    3031
    3132
     
    8788} RTVFSOPS;
    8889/** Pointer to constant VFS operations. */
    89 typedef RTVFSOPS const PCRTVFSOPS;
     90typedef RTVFSOPS const *PCRTVFSOPS;
    9091
    9192/** The RTVFSOPS structure version. */
     
    112113    /** File. */
    113114    RTVFSOBJTYPE_FILE,
     115    /** Symbolic link. */
     116    RTVFSOBJTYPE_SYMLINK,
    114117    /** End of valid object types. */
    115118    RTVFSOBJTYPE_END,
     
    242245
    243246    /**
     247     * Opens a directory entry for traversal purposes.
     248     *
     249     * Method which sole purpose is helping the path traversal.  Only one of
     250     * the three output variables will be set, the others will left untouched
     251     * (caller sets them to NIL).
     252     *
     253     * @returns IPRT status code.
     254     * @retval  VERR_PATH_NOT_FOUND if @a pszEntry was not found.
     255     * @param   pvThis          The implementation specific directory data.
     256     * @param   pszEntry        The name of the directory entry to remove.
     257     * @param   phVfsDir        If not NULL and it is a directory, open it and
     258     *                          return the handle here.
     259     * @param   phVfsSymlink    If not NULL and it is a symbolic link, open it
     260     *                          and return the handle here.
     261     * @param   phVfsMounted    If not NULL and it is a mounted VFS directory,
     262     *                          reference it and return the handle here.
     263     * @todo    Should com dir, symlinks and mount points using some common
     264     *          ancestor "class".
     265     */
     266    DECLCALLBACKMEMBER(int, pfnTraversalOpen)(void *pvThis, const char *pszEntry, PRTVFSDIR phVfsDir,
     267                                              PRTVFSSYMLINK phVfsSymlink, PRTVFS phVfsMounted);
     268
     269    /**
    244270     * Open or create a file.
    245271     *
     
    347373/** The RTVFSDIROPS structure version. */
    348374#define RTVFSDIROPS_VERSION         RT_MAKE_U32_FROM_U8(0xff,0x3f,1,0)
     375
     376
     377/**
     378 * The symbolic link operations.
     379 *
     380 * @extends RTVFSOBJOPS
     381 * @extends RTVFSOBJSETOPS
     382 */
     383typedef struct RTVFSSYMLINKOPS
     384{
     385    /** The basic object operation.  */
     386    RTVFSOBJOPS             Obj;
     387    /** The structure version (RTVFSSYMLINKOPS_VERSION). */
     388    uint32_t                uVersion;
     389    /** Reserved field, MBZ. */
     390    uint32_t                fReserved;
     391    /** The object setter operations. */
     392    RTVFSOBJSETOPS          ObjSet;
     393
     394    /**
     395     * Read the symbolic link target.
     396     *
     397     * @returns IPRT status code.
     398     * @param   pvThis      The implementation specific symbolic link data.
     399     * @param   pszTarget   The target buffer.
     400     * @param   cbTarget    The size of the target buffer.
     401     * @sa      RTSymlinkRead
     402     */
     403    DECLCALLBACKMEMBER(int, pfnRead)(void *pvThis, char *pszTarget, size_t cbTarget);
     404
     405    /** Marks the end of the structure (RTVFSSYMLINKOPS_VERSION). */
     406    uintptr_t               uEndMarker;
     407} RTVFSSYMLINKOPS;
     408/** Pointer to const symbolic link operations. */
     409typedef RTVFSSYMLINKOPS const *PCRTVFSSYMLINKOPS;
     410/** The RTVFSSYMLINKOPS structure version. */
     411#define RTVFSSYMLINKOPS_VERSION     RT_MAKE_U32_FROM_U8(0xff,0x4f,1,0)
    349412
    350413
     
    432495    DECLCALLBACKMEMBER(int, pfnTell)(void *pvThis, PRTFOFF poffActual);
    433496
     497    /**
     498     * Skips @a cb ahead in the stream.
     499     *
     500     * @returns IPRT status code.
     501     * @param   pvThis      The implementation specific file data.
     502     * @param   cb          The number bytes to skip.
     503     * @remarks This is optional and can be NULL.
     504     */
     505    DECLCALLBACKMEMBER(int, pfnSkip)(void *pvThis, RTFOFF cb);
     506
     507    /**
     508     * Fills the stream with @a cb zeros.
     509     *
     510     * @returns IPRT status code.
     511     * @param   pvThis      The implementation specific file data.
     512     * @param   cb          The number of zero bytes to insert.
     513     * @remarks This is optional and can be NULL.
     514     */
     515    DECLCALLBACKMEMBER(int, pfnZeroFill)(void *pvThis, RTFOFF cb);
     516
    434517    /** Marks the end of the structure (RTVFSIOSTREAMOPS_VERSION). */
    435518    uintptr_t               uEndMarker;
     
    439522
    440523/** The RTVFSIOSTREAMOPS structure version. */
    441 #define RTVFSIOSTREAMOPS_VERSION    RT_MAKE_U32_FROM_U8(0xff,0x4f,1,0)
     524#define RTVFSIOSTREAMOPS_VERSION    RT_MAKE_U32_FROM_U8(0xff,0x5f,1,0)
    442525
    443526
     
    490573
    491574/** The RTVFSFILEOPS structure version. */
    492 #define RTVFSFILEOPS_VERSION        RT_MAKE_U32_FROM_U8(0xff,0x5f,1,0)
     575#define RTVFSFILEOPS_VERSION        RT_MAKE_U32_FROM_U8(0xff,0x6f,1,0)
    493576
    494577/**
     
    509592
    510593
     594/** @defgroup grp_rt_vfs_ll_util        VFS Utility APIs
     595 * @{ */
     596
     597/**
     598 * Parsed path.
     599 */
     600typedef struct RTVFSPARSEDPATH
     601{
     602    /** The length of the path in szCopy. */
     603    uint16_t        cch;
     604    /** The number of path components. */
     605    uint16_t        cComponents;
     606    /** Set if the path ends with slash, indicating that it's a directory
     607     * reference and not a file reference.  The slash has been removed from
     608     * the copy. */
     609    bool            fDirSlash;
     610    /** The offset where each path component starts, i.e. the char after the
     611     * slash.  The array has cComponents + 1 entries, where the final one is
     612     * cch + 1 so that one can always terminate the current component by
     613     * szPath[aoffComponent[i] - 1] = '\0'. */
     614    uint16_t        aoffComponents[RTPATH_MAX / 2 + 1];
     615    /** A normalized copy of the path.
     616     * Reserve some extra space so we can be more relaxed about overflow
     617     * checks and terminator paddings, especially when recursing. */
     618    char            szPath[RTPATH_MAX];
     619} RTVFSPARSEDPATH;
     620/** Pointer to a parsed path. */
     621typedef RTVFSPARSEDPATH *PRTVFSPARSEDPATH;
     622
     623/** The max accepted path length.
     624 * This must be a few chars shorter than RTVFSPARSEDPATH::szPath because we
     625 * use two terminators and wish be a little bit lazy with checking. */
     626#define RTVFSPARSEDPATH_MAX     (RTPATH_MAX - 4U)
     627
     628/**
     629 * Appends @a pszPath (relative) to the already parsed path @a pPath.
     630 *
     631 * @retval  VINF_SUCCESS
     632 * @retval  VERR_FILENAME_TOO_LONG
     633 * @retval  VERR_INTERNAL_ERROR_4
     634 * @param   pPath               The parsed path to append @a pszPath onto.
     635 *                              This is both input and output.
     636 * @param   pszPath             The path to append.  This must be relative.
     637 * @param   piRestartComp       The component to restart parsing at.  This is
     638 *                              input/output.  The input does not have to be
     639 *                              within the valid range.  Optional.
     640 */
     641RTDECL(int) RTVfsParsePathAppend(PRTVFSPARSEDPATH pPath, const char *pszPath, uint16_t *piRestartComp);
     642
     643/**
     644 * Parses a path.
     645 *
     646 * @retval  VINF_SUCCESS
     647 * @retval  VERR_FILENAME_TOO_LONG
     648 * @param   pPath               Where to store the parsed path.
     649 * @param   pszPath             The path to parse.  Absolute or relative to @a
     650 *                              pszCwd.
     651 * @param   pszCwd              The current working directory.  Must be
     652 *                              absolute.
     653 */
     654RTDECL(int) RTVfsParsePath(PRTVFSPARSEDPATH pPath, const char *pszPath, const char *pszCwd);
     655
     656/**
     657 * Same as RTVfsParsePath except that it allocates a temporary buffer.
     658 *
     659 * @retval  VINF_SUCCESS
     660 * @retval  VERR_NO_TMP_MEMORY
     661 * @retval  VERR_FILENAME_TOO_LONG
     662 * @param   pszPath             The path to parse.  Absolute or relative to @a
     663 *                              pszCwd.
     664 * @param   pszCwd              The current working directory.  Must be
     665 *                              absolute.
     666 * @param   ppPath              Where to store the pointer to the allocated
     667 *                              buffer containing the parsed path.  This must
     668 *                              be freed by calling RTVfsParsePathFree.  NULL
     669 *                              will be stored on failured.
     670 */
     671RTDECL(int) RTVfsParsePathA(const char *pszPath, const char *pszCwd, PRTVFSPARSEDPATH *ppPath);
     672
     673/**
     674 * Frees a buffer returned by RTVfsParsePathA.
     675 *
     676 * @param   pPath               The parsed path buffer to free.  NULL is fine.
     677 */
     678RTDECL(void) RTVfsParsePathFree(PRTVFSPARSEDPATH pPath);
     679
     680/** @}  */
     681
    511682/** @} */
    512683
Note: See TracChangeset for help on using the changeset viewer.

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