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
#[allow(unused_imports)]
use crate::fs::open_unchecked;
use crate::fs::{dir_options, open, open_ambient_dir_impl, readdir_options, FollowSymlinks};
use ambient_authority::AmbientAuthority;
use std::path::{Component, Path};
use std::{fs, io};
#[inline]
pub fn open_dir(start: &fs::File, path: &Path) -> io::Result<fs::File> {
open(start, path, &dir_options())
}
#[cfg(not(windows))]
#[inline]
pub(crate) fn open_dir_for_reading(
start: &fs::File,
path: &Path,
follow: FollowSymlinks,
) -> io::Result<fs::File> {
open(start, path, readdir_options().follow(follow))
}
#[inline]
pub fn open_dir_nofollow(start: &fs::File, path: &Path) -> io::Result<fs::File> {
open(start, path, dir_options().follow(FollowSymlinks::No))
}
#[inline]
#[allow(dead_code)]
pub(crate) fn open_dir_unchecked(start: &fs::File, path: &Path) -> io::Result<fs::File> {
open_unchecked(start, path, &dir_options()).map_err(Into::into)
}
#[inline]
#[allow(dead_code)]
pub(crate) fn open_dir_for_reading_unchecked(
start: &fs::File,
path: &Path,
follow: FollowSymlinks,
) -> io::Result<fs::File> {
open_unchecked(start, path, readdir_options().follow(follow)).map_err(Into::into)
}
#[inline]
pub fn open_ambient_dir(path: &Path, ambient_authority: AmbientAuthority) -> io::Result<fs::File> {
open_ambient_dir_impl(path, ambient_authority)
}
#[inline]
pub fn open_parent_dir(
start: &fs::File,
ambient_authority: AmbientAuthority,
) -> io::Result<fs::File> {
let _ = ambient_authority;
open_dir_unchecked(start, Component::ParentDir.as_ref())
}