From 411b18de3ad3b7aa349c978f12f3d14dce6fce65 Mon Sep 17 00:00:00 2001 From: "J. David Lowe" Date: Tue, 26 Nov 2024 16:44:40 -0800 Subject: [PATCH] what's up with windows? --- src/windows/disk.rs | 13 +++++-------- tests/disk.rs | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/windows/disk.rs b/src/windows/disk.rs index 22afcbb93..714f07075 100644 --- a/src/windows/disk.rs +++ b/src/windows/disk.rs @@ -185,16 +185,13 @@ impl DiskInner { } if refreshes.details() && self.total_space != 0 { - let available_space = unsafe { - let mut tmp = 0; - let lpdirectoryname = PCWSTR::from_raw(self.mount_point.as_ptr()); - if GetDiskFreeSpaceExW(lpdirectoryname, None, None, Some(&mut tmp)).is_ok() { - tmp - } else { - 0 - } + let (total_space, available_space) = if refreshes.details() { + get_drive_size(&self.mount_point).unwrap_or_default() + } else { + (0, 0) }; + self.total_space = total_space; self.available_space = available_space; } false diff --git a/tests/disk.rs b/tests/disk.rs index cf9910f3a..2fbab2ba3 100644 --- a/tests/disk.rs +++ b/tests/disk.rs @@ -56,7 +56,7 @@ fn test_disk_refresh_kind() { if refreshes.kind() { // This would ideally assert that *all* are refreshed, but we settle for a weaker // assertion because failures can't be distinguished from "not refreshed" values. - #[cfg(not(target_os = "freebsd"))] + #[cfg(not(any(target_os = "freebsd", target_os = "windows")))] assert!( disks .iter()