VirtualBox

Ignore:
Timestamp:
Nov 9, 2016 5:03:40 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
111837
Message:

IPRT: Reshuffled RTFsQuerySizes from fs-nt.cpp to implement RTFileQueryFsSizes for windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/nt/fs-nt.cpp

    r62584 r64619  
    3333
    3434#include <iprt/fs.h>
     35#include <iprt/file.h>
    3536#include <iprt/path.h>
    3637#include <iprt/string.h>
     
    6465    if (RT_SUCCESS(rc))
    6566    {
    66         /*
    67          * Get the volume information.
    68          */
    69         FILE_FS_SIZE_INFORMATION FsSizeInfo;
    70         IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    71         NTSTATUS rcNt = NtQueryVolumeInformationFile(hFile, &Ios, &FsSizeInfo, sizeof(FsSizeInfo), FileFsSizeInformation);
    72         if (NT_SUCCESS(rcNt))
    73         {
    74             /*
    75              * Calculate the return values.
    76              */
    77             if (pcbTotal)
    78             {
    79                 *pcbTotal = FsSizeInfo.TotalAllocationUnits.QuadPart
    80                           * FsSizeInfo.SectorsPerAllocationUnit
    81                           * FsSizeInfo.BytesPerSector;
    82                 if (   *pcbTotal / FsSizeInfo.SectorsPerAllocationUnit / FsSizeInfo.BytesPerSector
    83                     != FsSizeInfo.TotalAllocationUnits.QuadPart)
    84                     *pcbTotal = UINT64_MAX;
    85             }
    86 
    87             if (pcbFree)
    88             {
    89                 *pcbFree = FsSizeInfo.AvailableAllocationUnits.QuadPart
    90                          * FsSizeInfo.SectorsPerAllocationUnit
    91                          * FsSizeInfo.BytesPerSector;
    92                 if (   *pcbFree / FsSizeInfo.SectorsPerAllocationUnit / FsSizeInfo.BytesPerSector
    93                     != FsSizeInfo.AvailableAllocationUnits.QuadPart)
    94                     *pcbFree = UINT64_MAX;
    95             }
    96 
    97             if (pcbBlock)
    98             {
    99                 *pcbBlock  = FsSizeInfo.SectorsPerAllocationUnit * FsSizeInfo.BytesPerSector;
    100                 if (*pcbBlock / FsSizeInfo.BytesPerSector != FsSizeInfo.SectorsPerAllocationUnit)
    101                     rc = VERR_OUT_OF_RANGE;
    102             }
    103 
    104             if (pcbSector)
    105                 *pcbSector = FsSizeInfo.BytesPerSector;
    106         }
    107         else
    108             rc = RTErrConvertFromNtStatus(rcNt);
     67        RTFILE hIprtFile = NIL_RTFILE;
     68        rc = RTFileFromNative(&hIprtFile, (RTHCINTPTR)hFile);
     69        AssertRC(rc);
     70        if (RT_SUCCESS(rc))
     71            rc = RTFileQueryFsSizes(hIprtFile, pcbTotal, pcbFree, pcbBlock, pcbSector);
    10972
    11073        RTNtPathClose(hFile);
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