diff --git a/src/file/imp/windows.rs b/src/file/imp/windows.rs index a8a6f76c4..e7f603843 100644 --- a/src/file/imp/windows.rs +++ b/src/file/imp/windows.rs @@ -19,11 +19,18 @@ fn to_utf16(s: &Path) -> Vec { s.as_os_str().encode_wide().chain(iter::once(0)).collect() } +fn not_supported(msg: &str) -> io::Result { + Err(io::Error::new(io::ErrorKind::Other, msg)) +} + pub fn create_named( path: &Path, open_options: &mut OpenOptions, - _permissions: Option<&std::fs::Permissions>, + permissions: Option<&std::fs::Permissions>, ) -> io::Result { + if permissions.map_or(false, |p| p.readonly()) { + return not_supported("changing permissions is not supported on this platform"); + } open_options .create_new(true) .read(true) diff --git a/src/lib.rs b/src/lib.rs index 798c2276d..b5c9364e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -420,7 +420,8 @@ impl<'a, 'b> Builder<'a, 'b> { /// /// ## Windows and others /// - /// This setting is ignored. + /// This setting is unsupported and trying to set a directory read-only + /// will cause an error to be returned.. /// /// # Limitations ///