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
#[cfg(racy_asserts)]
#[macro_use]
pub(crate) mod assert_same_file;
mod canonicalize;
mod copy;
mod create_dir;
mod dir_builder;
mod dir_entry;
mod dir_options;
#[cfg(not(any(target_os = "android", target_os = "linux", windows)))]
mod file_path_by_searching;
mod file_type;
mod follow_symlinks;
mod hard_link;
mod is_read_write;
mod maybe_owned_file;
mod metadata;
mod open;
mod open_dir;
mod open_options;
mod open_unchecked_error;
mod permissions;
mod read_dir;
mod read_link;
mod remove_dir;
mod remove_dir_all;
mod remove_file;
mod remove_open_dir;
mod rename;
mod reopen;
mod set_permissions;
mod set_times;
mod stat;
mod symlink;
mod system_time_spec;
pub(crate) mod errors;
pub(crate) mod manually;
pub(crate) mod via_parent;
use maybe_owned_file::MaybeOwnedFile;
#[cfg(not(any(target_os = "android", target_os = "linux", windows)))]
pub(crate) use file_path_by_searching::file_path_by_searching;
pub(crate) use open_unchecked_error::*;
#[cfg(not(windows))]
pub(crate) use super::posish::fs::*;
#[cfg(windows)]
pub(crate) use super::windows::fs::*;
pub use canonicalize::*;
pub use copy::*;
pub use create_dir::*;
pub use dir_builder::*;
pub use dir_entry::*;
pub use dir_options::*;
pub use file_type::*;
pub use follow_symlinks::*;
pub use hard_link::*;
pub use is_read_write::is_read_write;
pub use metadata::*;
pub use open::*;
pub use open_dir::*;
pub use open_options::*;
pub use permissions::*;
pub use read_dir::*;
pub use read_link::*;
pub use remove_dir::*;
pub use remove_dir_all::*;
pub use remove_file::*;
pub use remove_open_dir::*;
pub use rename::*;
pub use reopen::reopen;
pub use set_permissions::*;
pub use set_times::*;
pub use stat::*;
pub use symlink::*;
pub use system_time_spec::*;
#[cfg(racy_asserts)]
fn map_result<T: Clone>(result: &std::io::Result<T>) -> Result<T, (std::io::ErrorKind, String)> {
match result {
Ok(t) => Ok(t.clone()),
Err(e) => Err((e.kind(), e.to_string())),
}
}
#[test]
fn dir_paths() {
for path in &[std::env::current_dir().unwrap(), std::env::temp_dir()] {
let dir = unsafe { open_ambient_dir(&path).unwrap() };
assert_eq!(
file_path(&dir)
.as_ref()
.map(std::fs::canonicalize)
.map(Result::unwrap),
Some(std::fs::canonicalize(path).unwrap())
);
}
}