pub struct SourceDirectory { /* private fields */ }Expand description
A directory beneath the root. Every name is a single entry of it.
Implementations§
Source§impl SourceDirectory
impl SourceDirectory
Sourcepub fn write(
&self,
name: &str,
access: Option<&Access>,
bytes: &[u8],
) -> Result<(), AccessError>
pub fn write( &self, name: &str, access: Option<&Access>, bytes: &[u8], ) -> Result<(), AccessError>
Writes a new file name with bytes and syncs it. Whatever was at
name is removed first, so a link or hard link there is never
written through. With access, the file is its owner’s alone until
written, then takes that mode and group, and on Linux no access
control list it would get from the directory; it must have the
labels of access, which is checked before anything is written.
Where there are no modes, it is read-only if access has no write
bits. Without access, it has the platform’s default.
Sourcepub fn access(&self, name: &str) -> Result<Option<Access>, AccessError>
pub fn access(&self, name: &str) -> Result<Option<Access>, AccessError>
Who may use the regular file name; None when there is no regular
file there. A file whose access publishing could not keep is
refused: on Linux one with an access control list, and on Windows a
read-only or encrypted one. macOS and
Windows access control lists are neither read nor kept.
Sourcepub fn own_access(&self) -> Result<Access, AccessError>
pub fn own_access(&self) -> Result<Access, AccessError>
Who may use this directory. On Linux, a directory with an access control list, its own or one it gives new files, is refused.
Sourcepub fn set_own_access(&self, access: &Access) -> Result<(), AccessError>
pub fn set_own_access(&self, access: &Access) -> Result<(), AccessError>
Gives this directory the mode and group of access, and checks that
it has the labels of access.
Sourcepub fn check_final_name(
&self,
staged: &str,
name: &str,
) -> Result<(), AccessError>
pub fn check_final_name( &self, staged: &str, name: &str, ) -> Result<(), AccessError>
Checks, before either is made, that a file made here as name would
get the access control beside the mode bits that one made as
staged would: on Linux with SELinux, the label its policy gives a
new file of that name, which may depend on the name and is not given
again on renaming. Elsewhere there is nothing to check.
Sourcepub fn rename(&self, from: &str, to: &str) -> Result<(), AccessError>
pub fn rename(&self, from: &str, to: &str) -> Result<(), AccessError>
Renames from to to, replacing to, atomically.
Sourcepub fn remove_file(&self, name: &str) -> Result<bool, AccessError>
pub fn remove_file(&self, name: &str) -> Result<bool, AccessError>
Removes the file name; false when there was none.
Sourcepub fn remove_directory(&self, name: &str) -> Result<bool, AccessError>
pub fn remove_directory(&self, name: &str) -> Result<bool, AccessError>
Removes the directory name if it is empty; false when it is
missing or not empty.
Sourcepub fn unchecked_file_system(
&self,
mounts: &Mounts,
) -> Result<Option<String>, AccessError>
pub fn unchecked_file_system( &self, mounts: &Mounts, ) -> Result<Option<String>, AccessError>
The file system this directory is on, in words, where publishing
does not read the access control lists of what is in it: on Linux
any but the local ones that keep them as the attributes publishing
reads (ext2, ext3, ext4, XFS, Btrfs, tmpfs, F2FS, ZFS and bcachefs),
so network, host-shared (such as WSL’s Windows drives or a virtual
machine’s shared folders), FUSE, NTFS and stacked ones (overlayfs)
among them. The directory’s mount is found by its ID in mounts,
and both the type the kernel names it with and the magic number
statfs gives must be such a file system’s; one that cannot be
told, as where /proc cannot be read or the mount’s line is
malformed, is not checked
either, and says why. None where it is checked, and on other
platforms, which do not read access control lists at all.
Sourcepub fn sync(&self) -> Result<bool, AccessError>
pub fn sync(&self) -> Result<bool, AccessError>
Syncs the directory, making renames and removals in it durable.
Returns false on platforms that cannot sync a directory, where
they may not be durable yet.