Added GetDiskFreeSpaceEx().

svn path=/trunk/; revision=430
This commit is contained in:
Eric Kohl 1999-05-06 20:06:42 +00:00
parent 0072db2e5e
commit 781ba31ad3
4 changed files with 104 additions and 0 deletions

View file

@ -526,6 +526,15 @@ GetDiskFreeSpaceA(
LPDWORD lpTotalNumberOfClusters LPDWORD lpTotalNumberOfClusters
); );
WINBOOL
STDCALL
GetDiskFreeSpaceExA(
LPCSTR lpDirectoryName,
PULARGE_INTEGER lpFreeBytesAvailableToCaller,
PULARGE_INTEGER lpTotalNumberOfBytes,
PULARGE_INTEGER lpTotalNumberOfFreeBytes
);
WINBOOL WINBOOL
STDCALL STDCALL
CreateDirectoryA( CreateDirectoryA(

View file

@ -527,6 +527,15 @@ GetDiskFreeSpaceW(
LPDWORD lpTotalNumberOfClusters LPDWORD lpTotalNumberOfClusters
); );
WINBOOL
STDCALL
GetDiskFreeSpaceExW(
LPCWSTR lpDirectoryName,
PULARGE_INTEGER lpFreeBytesAvailableToCaller,
PULARGE_INTEGER lpTotalNumberOfBytes,
PULARGE_INTEGER lpTotalNumberOfFreeBytes
);
WINBOOL WINBOOL
STDCALL STDCALL
CreateDirectoryW( CreateDirectoryW(

View file

@ -184,6 +184,88 @@ GetDiskFreeSpaceW(
return TRUE; 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 UINT
STDCALL STDCALL
GetDriveTypeA( GetDriveTypeA(

View file

@ -289,6 +289,10 @@ GetDiskFreeSpaceA@20
GetDiskFreeSpaceA = GetDiskFreeSpaceA@20 GetDiskFreeSpaceA = GetDiskFreeSpaceA@20
GetDiskFreeSpaceW@20 GetDiskFreeSpaceW@20
GetDiskFreeSpaceW = GetDiskFreeSpaceW@20 GetDiskFreeSpaceW = GetDiskFreeSpaceW@20
GetDiskFreeSpaceExA@16
GetDiskFreeSpaceExA = GetDiskFreeSpaceExA@16
GetDiskFreeSpaceExW@16
GetDiskFreeSpaceExW = GetDiskFreeSpaceExW@16
;GetDriveTypeA@4 ;GetDriveTypeA@4
;GetDriveTypeW@4 ;GetDriveTypeW@4
;GetEnvironmentStrings@0 ;GetEnvironmentStrings@0