Skip to content

Commit

Permalink
Update to windows-sys 0.59. (#379)
Browse files Browse the repository at this point in the history
* Update to windows-sys 0.59.

Allow compilation with either windows-sys 0.52 or 0.59.

* Add needed windows-sys features.
  • Loading branch information
sunfishcode authored Dec 4, 2024
1 parent 0f53e08 commit 97ff12e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down
2 changes: 1 addition & 1 deletion cap-directories/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
2 changes: 1 addition & 1 deletion cap-fs-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
2 changes: 1 addition & 1 deletion cap-primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions cap-primitives/src/windows/fs/create_file_at_w.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _);
}
Expand Down
8 changes: 4 additions & 4 deletions cap-primitives/src/windows/fs/open_unchecked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn open_at(start: &fs::File, path: &Path, opts: &OpenOptions) -> io::Result<fs::
match component {
Component::Prefix(_) | Component::RootDir => {
rebuilt.push(component);
dir = 0;
dir = 0 as HANDLE;
}
Component::Normal(_) => {
rebuilt.push(component);
Expand All @@ -70,7 +70,7 @@ fn open_at(start: &fs::File, path: &Path, opts: &OpenOptions) -> io::Result<fs::
// path by dropping the directory base. It's ok to do
// this because we're not sandboxing at this level of the
// code.
if dir == 0 {
if dir == 0 as HANDLE {
return Err(io::Error::from_raw_os_error(ERROR_ACCESS_DENIED as _));
}
rebuilt = match file_path(start) {
Expand All @@ -79,7 +79,7 @@ fn open_at(start: &fs::File, path: &Path, opts: &OpenOptions) -> io::Result<fs::
return Err(io::Error::from_raw_os_error(ERROR_ACCESS_DENIED as _));
}
};
dir = 0;
dir = 0 as HANDLE;
// And then pop the last component of that.
let _ = rebuilt.pop();
}
Expand All @@ -93,7 +93,7 @@ fn open_at(start: &fs::File, path: &Path, opts: &OpenOptions) -> io::Result<fs::
// If we ended up re-rooting, use Windows' `CreateFileW` instead of our
// own `CreateFileAtW` so that it does the requisite magic for absolute
// paths.
if dir == 0 {
if dir == 0 as HANDLE {
// We're calling the windows-sys `CreateFileW` which expects a
// NUL-terminated filename, so add a NUL terminator.
wide.push(0);
Expand Down
2 changes: 1 addition & 1 deletion cap-tempfile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rand = "0.8.1"
rustix = { version = "0.38.0", features = ["procfs"] }

[target.'cfg(windows)'.dev-dependencies.windows-sys]
version = "0.52.0"
version = ">=0.52, <=0.59"
features = [
"Win32_Foundation",
]
Expand Down

0 comments on commit 97ff12e

Please sign in to comment.