pub struct LinkPath { /* private fields */ }Expand description
A guest path resolved for an operation that acts on the link itself.
Carries the parent directory handle plus the final component name. Parent
components are traversed under containment; the final one is never followed, so a
stale escaping link inside the root stays inspectable and removable while an
ordinary internal link such as node_modules/.bin/* still stats.
The shape is the enforcement: a content operation cannot be expressed through this value, because the final component is unreachable to a following open.
Implementations§
Source§impl LinkPath
impl LinkPath
Sourcepub fn is_root(&self) -> bool
pub fn is_root(&self) -> bool
Whether this names the root of its volume — the VFS root or a mount point — rather than an entry inside it.
Sourcepub fn writable(&self) -> Result<(), ContainError>
pub fn writable(&self) -> Result<(), ContainError>
Sourcepub fn contains_mount_point(&self) -> Result<Option<Arc<str>>, ContainError>
pub fn contains_mount_point(&self) -> Result<Option<Arc<str>>, ContainError>
A mount point strictly below this path, as written or where it lands through the root’s links: copying or moving it as one tree would take a hidden placeholder instead of the volume.
Sourcepub fn same_entry(&self, other: &Self) -> Result<bool, ContainError>
pub fn same_entry(&self, other: &Self) -> Result<bool, ContainError>
Compare physical entries, including aliases through other mounts.
Sourcepub fn check_copy_destination(
&self,
to: &ContentPath,
) -> Result<(), ContainError>
pub fn check_copy_destination( &self, to: &ContentPath, ) -> Result<(), ContainError>
Refuse a copy onto itself or into its own tree before creating targets.
Sourcepub fn temp_sibling(&self) -> Self
pub fn temp_sibling(&self) -> Self
A collision-safe sibling to stage a move between volumes in, resolved through the same parent handle so the final rename cannot be redirected.
pub fn symlink_metadata(&self) -> Result<Metadata, ContainError>
pub fn read_link_contents(&self) -> Result<PathBuf, ContainError>
Sourcepub fn link_kind(&self) -> Result<LinkKind, ContainError>
pub fn link_kind(&self) -> Result<LinkKind, ContainError>
Which flavour of link this is.
Windows records the distinction in the link itself and Unix does not, so on Unix the answer is a constant and nothing is stat’d for it.
Sourcepub fn symlink(&self, target: &Path, kind: LinkKind) -> Result<(), ContainError>
pub fn symlink(&self, target: &Path, kind: LinkKind) -> Result<(), ContainError>
Create a symlink here whose target is stored verbatim, in the given flavour.
Verbatim matters: the target is never resolved, so reproducing a link that escapes the root yields one that still refuses rather than a working door out of it.
Neither the inherent Dir::symlink nor DirExt::symlink can be used. The first
rejects an absolute target outright. The second, on Windows, stats the target to
choose between a file and a directory link — and that stat runs under containment,
from whichever directory handle the new link is being written through. A target of
../shared is then refused for reaching above that handle even though the link is
a perfectly ordinary internal one, and a directory link is silently rebuilt as a
file link, which on Windows does not traverse. The flavour comes from the source
link instead (link_kind), which is a property of the link and
needs no access to what it points at.
pub fn remove_file(&self) -> Result<(), ContainError>
pub fn remove_dir(&self) -> Result<(), ContainError>
pub fn remove_dir_all(&self) -> Result<(), ContainError>
Sourcepub fn check_removable(&self) -> Result<(), ContainError>
pub fn check_removable(&self) -> Result<(), ContainError>
The checks a removal of this entry with everything below it, or either
end of a rename, has to pass, run without changing anything; the
counterpart of ContentPath::check_rename_end for a link path.
pub fn create_dir_all(&self) -> Result<(), ContainError>
Sourcepub fn open_dir(&self) -> Result<Dir, ContainError>
pub fn open_dir(&self) -> Result<Dir, ContainError>
Open as a directory. Follows the final component, so call only after
symlink_metadata has established it is not a link.
Sourcepub fn regular_file(&self) -> Option<(FileIdentity, u64)>
pub fn regular_file(&self) -> Option<(FileIdentity, u64)>
The regular file this names and its size, the link itself never followed;
None for anything else, including nothing at all.
Sourcepub fn copied_onto_file(&self) -> Option<(FileIdentity, u64)>
pub fn copied_onto_file(&self) -> Option<(FileIdentity, u64)>
The regular file a copy onto this path writes, a final link followed as
copy_to follows it, and its size.
pub fn entries(&self) -> Result<ReadDir, ContainError>
Sourcepub fn copy_to(&self, dest: &Self) -> Result<(), ContainError>
pub fn copy_to(&self, dest: &Self) -> Result<(), ContainError>
Copy file contents onto dest. Follows the source’s final component, so call
only after establishing it is not a symlink — dereferencing one here is what
would turn a copy into an exfiltration.
Sourcepub fn rename_to(&self, dest: &Self) -> Result<(), ContainError>
pub fn rename_to(&self, dest: &Self) -> Result<(), ContainError>
Rename onto dest. Neither final component is followed, so this relocates a
link rather than its target.