4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** @file
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * IPRT - Virtual Filesystem.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/*
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Copyright (C) 2010-2012 Oracle Corporation
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync *
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * available from http://www.virtualbox.org. This file is free software;
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * General Public License (GPL) as published by the Free Software
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync *
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * The contents of this file may alternatively be used under the terms
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * of the Common Development and Distribution License Version 1.0
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * VirtualBox OSE distribution, in which case the provisions of the
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * CDDL are applicable instead of those of the GPL.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync *
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * You may elect to license modified versions of this file under the
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * terms and conditions of either the GPL or the CDDL or both.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#ifndef ___iprt_vfs_h
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#define ___iprt_vfs_h
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#include <iprt/cdefs.h>
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#include <iprt/types.h>
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#include <iprt/dir.h>
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#include <iprt/fs.h>
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync#include <iprt/handle.h>
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#include <iprt/symlink.h>
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#include <iprt/sg.h>
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#include <iprt/time.h>
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRT_C_DECLS_BEGIN
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
8f2d4fea58e2d827a8269d0c96d307217b5ab14dvboxsync/** @defgroup grp_rt_vfs RTVfs - Virtual Filesystem
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @ingroup grp_rt
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * The virtual filesystem APIs are intended to make it possible to work on
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * container files, file system sub-trees, file system overlays and other custom
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * filesystem configurations. It also makes it possible to create filters, like
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * automatically gunzipping a tar.gz file before feeding it to the RTTar API for
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * unpacking - or wise versa.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * The virtual filesystem APIs are intended to mirror the RTDir, RTFile, RTPath
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * and RTFs APIs pretty closely so that rewriting a piece of code to work with
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * it should be easy. However there are some differences to the way the APIs
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * works and the user should heed the documentation. The differences are
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * usually motivated by simplification and in some case to make the VFS more
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * flexible.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @{
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync/**
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * The object type.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsynctypedef enum RTVFSOBJTYPE
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync{
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync /** Invalid type. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync RTVFSOBJTYPE_INVALID = 0,
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync /** Pure base object.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * This is returned by the filesystem stream to represent directories,
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * devices, fifos and similar that needs to be created. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync RTVFSOBJTYPE_BASE,
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync /** Virtual filesystem. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync RTVFSOBJTYPE_VFS,
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync /** Filesystem stream. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync RTVFSOBJTYPE_FS_STREAM,
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync /** Pure I/O stream. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync RTVFSOBJTYPE_IO_STREAM,
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync /** Directory. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync RTVFSOBJTYPE_DIR,
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync /** File. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync RTVFSOBJTYPE_FILE,
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync /** Symbolic link. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync RTVFSOBJTYPE_SYMLINK,
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync /** End of valid object types. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync RTVFSOBJTYPE_END,
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync /** Pure I/O stream. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync RTVFSOBJTYPE_32BIT_HACK = 0x7fffffff
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync} RTVFSOBJTYPE;
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync/** Pointer to a VFS object type. */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsynctypedef RTVFSOBJTYPE *PRTVFSOBJTYPE;
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** @name RTVfsCreate flags
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @{ */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** Whether the file system is read-only. */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#define RTVFS_C_READONLY RT_BIT(0)
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** Whether we the VFS should be thread safe (i.e. automaticaly employ
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * locks). */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#define RTVFS_C_THREAD_SAFE RT_BIT(1)
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** @} */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/**
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * Creates an empty virtual filesystem.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync *
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @returns IPRT status code.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @param pszName Name, for logging and such.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @param fFlags Flags, MBZ.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @param phVfs Where to return the VFS handle. Release the returned
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * reference by calling RTVfsRelease.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsCreate(const char *pszName, uint32_t fFlags, PRTVFS phVfs);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(uint32_t) RTVfsRetain(RTVFS phVfs);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(uint32_t) RTVfsRelease(RTVFS phVfs);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsAttach(RTVFS hVfs, const char *pszMountPoint, uint32_t fFlags, RTVFS hVfsAttach);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsDetach(RTVFS hVfs, const char *pszMountPoint, RTVFS hVfsToDetach, PRTVFS *phVfsDetached);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(uint32_t) RTVfsGetAttachmentCount(RTVFS hVfs);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsGetAttachment(RTVFS hVfs, uint32_t iOrdinal, PRTVFS *phVfsAttached, uint32_t *pfFlags,
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync char *pszMountPoint, size_t cbMountPoint);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync/**
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync * Checks whether a given range is in use by the virtual filesystem.
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync *
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync * @returns IPRT status code.
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync * @param hVfs VFS handle.
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync * @param off Start offset to check.
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync * @param cb Number of bytes to check.
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync * @param pfUsed Where to store the result.
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync */
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsyncRTDECL(int) RTVfsIsRangeInUse(RTVFS hVfs, uint64_t off, size_t cb,
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync bool *pfUsed);
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
c1d279fc0865b91a40b30eda02ed14f6533fe1a4vboxsync/** @defgroup grp_vfs_obj VFS Base Object API
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * @{
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Retains a reference to the VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns New reference count on success, UINT32_MAX on failure.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsObj The VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
43af8389304c77c3d4db525de8907cb74207c380vboxsyncRTDECL(uint32_t) RTVfsObjRetain(RTVFSOBJ hVfsObj);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Releases a reference to the VFS base handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsObj The VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
43af8389304c77c3d4db525de8907cb74207c380vboxsyncRTDECL(uint32_t) RTVfsObjRelease(RTVFSOBJ hVfsObj);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Query information about the object.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns IPRT status code.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @retval VERR_NOT_SUPPORTED if the @a enmAddAttr value is not handled by the
43af8389304c77c3d4db525de8907cb74207c380vboxsync * implementation.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsObj The VFS object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param pObjInfo Where to return the info.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param enmAddAttr Which additional attributes should be retrieved.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTVfsIoStrmQueryInfo, RTVfsFileQueryInfo, RTFileQueryInfo,
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * RTPathQueryInfo
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
43af8389304c77c3d4db525de8907cb74207c380vboxsyncRTDECL(int) RTVfsObjQueryInfo(RTVFSOBJ hVfsObj, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS base object handle to a VFS handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL on failure.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsObj The VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFS) RTVfsObjToVfs(RTVFSOBJ hVfsObj);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS base object handle to a VFS filesystem stream handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL on failure.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsObj The VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFSFSSTREAM) RTVfsObjToFsStream(RTVFSOBJ hVfsObj);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS base object handle to a VFS directory handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL on failure.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsObj The VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFSDIR) RTVfsObjToDir(RTVFSOBJ hVfsObj);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS base object handle to a VFS I/O stream handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL on failure.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsObj The VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFSIOSTREAM) RTVfsObjToIoStream(RTVFSOBJ hVfsObj);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS base object handle to a VFS file handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL on failure.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsObj The VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFSFILE) RTVfsObjToFile(RTVFSOBJ hVfsObj);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS base object handle to a VFS symbolic link handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL on failure.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsObj The VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFSSYMLINK) RTVfsObjToSymlink(RTVFSOBJ hVfsObj);
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS handle to a VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL if the input handle was invalid.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfs The VFS handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFSOBJ) RTVfsObjFromVfs(RTVFS hVfs);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS filesystem stream handle to a VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL if the input handle was invalid.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsFSs The VFS filesystem stream handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFSOBJ) RTVfsObjFromFsStream(RTVFSFSSTREAM hVfsFss);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS directory handle to a VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL if the input handle was invalid.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsDir The VFS directory handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFSOBJ) RTVfsObjFromDir(RTVFSDIR hVfsDir);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS I/O stream handle to a VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL if the input handle was invalid.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsIos The VFS I/O stream handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFSOBJ) RTVfsObjFromIoStream(RTVFSIOSTREAM hVfsIos);
43af8389304c77c3d4db525de8907cb74207c380vboxsync
43af8389304c77c3d4db525de8907cb74207c380vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS file handle to a VFS base object handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL if the input handle was invalid.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsFile The VFS file handle.
43af8389304c77c3d4db525de8907cb74207c380vboxsync */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(RTVFSOBJ) RTVfsObjFromFile(RTVFSFILE hVfsFile);
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync/**
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Converts a VFS symbolic link handle to a VFS base object handle.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync *
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns Referenced handle on success, NIL if the input handle was invalid.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param hVfsSym The VFS symbolic link handle.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync */
43af8389304c77c3d4db525de8907cb74207c380vboxsyncRTDECL(RTVFSOBJ) RTVfsObjFromSymlink(RTVFSSYMLINK hVfsSym);
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync/** @} */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync/** @defgroup grp_vfs_fsstream VFS Filesystem Stream API
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync *
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * Filesystem streams are for tar, cpio and similar. Any virtual filesystem can
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * be turned into a filesystem stream using RTVfsFsStrmFromVfs.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync *
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * @{
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsyncRTDECL(uint32_t) RTVfsFsStrmRetain(RTVFSFSSTREAM hVfsFss);
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsyncRTDECL(uint32_t) RTVfsFsStrmRelease(RTVFSFSSTREAM hVfsFss);
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsyncRTDECL(int) RTVfsFsStrmQueryInfo(RTVFSFSSTREAM hVfsFss, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync/**
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * Gets the next object in the stream.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync *
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * This call may affect the stream posision of a previously returned object.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync *
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * The type of object returned here typically boils down to three types:
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * - I/O streams (representing files),
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * - symbolic links
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * - base object
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * The base objects represent anything not convered by the two other, i.e.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * directories, device nodes, fifos, sockets and whatnot. The details can be
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * queried using RTVfsObjQueryInfo.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync *
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * That said, absolutely any object except for filesystem stream objects can be
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * returned by this call. Any generic code is adviced to just deal with it all.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync *
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * @returns IPRT status code.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * @retval VINF_SUCCESS if a new object was retrieved.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * @retval VERR_EOF when there are no more objects.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * @param pvThis The implementation specific directory data.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * @param ppszName Where to return the object name. Must be freed by
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * calling RTStrFree.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * @param penmType Where to return the object type.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * @param hVfsObj Where to return the object handle (referenced).
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync * This must be cast to the desired type before use.
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsyncRTDECL(int) RTVfsFsStrmNext(RTVFSFSSTREAM hVfsFss, char **ppszName, RTVFSOBJTYPE *penmType, PRTVFSOBJ phVfsObj);
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync/** @} */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** @defgroup grp_vfs_dir VFS Directory API
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @{
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync/**
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * Retains a reference to the VFS directory handle.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync *
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @returns New reference count on success, UINT32_MAX on failure.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @param hVfsDir The VFS directory handle.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync */
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsyncRTDECL(uint32_t) RTVfsDirRetain(RTVFSDIR hVfsDir);
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync/**
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * Releases a reference to the VFS directory handle.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync *
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @param hVfsIos The VFS directory handle.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync */
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsyncRTDECL(uint32_t) RTVfsDirRelease(RTVFSDIR hVfsDir);
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync/** @} */
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
7e91bade293bb7d3de7f9c4710f89fbed6ec648bvboxsync/** @defgroup grp_vfs_symlink VFS Symbolic Link API
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @remarks The TAR VFS and filesystem stream uses symbolic links for
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * describing hard links as well. The users must use RTFS_IS_SYMLINK
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * to check if it is a real symlink in those cases.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @remarks Any VFS which is backed by a real file system may be subject to
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * races with other processes or threads, so the user may get
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * unexpected errors when this happends. This is a bit host specific,
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * i.e. it might be prevent on windows if we care.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @{
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync */
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync/**
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * Retains a reference to the VFS symbolic link handle.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @returns New reference count on success, UINT32_MAX on failure.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param hVfsSym The VFS symbolic link handle.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsyncRTDECL(uint32_t) RTVfsSymlinkRetain(RTVFSSYMLINK hVfsSym);
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync/**
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * Releases a reference to the VFS symbolic link handle.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param hVfsSym The VFS symbolic link handle.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync */
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsyncRTDECL(uint32_t) RTVfsSymlinkRelease(RTVFSSYMLINK hVfsSym);
f6f1d32779a2a6a1a4579c3bf6ff3aa0c37f0823vboxsync
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync/**
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * Query information about the symbolic link.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @returns IPRT status code.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param hVfsSym The VFS symbolic link handle.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param pObjInfo Where to return the info.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param enmAddAttr Which additional attributes should be retrieved.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @sa RTFileQueryInfo, RTPathQueryInfo, RTPathQueryInfoEx
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync */
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsyncRTDECL(int) RTVfsSymlinkQueryInfo(RTVFSSYMLINK hVfsSym, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync/**
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * Set the unix style owner and group.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @returns IPRT status code.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param hVfsSym The VFS symbolic link handle.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param fMode The new mode bits.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param fMask The mask indicating which bits we are changing.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @sa RTFileSetMode, RTPathSetMode
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync */
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsyncRTDECL(int) RTVfsSymlinkSetMode(RTVFSSYMLINK hVfsSym, RTFMODE fMode, RTFMODE fMask);
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync/**
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * Set the timestamps associated with the object.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @returns IPRT status code.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param hVfsSym The VFS symbolic link handle.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param pAccessTime Pointer to the new access time. NULL if not
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * to be changed.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param pModificationTime Pointer to the new modifcation time. NULL if
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * not to be changed.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param pChangeTime Pointer to the new change time. NULL if not to be
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * changed.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param pBirthTime Pointer to the new time of birth. NULL if not to be
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * changed.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @remarks See RTFileSetTimes for restrictions and behavior imposed by the
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * host OS or underlying VFS provider.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @sa RTFileSetTimes, RTPathSetTimes
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync */
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsyncRTDECL(int) RTVfsSymlinkSetTimes(RTVFSSYMLINK hVfsSym, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime);
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync/**
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * Set the unix style owner and group.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @returns IPRT status code.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param hVfsSym The VFS symbolic link handle.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param uid The user ID of the new owner. NIL_RTUID if
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * unchanged.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param gid The group ID of the new owner group. NIL_RTGID if
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * unchanged.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @sa RTFileSetOwner, RTPathSetOwner.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync */
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsyncRTDECL(int) RTVfsSymlinkSetOwner(RTVFSSYMLINK hVfsSym, RTUID uid, RTGID gid);
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync/**
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * Read the symbolic link target.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync *
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @returns IPRT status code.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @param hVfsSym The VFS symbolic link handle.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @param pszTarget The target buffer.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @param cbTarget The size of the target buffer.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @sa RTSymlinkRead
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync */
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsyncRTDECL(int) RTVfsSymlinkRead(RTVFSSYMLINK hVfsSym, char *pszTarget, size_t cbTarget);
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** @} */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync/** @defgroup grp_vfs_iostream VFS I/O Stream API
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @{
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync/**
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * Create a VFS I/O stream handle from a standard IPRT file handle (RTFILE).
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync *
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @returns IPRT status code.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param hFile The standard IPRT file handle.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param fOpen The flags the handle was opened with. Pass 0 to
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * have these detected.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param fLeaveOpen Whether to leave the handle open when the VFS file
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * is released, or to close it (@c false).
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param phVfsIos Where to return the VFS I/O stream handle.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync */
dc0a54940789f994c84390cb4a9f03da0b492285vboxsyncRTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos);
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync/**
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * Convenience function combining RTFileOpen with RTVfsIoStrmFromRTFile.
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync *
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * @returns IPRT status code.
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * @param pszFilename The path to the file in the normal file system.
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * @param fOpen The flags to pass to RTFileOpen when opening the
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * file, i.e. RTFILE_O_XXX.
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * @param phVfsIos Where to return the VFS I/O stream handle.
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync */
2a097016483d82de3da35c65da5afb5da7f9740fvboxsyncRTDECL(int) RTVfsIoStrmOpenNormal(const char *pszFilename, uint64_t fOpen, PRTVFSIOSTREAM phVfsIos);
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync/**
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * Create a VFS I/O stream handle from one of the standard handles.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync *
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @returns IPRT status code.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param enmStdHandle The standard IPRT file handle.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param fOpen The flags the handle was opened with. Pass 0 to
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * have these detected.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param fLeaveOpen Whether to leave the handle open when the VFS file
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * is released, or to close it (@c false).
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param phVfsIos Where to return the VFS I/O stream handle.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync */
dc0a54940789f994c84390cb4a9f03da0b492285vboxsyncRTDECL(int) RTVfsIoStrmFromStdHandle(RTHANDLESTD enmStdHandle, uint64_t fOpen, bool fLeaveOpen,
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync PRTVFSIOSTREAM phVfsIos);
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Retains a reference to the VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns New reference count on success, UINT32_MAX on failure.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(uint32_t) RTVfsIoStrmRetain(RTVFSIOSTREAM hVfsIos);
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Releases a reference to the VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(uint32_t) RTVfsIoStrmRelease(RTVFSIOSTREAM hVfsIos);
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Convert the VFS I/O stream handle to a VFS file handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns The VFS file handle on success, this must be released.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * NIL_RTVFSFILE if the I/O stream handle is invalid.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @sa RTVfsFileToIoStream
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
2e43d8b543c65b46f94084088524d5d16c62a021vboxsyncRTDECL(RTVFSFILE) RTVfsIoStrmToFile(RTVFSIOSTREAM hVfsIos);
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Query information about the I/O stream.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns IPRT status code.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param pObjInfo Where to return the info.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param enmAddAttr Which additional attributes should be retrieved.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @sa RTFileQueryInfo
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
2e43d8b543c65b46f94084088524d5d16c62a021vboxsyncRTDECL(int) RTVfsIoStrmQueryInfo(RTVFSIOSTREAM hVfsIos, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Read bytes from the I/O stream.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns IPRT status code.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @retval VINF_SUCCESS and the number of bytes read written to @a pcbRead.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @retval VINF_TRY_AGAIN if @a fBlocking is @c false, @a pcbRead is not NULL,
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * and no data was available. @a *pcbRead will be set to 0.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @retval VINF_EOF when trying to read __beyond__ the end of the stream and
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @a pcbRead is not NULL (it will be set to the number of bytes read,
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * or 0 if the end of the stream was reached before this call).
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * When the last byte of the read request is the last byte in the
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * stream, this status code will not be used. However, VINF_EOF is
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * returned when attempting to read 0 bytes while standing at the end
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * of the stream.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @retval VERR_EOF when trying to read __beyond__ the end of the stream and
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @a pcbRead is NULL.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @retval VERR_ACCESS_DENIED if the stream is not readable.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param pvBuf Where to store the read bytes.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param cbToRead The number of bytes to read.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param fBlocking Whether the call is blocking (@c true) or not. If
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * not, the @a pcbRead parameter must not be NULL.
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * @param pcbRead Where to always store the number of bytes actually
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * read. This can be NULL if @a fBlocking is true.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTVfsFileRead, RTFileRead, RTPipeRead, RTPipeReadBlocking,
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * RTSocketRead
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
2e43d8b543c65b46f94084088524d5d16c62a021vboxsyncRTDECL(int) RTVfsIoStrmRead(RTVFSIOSTREAM hVfsIos, void *pvBuf, size_t cbToRead, bool fBlocking, size_t *pcbRead);
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsyncRTDECL(int) RTVfsIoStrmReadAt(RTVFSIOSTREAM hVfsIos, RTFOFF off, void *pvBuf, size_t cbToRead, bool fBlocking, size_t *pcbRead);
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Write bytes to the I/O stream.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns IPRT status code.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @retval VERR_ACCESS_DENIED if the stream is not writable.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param pvBuf The bytes to write.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param cbToWrite The number of bytes to write.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param fBlocking Whether the call is blocking (@c true) or not. If
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * not, the @a pcbWritten parameter must not be NULL.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param pcbRead Where to always store the number of bytes actually
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * written. This can be NULL if @a fBlocking is true.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTVfsFileWrite, RTFileWrite, RTPipeWrite, RTPipeWriteBlocking,
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * RTSocketWrite
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
2e43d8b543c65b46f94084088524d5d16c62a021vboxsyncRTDECL(int) RTVfsIoStrmWrite(RTVFSIOSTREAM hVfsIos, const void *pvBuf, size_t cbToWrite, bool fBlocking, size_t *pcbWritten);
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsyncRTDECL(int) RTVfsIoStrmWriteAt(RTVFSIOSTREAM hVfsIos, RTFOFF off, const void *pvBuf, size_t cbToWrite, bool fBlocking, size_t *pcbWritten);
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Reads bytes from the I/O stream into a scatter buffer.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns IPRT status code.
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * @retval VINF_SUCCESS and the number of bytes read written to @a pcbRead.
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * @retval VINF_TRY_AGAIN if @a fBlocking is @c false, @a pcbRead is not NULL,
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * and no data was available. @a *pcbRead will be set to 0.
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * @retval VINF_EOF when trying to read __beyond__ the end of the stream and
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * @a pcbRead is not NULL (it will be set to the number of bytes read,
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * or 0 if the end of the stream was reached before this call).
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * When the last byte of the read request is the last byte in the
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * stream, this status code will not be used. However, VINF_EOF is
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * returned when attempting to read 0 bytes while standing at the end
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * of the stream.
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * @retval VERR_EOF when trying to read __beyond__ the end of the stream and
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * @a pcbRead is NULL.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @retval VERR_ACCESS_DENIED if the stream is not readable.
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param pSgBuf Pointer to a scatter buffer descriptor. The number
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * of bytes described by the segments is what will be
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * attemted read.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param fBlocking Whether the call is blocking (@c true) or not. If
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * not, the @a pcbRead parameter must not be NULL.
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * @param pcbRead Where to always store the number of bytes actually
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * read. This can be NULL if @a fBlocking is true.
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * @sa RTFileSgRead, RTSocketSgRead, RTPipeRead, RTPipeReadBlocking
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsyncRTDECL(int) RTVfsIoStrmSgRead(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead);
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Write bytes to the I/O stream from a gather buffer.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns IPRT status code.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @retval VERR_ACCESS_DENIED if the stream is not writable.
43af8389304c77c3d4db525de8907cb74207c380vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param pSgBuf Pointer to a gather buffer descriptor. The number
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * of bytes described by the segments is what will be
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * attemted written.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param fBlocking Whether the call is blocking (@c true) or not. If
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * not, the @a pcbWritten parameter must not be NULL.
ff74d28041a2179e652244a3f7b64d34c2dfc87avboxsync * @param pcbWritten Where to always store the number of bytes actually
667506dc4c739586cde5d4f245677ef5aac62ac2vboxsync * written. This can be NULL if @a fBlocking is true.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @sa RTFileSgWrite, RTSocketSgWrite
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsyncRTDECL(int) RTVfsIoStrmSgWrite(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten);
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Flush any buffered data to the I/O stream.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns IPRT status code.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTVfsFileFlush, RTFileFlush, RTPipeFlush
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsIoStrmFlush(RTVFSIOSTREAM hVfsIos);
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Poll for events.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns IPRT status code.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param fEvents The events to poll for (RTPOLL_EVT_XXX).
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param cMillies How long to wait for event to eventuate.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param fIntr Whether the wait is interruptible and can return
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * VERR_INTERRUPTED (@c true) or if this condition
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * should be hidden from the caller (@c false).
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param pfRetEvents Where to return the event mask.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTVfsFilePoll, RTPollSetAdd, RTPoll, RTPollNoResume.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
2e43d8b543c65b46f94084088524d5d16c62a021vboxsyncRTDECL(int) RTVfsIoStrmPoll(RTVFSIOSTREAM hVfsIos, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
2e43d8b543c65b46f94084088524d5d16c62a021vboxsync uint32_t *pfRetEvents);
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync/**
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * Tells the current I/O stream position.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync *
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @returns Zero or higher - where to return the I/O stream offset. Values
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * below zero are IPRT status codes (VERR_XXX).
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @param hVfsIos The VFS I/O stream handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @sa RTFileTell
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(RTFOFF) RTVfsIoStrmTell(RTVFSIOSTREAM hVfsIos);
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync/**
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * Skips @a cb ahead in the stream.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync *
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @returns IPRT status code.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @param hVfsIos The VFS I/O stream handle.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @param cb The number bytes to skip.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync */
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsyncRTDECL(int) RTVfsIoStrmSkip(RTVFSIOSTREAM hVfsIos, RTFOFF cb);
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync/**
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * Fills the stream with @a cb zeros.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync *
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @returns IPRT status code.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @param hVfsIos The VFS I/O stream handle.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync * @param cb The number of zero bytes to insert.
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync */
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsyncRTDECL(int) RTVfsIoStrmZeroFill(RTVFSIOSTREAM hVfsIos, RTFOFF cb);
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync/**
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * Checks if we're at the end of the I/O stream.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync *
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @returns true if at EOS, otherwise false.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync * @param hVfsIos The VFS I/O stream handle.
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsync */
0da79fbdac05db0541c03876955a4f95e222c6f2vboxsyncRTDECL(bool) RTVfsIoStrmIsAtEnd(RTVFSIOSTREAM hVfsIos);
2e43d8b543c65b46f94084088524d5d16c62a021vboxsync
2e43d8b543c65b46f94084088524d5d16c62a021vboxsync/**
2e43d8b543c65b46f94084088524d5d16c62a021vboxsync * Process the rest of the stream, checking if it's all valid UTF-8 encoding.
2e43d8b543c65b46f94084088524d5d16c62a021vboxsync *
2e43d8b543c65b46f94084088524d5d16c62a021vboxsync * @returns VBox status cod.e
2e43d8b543c65b46f94084088524d5d16c62a021vboxsync *
2e43d8b543c65b46f94084088524d5d16c62a021vboxsync * @param hVfsIos The VFS I/O stream handle.
327c02092b12a57e197999ca434b42fa3af51398vboxsync * @param fFlags Flags governing the validation, see
327c02092b12a57e197999ca434b42fa3af51398vboxsync * RTVFS_VALIDATE_UTF8_XXX.
327c02092b12a57e197999ca434b42fa3af51398vboxsync * @param poffError Where to return the error offset. Optional.
2e43d8b543c65b46f94084088524d5d16c62a021vboxsync */
327c02092b12a57e197999ca434b42fa3af51398vboxsyncRTDECL(int) RTVfsIoStrmValidateUtf8Encoding(RTVFSIOSTREAM hVfsIos, uint32_t fFlags, PRTFOFF poffError);
327c02092b12a57e197999ca434b42fa3af51398vboxsync
327c02092b12a57e197999ca434b42fa3af51398vboxsync/** @defgroup RTVFS_VALIDATE_UTF8_XXX RTVfsIoStrmValidateUtf8Encoding flags.
327c02092b12a57e197999ca434b42fa3af51398vboxsync * @{ */
327c02092b12a57e197999ca434b42fa3af51398vboxsync/** The text must not contain any null terminator codepoints. */
327c02092b12a57e197999ca434b42fa3af51398vboxsync#define RTVFS_VALIDATE_UTF8_NO_NULL RT_BIT_32(0)
327c02092b12a57e197999ca434b42fa3af51398vboxsync/** The codepoints must be in the range covered by RTC-3629. */
327c02092b12a57e197999ca434b42fa3af51398vboxsync#define RTVFS_VALIDATE_UTF8_BY_RTC_3629 RT_BIT_32(1)
327c02092b12a57e197999ca434b42fa3af51398vboxsync/** Mask of valid flags. */
327c02092b12a57e197999ca434b42fa3af51398vboxsync#define RTVFS_VALIDATE_UTF8_VALID_MASK UINT32_C(0x00000003)
327c02092b12a57e197999ca434b42fa3af51398vboxsync/** @} */
2e43d8b543c65b46f94084088524d5d16c62a021vboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** @} */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** @defgroup grp_vfs_file VFS File API
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @{
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
dc0a54940789f994c84390cb4a9f03da0b492285vboxsyncRTDECL(int) RTVfsFileOpen(RTVFS hVfs, const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/**
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * Create a VFS file handle from a standard IPRT file handle (RTFILE).
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync *
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @returns IPRT status code.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @param hFile The standard IPRT file handle.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @param fOpen The flags the handle was opened with. Pass 0 to
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * have these detected.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @param fLeaveOpen Whether to leave the handle open when the VFS file
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * is released, or to close it (@c false).
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @param phVfsFile Where to return the VFS file handle.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
dc0a54940789f994c84390cb4a9f03da0b492285vboxsyncRTDECL(int) RTVfsFileFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSFILE phVfsFile);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(RTHCUINTPTR) RTVfsFileToNative(RTFILE hVfsFile);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync/**
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * Convenience function combining RTFileOpen with RTVfsFileFromRTFile.
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync *
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * @returns IPRT status code.
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * @param pszFilename The path to the file in the normal file system.
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * @param fOpen The flags to pass to RTFileOpen when opening the
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * file, i.e. RTFILE_O_XXX.
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync * @param phVfsFile Where to return the VFS file handle.
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync */
2a097016483d82de3da35c65da5afb5da7f9740fvboxsyncRTDECL(int) RTVfsFileOpenNormal(const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile);
2a097016483d82de3da35c65da5afb5da7f9740fvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/**
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * Convert the VFS file handle to a VFS I/O stream handle.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync *
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @returns The VFS I/O stream handle on success, this must be released.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * NIL_RTVFSIOSTREAM if the file handle is invalid.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @param hVfsFile The VFS file handle.
404df8b2baf3f931a57bffd773b093d0fe40cd50vboxsync * @sa RTVfsIoStrmToFile
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(RTVFSIOSTREAM) RTVfsFileToIoStream(RTVFSFILE hVfsFile);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/**
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * Retains a reference to the VFS file handle.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync *
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @returns New reference count on success, UINT32_MAX on failure.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @param hVfsFile The VFS file handle.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(uint32_t) RTVfsFileRetain(RTVFSFILE hVfsFile);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/**
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * Releases a reference to the VFS file handle.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync *
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync * @param hVfsFile The VFS file handle.
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(uint32_t) RTVfsFileRelease(RTVFSFILE hVfsFile);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync/**
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * Query information about the object.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync *
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @returns IPRT status code.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @retval VERR_NOT_SUPPORTED if the @a enmAddAttr value is not handled by the
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * implementation.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync *
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param hVfsObj The VFS object handle.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param pObjInfo Where to return the info.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param enmAddAttr Which additional attributes should be retrieved.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTVfsObjQueryInfo, RTVfsFsStrmQueryInfo, RTVfsDirQueryInfo,
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * RTVfsIoStrmQueryInfo, RTVfsFileQueryInfo, RTFileQueryInfo,
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * RTPathQueryInfo.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsFileQueryInfo(RTVFSFILE hVfsFile, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync/**
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * Read bytes from the file at the current position.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync *
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @returns IPRT status code.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @retval VINF_SUCCESS and the number of bytes read written to @a pcbRead.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @retval VINF_TRY_AGAIN if @a fBlocking is @c false, @a pcbRead is not NULL,
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * and no data was available. @a *pcbRead will be set to 0.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @retval VINF_EOF when trying to read __beyond__ the end of the file and
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @a pcbRead is not NULL (it will be set to the number of bytes read,
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * or 0 if the end of the file was reached before this call).
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * When the last byte of the read request is the last byte in the
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * file, this status code will not be used. However, VINF_EOF is
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * returned when attempting to read 0 bytes while standing at the end
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * of the file.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @retval VERR_EOF when trying to read __beyond__ the end of the file and
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @a pcbRead is NULL.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @retval VERR_ACCESS_DENIED if the file is not readable.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync *
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param hVfsFile The VFS file handle.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param pvBuf Where to store the read bytes.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param cbToRead The number of bytes to read.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param fBlocking Whether the call is blocking (@c true) or not. If
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * not, the @a pcbRead parameter must not be NULL.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param pcbRead Where to always store the number of bytes actually
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * read. This can be NULL if @a fBlocking is true.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTVfsIoStrmRead, RTFileRead, RTPipeRead, RTPipeReadBlocking,
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * RTSocketRead
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsFileRead(RTVFSFILE hVfsFile, void *pvBuf, size_t cbToRead, size_t *pcbRead);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsFileReadAt(RTVFSFILE hVfsFile, RTFOFF off, void *pvBuf, size_t cbToRead, size_t *pcbRead);
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync/**
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * Write bytes to the file at the current position.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync *
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @returns IPRT status code.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @retval VERR_ACCESS_DENIED if the file is not writable.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync *
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param hVfsFile The VFS file handle.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param pvBuf The bytes to write.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param cbToWrite The number of bytes to write.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param fBlocking Whether the call is blocking (@c true) or not. If
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * not, the @a pcbWritten parameter must not be NULL.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param pcbRead Where to always store the number of bytes actually
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * written. This can be NULL if @a fBlocking is true.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTVfsIoStrmRead, RTFileWrite, RTPipeWrite, RTPipeWriteBlocking,
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * RTSocketWrite
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsFileWrite(RTVFSFILE hVfsFile, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsFileWriteAt(RTVFSFILE hVfsFile, RTFOFF off, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync/**
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * Flush any buffered data to the file.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync *
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @returns IPRT status code.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param hVfsFile The VFS file handle.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTVfsIoStrmFlush, RTFileFlush, RTPipeFlush
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsFileFlush(RTVFSFILE hVfsFile);
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync/**
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * Poll for events.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync *
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @returns IPRT status code.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param hVfsFile The VFS file handle.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param fEvents The events to poll for (RTPOLL_EVT_XXX).
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param cMillies How long to wait for event to eventuate.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param fIntr Whether the wait is interruptible and can return
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * VERR_INTERRUPTED (@c true) or if this condition
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * should be hidden from the caller (@c false).
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param pfRetEvents Where to return the event mask.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTVfsIoStrmPoll, RTPollSetAdd, RTPoll, RTPollNoResume.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(RTFOFF) RTVfsFilePoll(RTVFSFILE hVfsFile, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync uint32_t *pfRetEvents);
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync/**
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * Tells the current file position.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync *
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @returns Zero or higher - where to return the file offset. Values
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * below zero are IPRT status codes (VERR_XXX).
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @param hVfsFile The VFS file handle.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync * @sa RTFileTell, RTVfsIoStrmTell.
6edb8daa1da166b649f73256c47d63c9403ba27cvboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(RTFOFF) RTVfsFileTell(RTVFSFILE hVfsFile);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
956230513f1e35e9d694c219c7009034b71bb836vboxsync/**
956230513f1e35e9d694c219c7009034b71bb836vboxsync * Changes the current read/write position of a file.
956230513f1e35e9d694c219c7009034b71bb836vboxsync *
956230513f1e35e9d694c219c7009034b71bb836vboxsync * @returns IPRT status code.
956230513f1e35e9d694c219c7009034b71bb836vboxsync *
956230513f1e35e9d694c219c7009034b71bb836vboxsync * @param hVfsFile The VFS file handle.
956230513f1e35e9d694c219c7009034b71bb836vboxsync * @param offSeek The seek offset.
956230513f1e35e9d694c219c7009034b71bb836vboxsync * @param uMethod The seek emthod.
956230513f1e35e9d694c219c7009034b71bb836vboxsync * @param poffActual Where to optionally return the new file offset.
956230513f1e35e9d694c219c7009034b71bb836vboxsync *
956230513f1e35e9d694c219c7009034b71bb836vboxsync * @sa RTFileSeek
956230513f1e35e9d694c219c7009034b71bb836vboxsync */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsFileSeek(RTVFSFILE hVfsFile, RTFOFF offSeek, uint32_t uMethod, uint64_t *poffActual);
956230513f1e35e9d694c219c7009034b71bb836vboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsFileSetSize(RTVFSFILE hVfsFile, uint64_t cbSize);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsFileGetSize(RTVFSFILE hVfsFile, uint64_t *pcbSize);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(RTFOFF) RTVfsFileGetMaxSize(RTVFSFILE hVfsFile);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRTDECL(int) RTVfsFileGetMaxSizeEx(RTVFSFILE hVfsFile, PRTFOFF pcbMax);
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** @} */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync/** @defgroup grp_vfs_misc VFS Miscellaneous
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync * @{
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync */
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync/**
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync * Memorizes the I/O stream as a file backed by memory.
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync *
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync * @returns VBox status code.
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync *
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync * @param hVfsIos The VFS I/O stream to memorize. This will be read
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync * to the end on success, on failure its position is
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync * undefined.
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync * @param fFlags A combination of RTFILE_O_READ and RTFILE_O_WRITE.
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync * @param phVfsFile Where to return the handle to the memory file on
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync * success.
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync */
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsyncRTDECL(int) RTVfsMemorizeIoStreamAsFile(RTVFSIOSTREAM hVfsIos, uint32_t fFlags, PRTVFSFILE phVfsFile);
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync/**
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync * Pumps data from one I/O stream to another.
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync *
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync * The data is read in chunks from @a hVfsIosSrc and written to @a hVfsIosDst
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync * until @hVfsIosSrc indicates end of stream.
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync *
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync * @returns IPRT status code
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync *
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync * @param hVfsIosSrc The input stream.
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync * @param hVfsIosDst The output stream.
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync * @param cbBufHint Hints at a good temporary buffer size, pass 0 if
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync * clueless.
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync */
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsyncRTDECL(int) RTVfsUtilPumpIoStreams(RTVFSIOSTREAM hVfsIosSrc, RTVFSIOSTREAM hVfsIosDst, size_t cbBufHint);
835ac9173220411ef9fe578c3d4c03e5edfa20bevboxsync
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync/** @} */
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync
4d45842309f5db66367ef1c4a701fc37619b0ec0vboxsync
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync/** @defgroup grp_rt_vfs_chain VFS Chains
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync *
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * VFS chains is for doing pipe like things with VFS objects from the command
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * line. Imagine you want to cat the readme.gz of an ISO you could do
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * something like:
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * RTCat :iprtvfs:vfs(isofs,./mycd.iso)|ios(open,readme.gz)|ios(gunzip)
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * or
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * RTCat :iprtvfs:ios(isofs,./mycd.iso,/readme.gz)|ios(gunzip)
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync *
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * The "isofs", "open" and "gunzip" bits in the above examples are chain
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * element providers registered with IPRT. See RTVFSCHAINELEMENTREG for how
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * these works.
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync *
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync * @{ */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync/** The path prefix used to identify an VFS chain specification. */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync#define RTVFSCHAIN_SPEC_PREFIX ":iprtvfs:"
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(int) RTVfsChainOpenVfs( const char *pszSpec, PRTVFS phVfs, const char **ppszError);
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(int) RTVfsChainOpenFsStream( const char *pszSpec, PRTVFSFSSTREAM phVfsFss, const char **ppszError);
dc0a54940789f994c84390cb4a9f03da0b492285vboxsyncRTDECL(int) RTVfsChainOpenDir( const char *pszSpec, uint64_t fOpen, PRTVFSDIR phVfsDir, const char **ppszError);
dc0a54940789f994c84390cb4a9f03da0b492285vboxsyncRTDECL(int) RTVfsChainOpenFile( const char *pszSpec, uint64_t fOpen, PRTVFSFILE phVfsFile, const char **ppszError);
1e9c7d1236e5efe007e5984e75dad70243214559vboxsyncRTDECL(int) RTVfsChainOpenSymlink( const char *pszSpec, PRTVFSSYMLINK phVfsSym, const char **ppszError);
dc0a54940789f994c84390cb4a9f03da0b492285vboxsyncRTDECL(int) RTVfsChainOpenIoStream( const char *pszSpec, uint64_t fOpen, PRTVFSIOSTREAM phVfsIos, const char **ppszError);
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync/**
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * Tests if the given string is a chain specification or not.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync *
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @returns true if it is, false if it isn't.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync * @param pszSpec The alleged chain spec.
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync */
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsyncRTDECL(bool) RTVfsChainIsSpec(const char *pszSpec);
4d3f12a2094df73f5e04b71d3b7623aa0130285cvboxsync
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync/** @} */
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
1e9c7d1236e5efe007e5984e75dad70243214559vboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync/** @} */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsyncRT_C_DECLS_END
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync#endif /* !___iprt_vfs_h */
4e38f78b4916ef128a3902ed2a8d7e8d7f947d8dvboxsync