mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-27 20:36:31 -04:00
windows: add GetDiskFreeSpaceEx function
ref: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdiskfreespaceexw Change-Id: If57b0777106a2253e4287818d2c5aee2d6be13d3 Reviewed-on: https://go-review.googlesource.com/c/sys/+/200257 Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
committed by
Jason A. Donenfeld
parent
06d7bd2c5f
commit
b09406accb
@@ -356,3 +356,24 @@ func TestBuildSecurityDescriptor(t *testing.T) {
|
||||
t.Fatalf("SD = %q; want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDiskFreeSpaceEx(t *testing.T) {
|
||||
cwd, err := windows.UTF16PtrFromString(".")
|
||||
if err != nil {
|
||||
t.Fatalf(`failed to call UTF16PtrFromString("."): %v`, err)
|
||||
}
|
||||
var freeBytesAvailableToCaller, totalNumberOfBytes, totalNumberOfFreeBytes uint64
|
||||
if err := windows.GetDiskFreeSpaceEx(cwd, &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes); err != nil {
|
||||
t.Fatalf("failed to call GetDiskFreeSpaceEx: %v", err)
|
||||
}
|
||||
|
||||
if freeBytesAvailableToCaller == 0 {
|
||||
t.Errorf("freeBytesAvailableToCaller: got 0; want > 0")
|
||||
}
|
||||
if totalNumberOfBytes == 0 {
|
||||
t.Errorf("totalNumberOfBytes: got 0; want > 0")
|
||||
}
|
||||
if totalNumberOfFreeBytes == 0 {
|
||||
t.Errorf("totalNumberOfFreeBytes: got 0; want > 0")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user