mirror of
https://github.com/bootandy/dust.git
synced 2025-12-12 07:40:40 -08:00
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 <https://docs.rs/crate/winapi-util>
This commit is contained in:
@@ -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<u64, io::Error> {
|
||||
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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user