pub struct LocalScope { /* private fields */ }Implementations§
Source§impl LocalScope
impl LocalScope
Sourcepub fn new(allowed: &[PathBuf]) -> Self
pub fn new(allowed: &[PathBuf]) -> Self
Roots are canonicalised now so symlinked roots still compare equal to canonicalised requests, and their identity is recorded. A root that does not exist yet is kept as written and simply never matches.
pub fn roots(&self) -> &[PathBuf]
pub fn is_empty(&self) -> bool
Sourcepub fn resolve_existing(&self, raw: &str) -> Result<PathBuf>
pub fn resolve_existing(&self, raw: &str) -> Result<PathBuf>
Resolve a model-supplied path to a canonical path inside a root. Symlinks are followed before the containment check, so a link pointing outside the allowed directories is refused.
Sourcepub fn resolve_for_write(&self, raw: &str) -> Result<PathBuf>
pub fn resolve_for_write(&self, raw: &str) -> Result<PathBuf>
Resolve a path that may not exist yet (a download target). The nearest existing ancestor must be inside a root.
Sourcepub fn open_file(&self, raw: &str) -> Result<(PathBuf, File)>
pub fn open_file(&self, raw: &str) -> Result<(PathBuf, File)>
Resolve and open a regular file for reading.
Sourcepub fn open_resolved(&self, path: &Path) -> Result<File>
pub fn open_resolved(&self, path: &Path) -> Result<File>
Open the regular file at path, a path inside a root as
resolve_existing or a walk below one
returns it, without following a symlink anywhere below the root.
Sourcepub fn list(&self, dir: &Path) -> Result<Vec<LocalEntry>>
pub fn list(&self, dir: &Path) -> Result<Vec<LocalEntry>>
List the directory at dir, a path inside a root.
Sourcepub fn create_part(&self, dest: &Path) -> Result<PartFile>
pub fn create_part(&self, dest: &Path) -> Result<PartFile>
Start a download to dest (as resolve_for_write
returns it): missing folders are created, and the data goes to a
randomly named temporary file created exclusively in the destination
folder. PartFile::commit renames it into place.