@@ -27,9 +27,9 @@ pub trait OpenOptionsExt {
27
27
/// with the specified value.
28
28
///
29
29
/// 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.
33
33
///
34
34
/// # Examples
35
35
///
@@ -38,18 +38,19 @@ pub trait OpenOptionsExt {
38
38
/// use std::fs::OpenOptions;
39
39
/// use std::os::windows::fs::OpenOptionsExt;
40
40
///
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
43
43
/// let file = OpenOptions::new().access_mode(0).open("foo.txt");
44
44
/// ```
45
45
fn access_mode ( & mut self , access : u32 ) -> & mut Self ;
46
46
47
47
/// Overrides the `dwShareMode` argument to the call to `CreateFile` with
48
48
/// the specified value.
49
49
///
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.
53
54
///
54
55
/// # Examples
55
56
///
@@ -58,17 +59,20 @@ pub trait OpenOptionsExt {
58
59
/// use std::fs::OpenOptions;
59
60
/// use std::os::windows::fs::OpenOptionsExt;
60
61
///
62
+ /// // Do not allow others to read or modify this file while we have it open
63
+ /// // for writing
61
64
/// let file = OpenOptions::new().write(true)
62
- /// .share_mode(0) // Do not allow others to read or modify
65
+ /// .share_mode(0)
63
66
/// .open("foo.txt");
64
67
/// ```
65
68
fn share_mode ( & mut self , val : u32 ) -> & mut Self ;
66
69
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`).
70
73
///
71
74
/// Custom flags can only set flags, not remove flags set by Rusts options.
75
+ /// This options overwrites any previously set custom flags.
72
76
///
73
77
/// # Examples
74
78
///
@@ -79,7 +83,9 @@ pub trait OpenOptionsExt {
79
83
///
80
84
/// let mut options = OpenOptions::new();
81
85
/// 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
+ /// }
83
89
/// let file = options.open("foo.txt");
84
90
/// ```
85
91
#[ unstable( feature = "expand_open_options" ,
@@ -89,15 +95,16 @@ pub trait OpenOptionsExt {
89
95
90
96
/// Sets the `dwFileAttributes` argument to the call to `CreateFile2` to
91
97
/// 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`).
93
100
///
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()`.
97
104
///
98
105
/// 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()`.
101
108
///
102
109
/// In all other cases the attributes get ignored.
103
110
///
@@ -119,10 +126,6 @@ pub trait OpenOptionsExt {
119
126
/// the specified value (or combines it with `custom_flags` and `attributes`
120
127
/// to set the `dwFlagsAndAttributes` for `CreateFile`).
121
128
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 ;
126
129
}
127
130
128
131
#[ unstable( feature = "open_options_ext" ,
@@ -148,10 +151,6 @@ impl OpenOptionsExt for OpenOptions {
148
151
fn security_qos_flags ( & mut self , flags : u32 ) -> & mut OpenOptions {
149
152
self . as_inner_mut ( ) . security_qos_flags ( flags) ; self
150
153
}
151
-
152
- fn security_attributes ( & mut self , attrs : sys:: c:: LPSECURITY_ATTRIBUTES ) -> & mut OpenOptions {
153
- self . as_inner_mut ( ) . security_attributes ( attrs) ; self
154
- }
155
154
}
156
155
157
156
/// Extension methods for `fs::Metadata` to access the raw fields contained
0 commit comments