1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#![stable(feature = "rust1", since = "1.0.0")]
use fs::{OpenOptions, Metadata};
use io;
use path::Path;
use sys;
use sys_common::{AsInnerMut, AsInner};
#[unstable(feature = "open_options_ext",
reason = "may require more thought/methods",
issue = "27720")]
pub trait OpenOptionsExt {
fn desired_access(&mut self, access: u32) -> &mut Self;
fn creation_disposition(&mut self, val: u32) -> &mut Self;
fn flags_and_attributes(&mut self, val: u32) -> &mut Self;
fn share_mode(&mut self, val: u32) -> &mut Self;
}
#[unstable(feature = "open_options_ext",
reason = "may require more thought/methods",
issue = "27720")]
impl OpenOptionsExt for OpenOptions {
fn desired_access(&mut self, access: u32) -> &mut OpenOptions {
self.as_inner_mut().desired_access(access); self
}
fn creation_disposition(&mut self, access: u32) -> &mut OpenOptions {
self.as_inner_mut().creation_disposition(access); self
}
fn flags_and_attributes(&mut self, access: u32) -> &mut OpenOptions {
self.as_inner_mut().flags_and_attributes(access); self
}
fn share_mode(&mut self, access: u32) -> &mut OpenOptions {
self.as_inner_mut().share_mode(access); self
}
}
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn file_attributes(&self) -> u32;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn creation_time(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn last_access_time(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn last_write_time(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn file_size(&self) -> u64;
}
#[stable(feature = "metadata_ext", since = "1.1.0")]
impl MetadataExt for Metadata {
fn file_attributes(&self) -> u32 { self.as_inner().attrs() }
fn creation_time(&self) -> u64 { self.as_inner().created() }
fn last_access_time(&self) -> u64 { self.as_inner().accessed() }
fn last_write_time(&self) -> u64 { self.as_inner().modified() }
fn file_size(&self) -> u64 { self.as_inner().size() }
}
#[stable(feature = "symlink", since = "1.1.0")]
pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q)
-> io::Result<()> {
sys::fs::symlink_inner(src.as_ref(), dst.as_ref(), false)
}
#[stable(feature = "symlink", since = "1.1.0")]
pub fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q)
-> io::Result<()> {
sys::fs::symlink_inner(src.as_ref(), dst.as_ref(), true)
}