From 7a38a2659351f29963aaaa0615558c2b535f51ab Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Wed, 22 Jan 2020 21:11:06 -0600 Subject: [PATCH] Fix ~ (WinAPI) must use `Handle::from_path_any()` if target path might be a directory .# [why] "If you use `from_path()` on a directory, then subsequent queries using that handle will fail." Instead, use `from_path_any()` which supports opening files or directories. ref: "Struct winapi_util::Handle" from --- src/utils/platform.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/platform.rs b/src/utils/platform.rs index 450e1db..259f388 100644 --- a/src/utils/platform.rs +++ b/src/utils/platform.rs @@ -28,7 +28,7 @@ pub fn get_metadata(d: &DirEntry, _use_apparent_size: bool) -> Option<(u64, Opti use winapi_util::file::information; use winapi_util::Handle; - let h = Handle::from_path(d.path()).ok()?; + let h = Handle::from_path_any(d.path()).ok()?; let info = information(&h).ok()?; Some(( @@ -59,7 +59,7 @@ pub fn get_filesystem(file_path: &str) -> Result { use winapi_util::file::information; use winapi_util::Handle; - let h = Handle::from_path(file_path)?; + let h = Handle::from_path_any(file_path)?; let info = information(&h)?; Ok(info.volume_serial_number()) }