From 97ff12ebba231511081885fe36b17d174915b688 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 3 Dec 2024 17:49:32 -0800 Subject: [PATCH] Update to windows-sys 0.59. (#379) * Update to windows-sys 0.59. Allow compilation with either windows-sys 0.52 or 0.59. * Add needed windows-sys features. --- Cargo.toml | 3 ++- cap-directories/Cargo.toml | 2 +- cap-fs-ext/Cargo.toml | 2 +- cap-primitives/Cargo.toml | 2 +- cap-primitives/src/windows/fs/create_file_at_w.rs | 4 ++-- cap-primitives/src/windows/fs/open_unchecked.rs | 8 ++++---- cap-tempfile/Cargo.toml | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ea0d1901..549c9698 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,10 +41,11 @@ rustix = { version = "0.38.0", features = ["fs"] } nt_version = "0.1.3" [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.52.0" +version = ">=0.52, <=0.59" features = [ "Win32_Storage_FileSystem", "Win32_Foundation", + "Win32_System_Ioctl", "Win32_System_SystemServices", ] diff --git a/cap-directories/Cargo.toml b/cap-directories/Cargo.toml index 8fbe1a7c..17e44c9a 100644 --- a/cap-directories/Cargo.toml +++ b/cap-directories/Cargo.toml @@ -20,7 +20,7 @@ directories-next = "2.0.0" rustix = { version = "0.38.0" } [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.52.0" +version = ">=0.52, <=0.59" features = [ "Win32_Foundation", ] diff --git a/cap-fs-ext/Cargo.toml b/cap-fs-ext/Cargo.toml index c3d10db6..5a0cdcee 100644 --- a/cap-fs-ext/Cargo.toml +++ b/cap-fs-ext/Cargo.toml @@ -32,7 +32,7 @@ async_std_fs_utf8 = ["cap-async-std/fs_utf8", "camino"] async_std_arf_strings = ["cap-async-std/arf_strings", "async_std_fs_utf8", "arf-strings"] [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.52.0" +version = ">=0.52, <=0.59" features = [ "Win32_Storage_FileSystem", ] diff --git a/cap-primitives/Cargo.toml b/cap-primitives/Cargo.toml index 264b73ae..c63f3c7d 100644 --- a/cap-primitives/Cargo.toml +++ b/cap-primitives/Cargo.toml @@ -31,7 +31,7 @@ rustix = { version = "0.38.38", features = ["fs", "process", "procfs", "termios" winx = "0.36.0" [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.52.0" +version = ">=0.52, <=0.59" features = [ "Win32_Foundation", "Win32_Security", diff --git a/cap-primitives/src/windows/fs/create_file_at_w.rs b/cap-primitives/src/windows/fs/create_file_at_w.rs index 5808997a..cefa7932 100644 --- a/cap-primitives/src/windows/fs/create_file_at_w.rs +++ b/cap-primitives/src/windows/fs/create_file_at_w.rs @@ -95,10 +95,10 @@ pub unsafe fn CreateFileAtW( // sorry that I cannot give more details on these functions". // // [unofficial blog posts]: https://mecanik.dev/en/posts/convert-dos-and-nt-paths-using-rtl-functions/ - assert!(dir != 0); + assert!(dir != 0 as HANDLE); // Extended attributes are not implemented yet. - if htemplatefile != 0 { + if htemplatefile != 0 as HANDLE { SetLastError(ERROR_NOT_SUPPORTED); return HandleOrInvalid::from_raw_handle(INVALID_HANDLE_VALUE as _); } diff --git a/cap-primitives/src/windows/fs/open_unchecked.rs b/cap-primitives/src/windows/fs/open_unchecked.rs index f9f17470..49668f82 100644 --- a/cap-primitives/src/windows/fs/open_unchecked.rs +++ b/cap-primitives/src/windows/fs/open_unchecked.rs @@ -58,7 +58,7 @@ fn open_at(start: &fs::File, path: &Path, opts: &OpenOptions) -> io::Result { rebuilt.push(component); - dir = 0; + dir = 0 as HANDLE; } Component::Normal(_) => { rebuilt.push(component); @@ -70,7 +70,7 @@ fn open_at(start: &fs::File, path: &Path, opts: &OpenOptions) -> io::Result io::Result io::Result