diff --git a/packages/tauri/src/gb_repository/repository.rs b/packages/tauri/src/gb_repository/repository.rs index f2f9996ba..6715dc04d 100644 --- a/packages/tauri/src/gb_repository/repository.rs +++ b/packages/tauri/src/gb_repository/repository.rs @@ -5,6 +5,8 @@ use std::{ path, time, }; +#[cfg(target_os = "windows")] +use crate::windows::*; #[cfg(target_family = "unix")] use std::os::unix::prelude::*; diff --git a/packages/tauri/src/lib.rs b/packages/tauri/src/lib.rs index a38891de5..2519e6aa5 100644 --- a/packages/tauri/src/lib.rs +++ b/packages/tauri/src/lib.rs @@ -1,4 +1,5 @@ #![feature(error_generic_member_access)] +#![cfg_attr(target_os = "windows", feature(windows_by_handle))] pub mod analytics; pub mod app; @@ -29,6 +30,8 @@ pub mod types; pub mod users; pub mod virtual_branches; pub mod watcher; +#[cfg(target_os = "windows")] +pub(crate) mod windows; pub mod writer; pub mod zip; diff --git a/packages/tauri/src/windows.rs b/packages/tauri/src/windows.rs new file mode 100644 index 000000000..5db18691b --- /dev/null +++ b/packages/tauri/src/windows.rs @@ -0,0 +1,23 @@ +use std::os::windows::fs::MetadataExt; + +pub trait MetadataShim { + fn ino(&self) -> u64; + fn dev(&self) -> u64; + fn uid(&self) -> u32; + fn gid(&self) -> u32; +} + +impl MetadataShim for std::fs::Metadata { + fn ino(&self) -> u64 { + self.file_index().expect("file metadata constructed based on directory listing instead of a file (see https://doc.rust-lang.org/std/os/windows/fs/trait.MetadataExt.html#tymethod.file_index)") + } + fn dev(&self) -> u64 { + self.volume_serial_number().expect("file metadata constructed based on directory listing instead of a file (see https://doc.rust-lang.org/std/os/windows/fs/trait.MetadataExt.html#tymethod.volume_serial_number)") as u64 + } + fn uid(&self) -> u32 { + 0 + } + fn gid(&self) -> u32 { + 0 + } +}