Skip to content

Commit b982df8

Browse files
committed
Update to winx 0.23.0.
Use `winapi_util::file::information` in place of `winx::file::get_fileinfo`, which is simpler, except for needing to convert the types, which we need to do because we're ultimately using these values in the [windows `MetadataExt` trait] which uses `u32`. I submitted BurntSushi/winapi-util#7 to propose changing the types upstream. [windows `MetadataExt` trait]: https://doc.rust-lang.org/stable/std/os/windows/fs/trait.MetadataExt.html
1 parent 827d922 commit b982df8

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ libc = "0.2.81"
3636
# for testing here.
3737
nt_version = "0.1.3"
3838
winapi = "0.3.9"
39-
winx = "0.22.0"
39+
winx = "0.23.0"
4040

4141
[features]
4242
default = []

cap-primitives/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ errno = "0.2.7"
3737
errno = "0.2.7"
3838

3939
[target.'cfg(windows)'.dependencies]
40-
winx = "0.22.0"
40+
winx = "0.23.0"
4141
winapi = { version = "0.3.9", features = [
4242
"ioapiset",
4343
"winioctl"

cap-primitives/src/windows/fs/dir_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use std::{
99
},
1010
path::{Path, PathBuf},
1111
};
12+
use winapi::um::winbase::FILE_FLAG_BACKUP_SEMANTICS;
1213
use winapi::um::winnt;
13-
use winx::file::Flags;
1414

1515
/// Rust's `Path` implicitly strips redundant slashes, however they aren't
1616
/// redundant in one case: at the end of a path they indicate that a path is
@@ -68,7 +68,7 @@ pub(crate) fn dir_options() -> OpenOptions {
6868
OpenOptions::new()
6969
.read(true)
7070
.dir_required(true)
71-
.custom_flags(Flags::FILE_FLAG_BACKUP_SEMANTICS.bits())
71+
.custom_flags(FILE_FLAG_BACKUP_SEMANTICS)
7272
.share_mode(winnt::FILE_SHARE_READ | winnt::FILE_SHARE_WRITE)
7373
.clone()
7474
}
@@ -83,7 +83,7 @@ pub(crate) fn readdir_options() -> OpenOptions {
8383
pub(crate) fn canonicalize_options() -> OpenOptions {
8484
OpenOptions::new()
8585
.read(true)
86-
.custom_flags(Flags::FILE_FLAG_BACKUP_SEMANTICS.bits())
86+
.custom_flags(FILE_FLAG_BACKUP_SEMANTICS)
8787
.clone()
8888
}
8989

@@ -100,7 +100,7 @@ pub(crate) unsafe fn open_ambient_dir_impl(path: &Path) -> io::Result<fs::File>
100100
// underneath us, since we use paths to implement many directory operations.
101101
let dir = fs::OpenOptions::new()
102102
.read(true)
103-
.custom_flags(Flags::FILE_FLAG_BACKUP_SEMANTICS.bits())
103+
.custom_flags(FILE_FLAG_BACKUP_SEMANTICS)
104104
.share_mode(winnt::FILE_SHARE_READ | winnt::FILE_SHARE_WRITE)
105105
.open(&path)?;
106106

cap-primitives/src/windows/fs/metadata_ext.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::useless_conversion)]
22

3-
use std::{fs, io};
3+
use std::{convert::TryInto, fs, io};
44

55
#[derive(Debug, Clone)]
66
pub(crate) struct MetadataExt {
@@ -38,17 +38,19 @@ impl MetadataExt {
3838

3939
#[cfg(not(windows_by_handle))]
4040
if volume_serial_number.is_none() || number_of_links.is_none() || file_index.is_none() {
41-
let fileinfo = winx::file::get_fileinfo(file)?;
41+
let fileinfo = winapi_util::file::information(file)?;
4242
if volume_serial_number.is_none() {
43-
volume_serial_number = Some(fileinfo.dwVolumeSerialNumber);
43+
let t64: u64 = fileinfo.volume_serial_number();
44+
let t32: u32 = t64.try_into().unwrap();
45+
volume_serial_number = Some(t32);
4446
}
4547
if number_of_links.is_none() {
46-
number_of_links = Some(fileinfo.nNumberOfLinks);
48+
let t64: u64 = fileinfo.number_of_links();
49+
let t32: u32 = t64.try_into().unwrap();
50+
number_of_links = Some(t32);
4751
}
4852
if file_index.is_none() {
49-
file_index = Some(
50-
(u64::from(fileinfo.nFileIndexHigh) << 32) | u64::from(fileinfo.nFileIndexLow),
51-
);
53+
file_index = Some(fileinfo.file_index());
5254
}
5355
}
5456

cap-primitives/src/windows/fs/oflags.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::fs::{FollowSymlinks, OpenOptions};
22
use std::{fs, os::windows::fs::OpenOptionsExt};
3-
use winx::file::Flags;
3+
use winapi::um::winbase::{FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT};
44

55
/// Translate the given `cap_std` into `std` options. Also return a bool
66
/// indicating that the `trunc` flag was requested but could not be set,
@@ -18,11 +18,11 @@ pub(in super::super) fn open_options_to_std(opts: &OpenOptions) -> (fs::OpenOpti
1818
manually_trunc = true;
1919
trunc = false;
2020
}
21-
opts.ext.custom_flags | Flags::FILE_FLAG_OPEN_REPARSE_POINT.bits()
21+
opts.ext.custom_flags | FILE_FLAG_OPEN_REPARSE_POINT
2222
}
2323
};
2424
if opts.maybe_dir {
25-
custom_flags |= Flags::FILE_FLAG_BACKUP_SEMANTICS.bits();
25+
custom_flags |= FILE_FLAG_BACKUP_SEMANTICS;
2626
}
2727
let mut std_opts = fs::OpenOptions::new();
2828
std_opts

cap-time-ext/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ posish = "0.5.2"
2222

2323
[target.'cfg(windows)'.dependencies]
2424
once_cell = "1.5.2"
25-
winx = "0.22.0"
25+
winx = "0.23.0"
2626

2727
[badges]
2828
maintenance = { status = "actively-developed" }

0 commit comments

Comments
 (0)