MCPcopy Create free account
hub / github.com/archlinux/alpm / new

Method new

alpm-common/src/package/input.rs:36–55  ·  view source on GitHub ↗

Creates a new [`InputPath`]. # Errors Returns an error if - `base_dir` is not absolute, - `base_dir` is not a directory, - or `path` is not relative.

(base_dir: &'a Path, path: &'b Path)

Source from the content-addressed store, hash-verified

34 /// - `base_dir` is not a directory,
35 /// - or `path` is not relative.
36 pub fn new(base_dir: &'a Path, path: &'b Path) -> Result<Self, crate::Error> {
37 if !base_dir.is_absolute() {
38 return Err(crate::Error::NonAbsolutePaths {
39 paths: vec![base_dir.to_path_buf()],
40 });
41 }
42 if !base_dir.is_dir() {
43 return Err(crate::Error::NotADirectory {
44 path: base_dir.to_path_buf(),
45 });
46 }
47
48 if !path.is_relative() {
49 return Err(crate::Error::NonRelativePaths {
50 paths: vec![path.to_path_buf()],
51 });
52 }
53
54 Ok(Self { base_dir, path })
55 }
56
57 /// Returns a reference to the base dir.
58 pub fn base_dir(&self) -> &Path {

Callers

nothing calls this directly

Calls 3

is_dirMethod · 0.80
to_path_bufMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected