From ebcea0128c83e6ace0fe98ff6a01a315f0cde325 Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Sun, 19 Mar 2017 11:09:15 +0900 Subject: [PATCH] Getting the FLAG from the winapi module. --- Cargo.toml | 6 +++--- src/directory/mmap_directory.rs | 8 +++++--- src/lib.rs | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7df8882db..f6fd20cc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,8 +24,6 @@ rustc-serialize = "0.3" log = "0.3.6" combine = "2.2" tempdir = "0.3" - - bincode = "0.5" libc = {version = "0.2.20", optional=true} num_cpus = "1.2" @@ -37,10 +35,12 @@ uuid = { version = "0.4", features = ["v4", "rustc-serialize"] } chan = "0.1" version = "2" crossbeam = "0.2" - futures = "0.1.9" futures-cpupool = "0.1.2" +[target.'cfg(windows)'.dependencies] +winapi = "*" + [dev-dependencies] rand = "0.3" diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index 9b466f0dc..2f6224185 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -23,6 +23,10 @@ use std::sync::RwLock; use std::sync::Weak; use tempdir::TempDir; +#[cfg(windows)] +use winapi::winbase::FILE_FLAG_BACKUP_SEMANTICS; + + fn open_mmap(full_path: &PathBuf) -> result::Result>, FileError> { let convert_file_error = |err: io::Error| { @@ -231,11 +235,9 @@ impl MmapDirectory { #[cfg(windows)] { use std::os::windows::fs::OpenOptionsExt; - const FILE_FLAG_BACKUP_SEMANTICS: u32 = 0x02000000; - open_opts.write(true) .custom_flags(FILE_FLAG_BACKUP_SEMANTICS); - }; + } let fd = try!(open_opts.open(&self.root_path)); try!(fd.sync_all()); diff --git a/src/lib.rs b/src/lib.rs index 81d9acc24..46fb75abc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,6 +51,9 @@ extern crate futures_cpupool; #[cfg(feature="simdcompression")] extern crate libc; +#[cfg(windows)] +extern crate winapi; + #[cfg(test)] extern crate test; #[cfg(test)] extern crate rand;