Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Windows: make `fs` to use workspace `windows` crate (#9350)

张小白cbf960e9798d
diff --git a/Cargo.lock b/Cargo.lock
index 458f1a88351..8af76cf35bd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3920,7 +3920,7 @@ dependencies = [
"text",
"time",
"util",
- "windows-sys 0.52.0",
+ "windows 0.53.0",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 62b33df5872..2a116f2bd82 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -343,6 +343,7 @@ features = [
"Win32_Graphics_DirectComposition",
"Win32_Graphics_Gdi",
"Win32_Security",
+ "Win32_Storage_FileSystem",
"Win32_System_Com",
"Win32_System_Com_StructuredStorage",
"Win32_System_DataExchange",
diff --git a/crates/fs/Cargo.toml b/crates/fs/Cargo.toml
index 1e6fb625691..1ad427de5cd 100644
--- a/crates/fs/Cargo.toml
+++ b/crates/fs/Cargo.toml
@@ -43,10 +43,7 @@ fsevent.workspace = true
notify = "6.1.1"
[target.'cfg(target_os = "windows")'.dependencies]
-windows-sys = { version = "0.52", features = [
- "Win32_Foundation",
- "Win32_Storage_FileSystem",
-] }
+windows.workspace = true
[dev-dependencies]
gpui = { workspace = true, features = ["test-support"] }
diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs
index 9bf67013ece..1a7638c640d 100644
--- a/crates/fs/src/fs.rs
+++ b/crates/fs/src/fs.rs
@@ -1495,7 +1495,7 @@ async fn file_id(path: impl AsRef<Path>) -> Result<u64> {
use std::os::windows::io::AsRawHandle;
use smol::fs::windows::OpenOptionsExt;
- use windows_sys::Win32::{
+ use windows::Win32::{
Foundation::HANDLE,
Storage::FileSystem::{
GetFileInformationByHandle, BY_HANDLE_FILE_INFORMATION, FILE_FLAG_BACKUP_SEMANTICS,
@@ -1504,7 +1504,7 @@ async fn file_id(path: impl AsRef<Path>) -> Result<u64> {
let file = smol::fs::OpenOptions::new()
.read(true)
- .custom_flags(FILE_FLAG_BACKUP_SEMANTICS)
+ .custom_flags(FILE_FLAG_BACKUP_SEMANTICS.0)
.open(path)
.await?;
@@ -1512,10 +1512,7 @@ async fn file_id(path: impl AsRef<Path>) -> Result<u64> {
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfileinformationbyhandle
// This function supports Windows XP+
smol::unblock(move || {
- let ret = unsafe { GetFileInformationByHandle(file.as_raw_handle() as HANDLE, &mut info) };
- if ret == 0 {
- return Err(anyhow!(format!("{}", std::io::Error::last_os_error())));
- };
+ unsafe { GetFileInformationByHandle(HANDLE(file.as_raw_handle() as _), &mut info)? };
Ok(((info.nFileIndexHigh as u64) << 32) | (info.nFileIndexLow as u64))
})