VirtualBox

Changeset 69977 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Dec 7, 2017 1:02:36 PM (7 years ago)
Author:
vboxsync
Message:

IPRT/vfs: Implemented RTVFsFileSetSize, RTVfsFileGetMaxSize and RTvfsFileQueryMaxSize.

Location:
trunk/include/iprt
Files:
4 edited

Legend:

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

    r69105 r69977  
    11371137/** @} */
    11381138
    1139 /** @name RTFileSetAllocationSize flags
     1139/**
     1140 * Sets the current size of the file ensuring that all required blocks
     1141 * are allocated on the underlying medium.
     1142 *
     1143 * @returns IPRT status code.
     1144 * @retval  VERR_NOT_SUPPORTED if either this operation is not supported on the
     1145 *          current host in an efficient manner or the given combination of
     1146 *          flags is not supported.
     1147 * @param   hFile           The handle to the file.
     1148 * @param   cbSize          The new size of the file to allocate.
     1149 * @param   fFlags          Combination of RTFILE_ALLOC_SIZE_F_*
     1150 */
     1151RTDECL(int) RTFileSetAllocationSize(RTFILE hFile, uint64_t cbSize, uint32_t fFlags);
     1152
     1153/** @name RTFILE_ALLOC_SIZE_F_XXX - RTFileSetAllocationSize flags
    11401154 * @{ */
    11411155/** Default flags. */
    11421156#define RTFILE_ALLOC_SIZE_F_DEFAULT         0
    1143 /** Do not change the size of the file if the given size is
    1144  * bigger than the current file size. Useful to preallocate
    1145  * blocks beyond the current size for appending data in an efficient
    1146  * manner. Might not be supported on all hosts and will return
     1157/** Do not change the size of the file if the given size is bigger than the
     1158 * current file size.
     1159 *
     1160 * Useful to preallocate blocks beyond the current size for appending data in an
     1161 * efficient manner. Might not be supported on all hosts and will return
    11471162 * VERR_NOT_SUPPORTED in that case. */
    11481163#define RTFILE_ALLOC_SIZE_F_KEEP_SIZE       RT_BIT(0)
     
    11511166/** @} */
    11521167
    1153 /**
    1154  * Sets the current size of the file ensuring that all required blocks
    1155  * are allocated on the underlying medium.
    1156  *
    1157  * @returns IPRT status code.
    1158  * @retval  VERR_NOT_SUPPORTED if either this operation is not supported on the current host
    1159  *                             in an efficient manner or the given combination of flags is
    1160  *                             not supported.
    1161  * @param   hFile           The handle to the file.
    1162  * @param   cbSize          The new size of the file to allocate.
    1163  * @param   fFlags          Combination of RTFILE_ALLOC_SIZE_F_*
    1164  */
    1165 RTDECL(int) RTFileSetAllocationSize(RTFILE hFile, uint64_t cbSize, uint32_t fFlags);
    11661168
    11671169#ifdef IN_RING3
  • trunk/include/iprt/mangling.h

    r69892 r69977  
    24742474# define RTVfsFileGetOpenFlags                          RT_MANGLER(RTVfsFileGetOpenFlags)
    24752475# define RTVfsFileGetSize                               RT_MANGLER(RTVfsFileGetSize)
     2476# define RTVfsFileGetMaxSize                            RT_MANGLER(RTVfsFileGetMaxSize)
    24762477# define RTVfsFileOpen                                  RT_MANGLER(RTVfsFileOpen)
    24772478# define RTVfsFileOpenNormal                            RT_MANGLER(RTVfsFileOpenNormal)
    24782479# define RTVfsFilePoll                                  RT_MANGLER(RTVfsFilePoll)
    24792480# define RTVfsFileQueryInfo                             RT_MANGLER(RTVfsFileQueryInfo)
     2481# define RTVfsFileQueryMaxSize                          RT_MANGLER(RTVfsFileQueryMaxSize)
    24802482# define RTVfsFileRead                                  RT_MANGLER(RTVfsFileRead)
    24812483# define RTVfsFileReadAt                                RT_MANGLER(RTVfsFileReadAt)
     
    24842486# define RTVfsFileRetainDebug                           RT_MANGLER(RTVfsFileRetainDebug)
    24852487# define RTVfsFileSeek                                  RT_MANGLER(RTVfsFileSeek)
     2488# define RTVfsFileSetSize                               RT_MANGLER(RTVfsFileSetSize)
    24862489# define RTVfsFileSgRead                                RT_MANGLER(RTVfsFileSgRead)
    24872490# define RTVfsFileSgWrite                               RT_MANGLER(RTVfsFileSgWrite)
  • trunk/include/iprt/vfs.h

    r69844 r69977  
    14041404RTDECL(int)         RTVfsFileSeek(RTVFSFILE hVfsFile, RTFOFF offSeek, uint32_t uMethod, uint64_t *poffActual);
    14051405
    1406 RTDECL(int)         RTVfsFileSetSize(RTVFSFILE hVfsFile, uint64_t cbSize);
     1406/**
     1407 * Sets the size of a file.
     1408 *
     1409 * This may also be used for preallocating space
     1410 * (RTVFSFILE_SIZE_F_PREALLOC_KEEP_SIZE).
     1411 *
     1412 * @returns IPRT status code.
     1413 * @retval  VERR_ACCESS_DENIED if handle isn't writable.
     1414 * @retval  VERR_WRITE_PROTECT if read-only file system.
     1415 * @retval  VERR_FILE_TOO_BIG if cbSize is larger than what the file system can
     1416 *          theoretically deal with.
     1417 * @retval  VERR_DISK_FULL if the file system if full.
     1418 * @retval  VERR_NOT_SUPPORTED if fFlags indicates some operation that's not
     1419 *          supported by the file system / host operating system.
     1420 *
     1421 * @param   hVfsFile        The VFS file handle.
     1422 * @param   cbSize          The new file size.
     1423 * @param   fFlags          RTVFSFILE_SIZE_F_NORMAL, RTVFSFILE_SIZE_F_GROW, or
     1424 *                          RTVFSFILE_SIZE_F_GROW_KEEP_SIZE.
     1425 *
     1426 * @sa      RTFileSetSize, RTFileSetAllocationSize
     1427 */
     1428RTDECL(int)         RTVfsFileSetSize(RTVFSFILE hVfsFile, uint64_t cbSize, uint32_t fFlags);
     1429
     1430/** @name RTVFSFILE_SIZE_F_XXX - RTVfsFileSetSize flags.
     1431 * @{ */
     1432/** Normal truncate or grow (zero'ed) like RTFileSetSize . */
     1433#define RTVFSFILE_SIZE_F_NORMAL             UINT32_C(0x00000001)
     1434/** Only grow the file, ignore call if cbSize would trunacte the file.
     1435 * This is what RTFileSetAllocationSize does by default.  */
     1436#define RTVFSFILE_SIZE_F_GROW               UINT32_C(0x00000002)
     1437/** Only grow the file, ignore call if cbSize would trunacte the file.
     1438 * This is what RTFileSetAllocationSize does by default.  */
     1439#define RTVFSFILE_SIZE_F_GROW_KEEP_SIZE     UINT32_C(0x00000003)
     1440/** Action mask. */
     1441#define RTVFSFILE_SIZE_F_ACTION_MASK        UINT32_C(0x00000003)
     1442/** Validate the flags.
     1443 * Will reference @a a_fFlags more than once.  */
     1444#define RTVFSFILE_SIZE_F_IS_VALID(a_fFlags) \
     1445    ( !((a_fFlags) & ~RTVFSFILE_SIZE_F_ACTION_MASK) && ((a_fFlags) & RTVFSFILE_SIZE_F_ACTION_MASK) != 0 )
     1446/** @} */
     1447
     1448
     1449/** Mask of valid flags. */
     1450#define RTFILE_ALLOC_SIZE_F_VALID           (RTFILE_ALLOC_SIZE_F_KEEP_SIZE)
     1451/** @} */
     1452
     1453
    14071454RTDECL(int)         RTVfsFileGetSize(RTVFSFILE hVfsFile, uint64_t *pcbSize);
    14081455RTDECL(RTFOFF)      RTVfsFileGetMaxSize(RTVFSFILE hVfsFile);
    1409 RTDECL(int)         RTVfsFileGetMaxSizeEx(RTVFSFILE hVfsFile, PRTFOFF pcbMax);
     1456RTDECL(int)         RTVfsFileQueryMaxSize(RTVFSFILE hVfsFile, uint64_t *pcbMax);
    14101457
    14111458/**
  • trunk/include/iprt/vfslowlevel.h

    r69955 r69977  
    10041004
    10051005    /**
    1006      * Get the current file/stream size.
     1006     * Get the current file size.
    10071007     *
    10081008     * @returns IPRT status code.
     
    10121012     */
    10131013    DECLCALLBACKMEMBER(int, pfnQuerySize)(void *pvThis, uint64_t *pcbFile);
     1014
     1015    /**
     1016     * Change the file size.
     1017     *
     1018     * @returns IPRT status code.
     1019     * @retval  VERR_ACCESS_DENIED if handle isn't writable.
     1020     * @retval  VERR_WRITE_PROTECT if read-only file system.
     1021     * @retval  VERR_FILE_TOO_BIG if cbSize is larger than what the file system can
     1022     *          theoretically deal with.
     1023     * @retval  VERR_DISK_FULL if the file system if full.
     1024     * @retval  VERR_NOT_SUPPORTED if fFlags indicates some operation that's not
     1025     *          supported by the file system / host operating system.
     1026     *
     1027     * @param   pvThis      The implementation specific file data.
     1028     * @param   pcbFile     Where to store the current file size.
     1029     * @param   fFlags      RTVFSFILE_SET_SIZE_F_XXX.
     1030     * @note    Optional.  If NULL, VERR_WRITE_PROTECT will be returned.
     1031     * @sa      RTFileSetSize, RTFileSetAllocationSize
     1032     */
     1033    DECLCALLBACKMEMBER(int, pfnSetSize)(void *pvThis, uint64_t cbFile, uint32_t fFlags);
     1034
     1035    /**
     1036     * Determine the maximum file size.
     1037     *
     1038     * This won't take amount of freespace into account, just the limitations of the
     1039     * underlying file system / host operating system.
     1040     *
     1041     * @returns IPRT status code.
     1042     * @param   pvThis      The implementation specific file data.
     1043     * @param   pcbMax      Where to return the max file size.
     1044     * @note    Optional.  If NULL, VERR_NOT_IMPLEMENTED will be returned.
     1045     * @sa      RTFileGetMaxSizeEx
     1046     */
     1047    DECLCALLBACKMEMBER(int, pfnQueryMaxSize)(void *pvThis, uint64_t *pcbMax);
    10141048
    10151049    /** @todo There will be more methods here. */
     
    10221056
    10231057/** The RTVFSFILEOPS structure version. */
    1024 #define RTVFSFILEOPS_VERSION        RT_MAKE_U32_FROM_U8(0xff,0x7f,1,0)
     1058#define RTVFSFILEOPS_VERSION        RT_MAKE_U32_FROM_U8(0xff,0x7f,2,0)
    10251059
    10261060/**
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