@@ -27,9 +27,9 @@ pub trait OpenOptionsExt {
2727 /// with the specified value.
2828 ///
2929 /// This will override the `read`, `write`, and `append` flags on the
30- /// `OpenOptions` structure. This method provides fine-grained control
31- /// over the permissions to read, write and append data, attributes
32- /// (like hidden and system) and extended attributes.
30+ /// `OpenOptions` structure. This method provides fine-grained control over
31+ /// the permissions to read, write and append data, attributes (like hidden
32+ /// and system) and extended attributes.
3333 ///
3434 /// # Examples
3535 ///
@@ -38,18 +38,19 @@ pub trait OpenOptionsExt {
3838 /// use std::fs::OpenOptions;
3939 /// use std::os::windows::fs::OpenOptionsExt;
4040 ///
41- /// // Open without read and write permission, for example if you only need to call `stat()`
42- /// // on the file
41+ /// // Open without read and write permission, for example if you only need
42+ /// // to call `stat()` on the file
4343 /// let file = OpenOptions::new().access_mode(0).open("foo.txt");
4444 /// ```
4545 fn access_mode ( & mut self , access : u32 ) -> & mut Self ;
4646
4747 /// Overrides the `dwShareMode` argument to the call to `CreateFile` with
4848 /// the specified value.
4949 ///
50- /// By default `share_mode` is set to `FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE`.
51- /// Specifying less permissions denies others to read from, write to and/or
52- /// delete the file while it is open.
50+ /// By default `share_mode` is set to
51+ /// `FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE`. Specifying
52+ /// less permissions denies others to read from, write to and/or delete the
53+ /// file while it is open.
5354 ///
5455 /// # Examples
5556 ///
@@ -58,17 +59,20 @@ pub trait OpenOptionsExt {
5859 /// use std::fs::OpenOptions;
5960 /// use std::os::windows::fs::OpenOptionsExt;
6061 ///
62+ /// // Do not allow others to read or modify this file while we have it open
63+ /// // for writing
6164 /// let file = OpenOptions::new().write(true)
62- /// .share_mode(0) // Do not allow others to read or modify
65+ /// .share_mode(0)
6366 /// .open("foo.txt");
6467 /// ```
6568 fn share_mode ( & mut self , val : u32 ) -> & mut Self ;
6669
67- /// Sets extra flags for the `dwFileFlags` argument to the call to `CreateFile2`
68- /// (or combines it with `attributes` and `security_qos_flags` to set the
69- /// `dwFlagsAndAttributes` for `CreateFile`).
70+ /// Sets extra flags for the `dwFileFlags` argument to the call to
71+ /// `CreateFile2` (or combines it with `attributes` and `security_qos_flags`
72+ /// to set the `dwFlagsAndAttributes` for `CreateFile`).
7073 ///
7174 /// Custom flags can only set flags, not remove flags set by Rusts options.
75+ /// This options overwrites any previously set custom flags.
7276 ///
7377 /// # Examples
7478 ///
@@ -79,7 +83,9 @@ pub trait OpenOptionsExt {
7983 ///
8084 /// let mut options = OpenOptions::new();
8185 /// options.create(true).write(true);
82- /// if cfg!(windows) { options.custom_flags(winapi::FILE_FLAG_DELETE_ON_CLOSE); }
86+ /// if cfg!(windows) {
87+ /// options.custom_flags(winapi::FILE_FLAG_DELETE_ON_CLOSE);
88+ /// }
8389 /// let file = options.open("foo.txt");
8490 /// ```
8591 #[ unstable( feature = "expand_open_options" ,
@@ -89,15 +95,16 @@ pub trait OpenOptionsExt {
8995
9096 /// Sets the `dwFileAttributes` argument to the call to `CreateFile2` to
9197 /// the specified value (or combines it with `custom_flags` and
92- /// `security_qos_flags` to set the `dwFlagsAndAttributes` for `CreateFile`).
98+ /// `security_qos_flags` to set the `dwFlagsAndAttributes` for
99+ /// `CreateFile`).
93100 ///
94- /// If a _new_ file is created because it does not yet exist and `.create(true)` or
95- /// `.create_new(true)` are specified, the new file is given the attributes declared
96- /// with `.attributes()`.
101+ /// If a _new_ file is created because it does not yet exist and
102+ ///`.create(true)` or `.create_new(true)` are specified, the new file is
103+ /// given the attributes declared with `.attributes()`.
97104 ///
98105 /// If an _existing_ file is opened with `.create(true).truncate(true)`, its
99- /// existing attributes are preserved and combined with the ones declared with
100- /// `.attributes()`.
106+ /// existing attributes are preserved and combined with the ones declared
107+ /// with `.attributes()`.
101108 ///
102109 /// In all other cases the attributes get ignored.
103110 ///
@@ -119,10 +126,6 @@ pub trait OpenOptionsExt {
119126 /// the specified value (or combines it with `custom_flags` and `attributes`
120127 /// to set the `dwFlagsAndAttributes` for `CreateFile`).
121128 fn security_qos_flags ( & mut self , flags : u32 ) -> & mut OpenOptions ;
122-
123- /// Sets the `lpSecurityAttributes` argument to the call to `CreateFile` to
124- /// the specified value.
125- fn security_attributes ( & mut self , attrs : sys:: c:: LPSECURITY_ATTRIBUTES ) -> & mut OpenOptions ;
126129}
127130
128131#[ unstable( feature = "open_options_ext" ,
@@ -148,10 +151,6 @@ impl OpenOptionsExt for OpenOptions {
148151 fn security_qos_flags ( & mut self , flags : u32 ) -> & mut OpenOptions {
149152 self . as_inner_mut ( ) . security_qos_flags ( flags) ; self
150153 }
151-
152- fn security_attributes ( & mut self , attrs : sys:: c:: LPSECURITY_ATTRIBUTES ) -> & mut OpenOptions {
153- self . as_inner_mut ( ) . security_attributes ( attrs) ; self
154- }
155154}
156155
157156/// Extension methods for `fs::Metadata` to access the raw fields contained
0 commit comments