From 1e0ac31e11426d71238fcb86d43febf360f79e06 Mon Sep 17 00:00:00 2001 From: Laurentiu Nicola Date: Mon, 20 Mar 2017 23:12:48 +0200 Subject: [PATCH] Clarify comment and use qualified import for the flag --- src/directory/mmap_directory.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index 2f6224185..6b2730a4b 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -23,11 +23,6 @@ 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| { if err.kind() == io::ErrorKind::NotFound { @@ -226,8 +221,8 @@ impl MmapDirectory { fn sync_directory(&self) -> Result<(), io::Error> { let mut open_opts = OpenOptions::new(); - // Linux needs read to be set, or otherwise returns EINVAL - // and fails with EISDIR if write is set + // Linux needs read to be set, otherwise returns EINVAL + // write must not be set, or it fails with EISDIR open_opts.read(true); // On Windows, opening a directory requires FILE_FLAG_BACKUP_SEMANTICS @@ -235,8 +230,10 @@ impl MmapDirectory { #[cfg(windows)] { use std::os::windows::fs::OpenOptionsExt; + use winapi::winbase; + open_opts.write(true) - .custom_flags(FILE_FLAG_BACKUP_SEMANTICS); + .custom_flags(winbase::FILE_FLAG_BACKUP_SEMANTICS); } let fd = try!(open_opts.open(&self.root_path));