mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Added GetDiskFreeSpaceEx().
svn path=/trunk/; revision=430
This commit is contained in:
parent
0072db2e5e
commit
781ba31ad3
4 changed files with 104 additions and 0 deletions
|
@ -526,6 +526,15 @@ GetDiskFreeSpaceA(
|
|||
LPDWORD lpTotalNumberOfClusters
|
||||
);
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GetDiskFreeSpaceExA(
|
||||
LPCSTR lpDirectoryName,
|
||||
PULARGE_INTEGER lpFreeBytesAvailableToCaller,
|
||||
PULARGE_INTEGER lpTotalNumberOfBytes,
|
||||
PULARGE_INTEGER lpTotalNumberOfFreeBytes
|
||||
);
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
CreateDirectoryA(
|
||||
|
|
|
@ -527,6 +527,15 @@ GetDiskFreeSpaceW(
|
|||
LPDWORD lpTotalNumberOfClusters
|
||||
);
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GetDiskFreeSpaceExW(
|
||||
LPCWSTR lpDirectoryName,
|
||||
PULARGE_INTEGER lpFreeBytesAvailableToCaller,
|
||||
PULARGE_INTEGER lpTotalNumberOfBytes,
|
||||
PULARGE_INTEGER lpTotalNumberOfFreeBytes
|
||||
);
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
CreateDirectoryW(
|
||||
|
|
|
@ -184,6 +184,88 @@ GetDiskFreeSpaceW(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GetDiskFreeSpaceExA(
|
||||
LPCSTR lpDirectoryName,
|
||||
PULARGE_INTEGER lpFreeBytesAvailableToCaller,
|
||||
PULARGE_INTEGER lpTotalNumberOfBytes,
|
||||
PULARGE_INTEGER lpTotalNumberOfFreeBytes
|
||||
)
|
||||
{
|
||||
WCHAR DirectoryNameW[MAX_PATH];
|
||||
ULONG i;
|
||||
|
||||
i = 0;
|
||||
while ((*lpDirectoryName)!=0 && i < MAX_PATH)
|
||||
{
|
||||
DirectoryNameW[i] = *lpDirectoryName;
|
||||
lpDirectoryName++;
|
||||
i++;
|
||||
}
|
||||
DirectoryNameW[i] = 0;
|
||||
return GetDiskFreeSpaceExW(DirectoryNameW,
|
||||
lpFreeBytesAvailableToCaller,
|
||||
lpTotalNumberOfBytes,
|
||||
lpTotalNumberOfFreeBytes);
|
||||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GetDiskFreeSpaceExW(
|
||||
LPCWSTR lpDirectoryName,
|
||||
PULARGE_INTEGER lpFreeBytesAvailableToCaller,
|
||||
PULARGE_INTEGER lpTotalNumberOfBytes,
|
||||
PULARGE_INTEGER lpTotalNumberOfFreeBytes
|
||||
)
|
||||
{
|
||||
FILE_FS_SIZE_INFORMATION FileFsSize;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
HANDLE hFile;
|
||||
NTSTATUS errCode;
|
||||
WCHAR RootPath[4];
|
||||
ULARGE_INTEGER BytesPerCluster;
|
||||
|
||||
wcsncpy (RootPath, lpDirectoryName, 3);
|
||||
|
||||
hFile = CreateFileW(RootPath,
|
||||
FILE_READ_ATTRIBUTES,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
|
||||
errCode = NtQueryVolumeInformationFile(hFile,
|
||||
&IoStatusBlock,
|
||||
&FileFsSize,
|
||||
sizeof(FILE_FS_SIZE_INFORMATION),
|
||||
FileFsSizeInformation);
|
||||
if (!NT_SUCCESS(errCode))
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BytesPerCluster.QuadPart =
|
||||
FileFsSize.BytesPerSector * FileFsSize.SectorsPerAllocationUnit;
|
||||
|
||||
// FIXME: Use quota information
|
||||
lpFreeBytesAvailableToCaller->QuadPart =
|
||||
BytesPerCluster.QuadPart * FileFsSize.AvailableAllocationUnits.QuadPart;
|
||||
|
||||
lpTotalNumberOfBytes->QuadPart =
|
||||
BytesPerCluster.QuadPart * FileFsSize.TotalAllocationUnits.LowPart;
|
||||
lpTotalNumberOfFreeBytes->QuadPart =
|
||||
BytesPerCluster.QuadPart * FileFsSize.AvailableAllocationUnits.QuadPart;
|
||||
|
||||
CloseHandle(hFile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
UINT
|
||||
STDCALL
|
||||
GetDriveTypeA(
|
||||
|
|
|
@ -289,6 +289,10 @@ GetDiskFreeSpaceA@20
|
|||
GetDiskFreeSpaceA = GetDiskFreeSpaceA@20
|
||||
GetDiskFreeSpaceW@20
|
||||
GetDiskFreeSpaceW = GetDiskFreeSpaceW@20
|
||||
GetDiskFreeSpaceExA@16
|
||||
GetDiskFreeSpaceExA = GetDiskFreeSpaceExA@16
|
||||
GetDiskFreeSpaceExW@16
|
||||
GetDiskFreeSpaceExW = GetDiskFreeSpaceExW@16
|
||||
;GetDriveTypeA@4
|
||||
;GetDriveTypeW@4
|
||||
;GetEnvironmentStrings@0
|
||||
|
|
Loading…
Reference in a new issue