diff --git a/Cargo.toml b/Cargo.toml index 836ff64..1e7afd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,14 +24,15 @@ print_bytes = { version = "0.7", optional = true } serde = { version = "1.0", optional = true } [target.'cfg(windows)'.dependencies] -winapi = { version = "0.3", features = ["fileapi"] } +windows-sys = { version = "0.42", features = ["Win32_Storage_FileSystem"] } [dev-dependencies] bincode = "1.3" tempfile = "3.2" +windows-sys = { version = "0.42", features = ["Win32_Foundation"] } [target.'cfg(not(windows))'.dev-dependencies] libc = "0.2" [features] -localization = ["winapi/shellapi"] +localization = ["windows-sys/Win32_UI_Shell", "windows-sys/Win32_UI_WindowsAndMessaging"] diff --git a/src/windows/localize.rs b/src/windows/localize.rs index 8cc3afc..604d755 100644 --- a/src/windows/localize.rs +++ b/src/windows/localize.rs @@ -5,9 +5,8 @@ use std::os::windows::ffi::OsStrExt; use std::os::windows::ffi::OsStringExt; use std::path::Path; -use winapi::shared::minwindef::UINT; -use winapi::um::shellapi::SHGetFileInfoW; -use winapi::um::shellapi::SHGFI_DISPLAYNAME; +use windows_sys::Win32::UI::Shell::SHGetFileInfoW; +use windows_sys::Win32::UI::Shell::SHGFI_DISPLAYNAME; pub(super) fn name(path: &Path) -> Option { let mut path: Vec<_> = path.as_os_str().encode_wide().collect(); @@ -22,7 +21,7 @@ pub(super) fn name(path: &Path) -> Option { path.as_ptr(), 0, path_info.as_mut_ptr(), - mem::size_of_val(&path_info) as UINT, + mem::size_of_val(&path_info) as _, SHGFI_DISPLAYNAME, ) }; diff --git a/src/windows/normalize.rs b/src/windows/normalize.rs index 66927cd..9f29be9 100644 --- a/src/windows/normalize.rs +++ b/src/windows/normalize.rs @@ -11,8 +11,7 @@ use std::path::Prefix; use std::path::PrefixComponent; use std::ptr; -use winapi::shared::minwindef::DWORD; -use winapi::um::fileapi::GetFullPathNameW; +use windows_sys::Win32::Storage::FileSystem::GetFullPathNameW; use super::BasePath; use super::BasePathBuf; @@ -104,8 +103,9 @@ pub(super) fn normalize_virtually( break Err(io::Error::last_os_error()); } + let _: u32 = capacity; // This assertion should never fail. - static_assert!(mem::size_of::() <= mem::size_of::()); + static_assert!(mem::size_of::() <= mem::size_of::()); let length = capacity as usize; if let Some(mut additional_capacity) = diff --git a/tests/integration.rs b/tests/integration.rs index 229b150..242b755 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -14,7 +14,7 @@ mod common; #[cfg(windows)] #[rustfmt::skip] -use winapi::shared::winerror::ERROR_INVALID_NAME; +use windows_sys::Win32::Foundation::ERROR_INVALID_NAME; #[cfg(not(windows))] use libc::ENOENT as ERROR_INVALID_NAME;