/rust/registry/src/index.crates.io-6f17d22bba15001f/rustix-0.38.44/src/fs/mod.rs
Line | Count | Source (jump to first uncovered line) |
1 | | //! Filesystem operations. |
2 | | |
3 | | mod abs; |
4 | | #[cfg(not(target_os = "redox"))] |
5 | | mod at; |
6 | | mod constants; |
7 | | #[cfg(linux_kernel)] |
8 | | mod copy_file_range; |
9 | | #[cfg(not(any(target_os = "espidf", target_os = "redox")))] |
10 | | mod cwd; |
11 | | #[cfg(all(feature = "alloc", not(any(target_os = "espidf", target_os = "redox"))))] |
12 | | mod dir; |
13 | | #[cfg(not(any( |
14 | | apple, |
15 | | netbsdlike, |
16 | | target_os = "solaris", |
17 | | target_os = "dragonfly", |
18 | | target_os = "espidf", |
19 | | target_os = "haiku", |
20 | | target_os = "redox", |
21 | | target_os = "vita", |
22 | | )))] |
23 | | mod fadvise; |
24 | | pub(crate) mod fcntl; |
25 | | #[cfg(apple)] |
26 | | mod fcntl_apple; |
27 | | #[cfg(apple)] |
28 | | mod fcopyfile; |
29 | | pub(crate) mod fd; |
30 | | #[cfg(all(apple, feature = "alloc"))] |
31 | | mod getpath; |
32 | | #[cfg(not(target_os = "wasi"))] // WASI doesn't have get[gpu]id. |
33 | | mod id; |
34 | | #[cfg(linux_kernel)] |
35 | | pub mod inotify; |
36 | | #[cfg(linux_kernel)] |
37 | | mod ioctl; |
38 | | #[cfg(not(any( |
39 | | target_os = "espidf", |
40 | | target_os = "haiku", |
41 | | target_os = "redox", |
42 | | target_os = "vita", |
43 | | target_os = "wasi" |
44 | | )))] |
45 | | mod makedev; |
46 | | #[cfg(any(linux_kernel, target_os = "freebsd"))] |
47 | | mod memfd_create; |
48 | | #[cfg(linux_kernel)] |
49 | | #[cfg(feature = "fs")] |
50 | | mod mount; |
51 | | #[cfg(linux_kernel)] |
52 | | mod openat2; |
53 | | #[cfg(linux_kernel)] |
54 | | mod raw_dir; |
55 | | mod seek_from; |
56 | | #[cfg(target_os = "linux")] |
57 | | mod sendfile; |
58 | | #[cfg(not(any(target_os = "espidf", target_os = "redox")))] |
59 | | mod special; |
60 | | #[cfg(linux_kernel)] |
61 | | mod statx; |
62 | | #[cfg(not(any( |
63 | | target_os = "espidf", |
64 | | target_os = "redox", |
65 | | target_os = "vita", |
66 | | target_os = "wasi" |
67 | | )))] |
68 | | mod sync; |
69 | | #[cfg(any(apple, linux_kernel, target_os = "hurd"))] |
70 | | mod xattr; |
71 | | |
72 | | pub use abs::*; |
73 | | #[cfg(not(target_os = "redox"))] |
74 | | pub use at::*; |
75 | | pub use constants::*; |
76 | | #[cfg(linux_kernel)] |
77 | | pub use copy_file_range::copy_file_range; |
78 | | #[cfg(not(any(target_os = "espidf", target_os = "redox")))] |
79 | | pub use cwd::*; |
80 | | #[cfg(all(feature = "alloc", not(any(target_os = "espidf", target_os = "redox"))))] |
81 | | pub use dir::{Dir, DirEntry}; |
82 | | #[cfg(not(any( |
83 | | apple, |
84 | | netbsdlike, |
85 | | target_os = "solaris", |
86 | | target_os = "dragonfly", |
87 | | target_os = "espidf", |
88 | | target_os = "haiku", |
89 | | target_os = "redox", |
90 | | target_os = "vita", |
91 | | )))] |
92 | | pub use fadvise::fadvise; |
93 | | pub use fcntl::*; |
94 | | #[cfg(apple)] |
95 | | pub use fcntl_apple::*; |
96 | | #[cfg(apple)] |
97 | | pub use fcopyfile::*; |
98 | | pub use fd::*; |
99 | | #[cfg(all(apple, feature = "alloc"))] |
100 | | pub use getpath::getpath; |
101 | | #[cfg(not(target_os = "wasi"))] |
102 | | pub use id::*; |
103 | | #[cfg(linux_kernel)] |
104 | | pub use ioctl::*; |
105 | | #[cfg(not(any( |
106 | | target_os = "espidf", |
107 | | target_os = "haiku", |
108 | | target_os = "redox", |
109 | | target_os = "vita", |
110 | | target_os = "wasi" |
111 | | )))] |
112 | | pub use makedev::*; |
113 | | #[cfg(any(linux_kernel, target_os = "freebsd"))] |
114 | | pub use memfd_create::memfd_create; |
115 | | #[cfg(linux_kernel)] |
116 | | #[cfg(feature = "fs")] |
117 | | pub use mount::*; |
118 | | #[cfg(linux_kernel)] |
119 | | pub use openat2::openat2; |
120 | | #[cfg(linux_kernel)] |
121 | | pub use raw_dir::{RawDir, RawDirEntry}; |
122 | | pub use seek_from::SeekFrom; |
123 | | #[cfg(target_os = "linux")] |
124 | | pub use sendfile::sendfile; |
125 | | #[cfg(not(any(target_os = "espidf", target_os = "redox")))] |
126 | | pub use special::*; |
127 | | #[cfg(linux_kernel)] |
128 | | pub use statx::statx; |
129 | | #[cfg(not(any( |
130 | | target_os = "espidf", |
131 | | target_os = "redox", |
132 | | target_os = "vita", |
133 | | target_os = "wasi" |
134 | | )))] |
135 | | pub use sync::sync; |
136 | | #[cfg(any(apple, linux_kernel, target_os = "hurd"))] |
137 | | pub use xattr::*; |
138 | | |
139 | | /// Re-export types common to POSIX-ish platforms. |
140 | | #[cfg(feature = "std")] |
141 | | #[cfg(unix)] |
142 | | pub use std::os::unix::fs::{DirEntryExt, FileExt, FileTypeExt, MetadataExt, OpenOptionsExt}; |
143 | | #[cfg(feature = "std")] |
144 | | #[cfg(all(wasi_ext, target_os = "wasi"))] |
145 | | pub use std::os::wasi::fs::{DirEntryExt, FileExt, FileTypeExt, MetadataExt, OpenOptionsExt}; |
146 | | |
147 | | /// Extension trait for accessing timestamp fields of `Stat`. |
148 | | /// |
149 | | /// Rustix's `Stat` type on some platforms has unsigned `st_mtime`, |
150 | | /// `st_atime`, and `st_ctime` fields. This is incorrect, as Unix defines |
151 | | /// these fields to be signed, with negative values representing dates before |
152 | | /// the Unix epoch. Until the next semver bump, these unsigned fields are |
153 | | /// deprecated, and this trait provides accessors which return their values |
154 | | /// as signed integers. |
155 | | #[cfg(unix)] |
156 | | pub trait StatExt { |
157 | | /// Return the value of the `st_atime` field, casted to the correct type. |
158 | | fn atime(&self) -> i64; |
159 | | /// Return the value of the `st_mtime` field, casted to the correct type. |
160 | | fn mtime(&self) -> i64; |
161 | | /// Return the value of the `st_ctime` field, casted to the correct type. |
162 | | fn ctime(&self) -> i64; |
163 | | } |
164 | | |
165 | | #[cfg(all( |
166 | | unix, |
167 | | not(any(target_os = "aix", target_os = "hurd", target_os = "nto")) |
168 | | ))] |
169 | | #[allow(deprecated)] |
170 | | impl StatExt for Stat { |
171 | | #[inline] |
172 | 0 | fn atime(&self) -> i64 { |
173 | 0 | self.st_atime as i64 |
174 | 0 | } |
175 | | |
176 | | #[inline] |
177 | 0 | fn mtime(&self) -> i64 { |
178 | 0 | self.st_mtime as i64 |
179 | 0 | } |
180 | | |
181 | | #[inline] |
182 | 0 | fn ctime(&self) -> i64 { |
183 | 0 | self.st_ctime as i64 |
184 | 0 | } |
185 | | } |
186 | | |
187 | | #[cfg(any(target_os = "aix", target_os = "hurd", target_os = "nto"))] |
188 | | #[allow(deprecated)] |
189 | | impl StatExt for Stat { |
190 | | #[inline] |
191 | | fn atime(&self) -> i64 { |
192 | | self.st_atim.tv_sec as i64 |
193 | | } |
194 | | |
195 | | #[inline] |
196 | | fn mtime(&self) -> i64 { |
197 | | self.st_mtim.tv_sec as i64 |
198 | | } |
199 | | |
200 | | #[inline] |
201 | | fn ctime(&self) -> i64 { |
202 | | self.st_ctim.tv_sec as i64 |
203 | | } |
204 | | } |