Windows: make fs
to use workspace windows
crate (#9350)
Release Notes: - N/A
This commit is contained in:
parent
a183c33367
commit
cbf960e979
4 changed files with 6 additions and 11 deletions
|
@ -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))
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue