about summary refs log tree commit diff
path: root/src/libstd/sys/windows
diff options
context:
space:
mode:
authorPaul Dicker <pitdicker@gmail.com>2016-01-13 21:47:46 +0100
committerPaul Dicker <pitdicker@gmail.com>2016-01-13 21:47:46 +0100
commit7a1817c9d4a0649a7ea1c948bd731a5b63aa3d06 (patch)
tree2e1f2d70228636bb1ec4023e03adc422676ccf2c /src/libstd/sys/windows
parent42f4dd047af2de895df2754f7222b39f10cb6205 (diff)
downloadrust-7a1817c9d4a0649a7ea1c948bd731a5b63aa3d06.tar.gz
rust-7a1817c9d4a0649a7ea1c948bd731a5b63aa3d06.zip
Move `custom_flags` to `OpenOptionsExt`
And mark the new methods as unstable.
Diffstat (limited to 'src/libstd/sys/windows')
-rw-r--r--src/libstd/sys/windows/ext/fs.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs
index fa7e0e564ac..04053b6cb6a 100644
--- a/src/libstd/sys/windows/ext/fs.rs
+++ b/src/libstd/sys/windows/ext/fs.rs
@@ -64,6 +64,28 @@ pub trait OpenOptionsExt {
     /// ```
     fn share_mode(&mut self, val: u32) -> &mut Self;
 
+    /// Sets extra flags for the `dwFileFlags` argument to the call to `CreateFile2`
+    /// (or combines it with `attributes` and `security_qos_flags` to set the
+    /// `dwFlagsAndAttributes` for `CreateFile`).
+    ///
+    /// Custom flags can only set flags, not remove flags set by Rusts options.
+    ///
+    /// # Examples
+    ///
+    /// ```rust,ignore
+    /// extern crate winapi;
+    /// use std::fs::OpenOptions;
+    /// use std::os::windows::fs::OpenOptionsExt;
+    ///
+    /// let options = OpenOptions::new().create(true).write(true);
+    /// if cfg!(windows) { options.custom_flags(winapi::FILE_FLAG_DELETE_ON_CLOSE); }
+    /// let file = options.open("foo.txt");
+    /// ```
+    #[unstable(feature = "expand_open_options",
+               reason = "recently added",
+               issue = "30014")]
+    fn custom_flags(&mut self, flags: u32) -> &mut Self;
+
     /// Sets the `dwFileAttributes` argument to the call to `CreateFile2` to
     /// the specified value (or combines it with `custom_flags` and
     /// `security_qos_flags` to set the `dwFlagsAndAttributes` for `CreateFile`).
@@ -114,6 +136,10 @@ impl OpenOptionsExt for OpenOptions {
         self.as_inner_mut().share_mode(share); self
     }
 
+    fn custom_flags(&mut self, flags: u32) -> &mut OpenOptions {
+        self.as_inner_mut().custom_flags(flags); self
+    }
+
     fn attributes(&mut self, attributes: u32) -> &mut OpenOptions {
         self.as_inner_mut().attributes(attributes); self
     }