pub struct Dir { /* private fields */ }
Expand description
Resource representing file system directory
Implementations§
Source§impl Dir
impl Dir
Sourcepub fn new<P: AsRef<Path>>(path: P) -> Self
pub fn new<P: AsRef<Path>>(path: P) -> Self
Create new Dir pointing to absolute file system path
panicking if failed
Sourcepub fn new_safe<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>>
pub fn new_safe<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>>
Create new Dir pointing to absolute file system path
Sourcepub fn created(self) -> Self
pub fn created(self) -> Self
Creates the directory using create
and returns itself or stops the build
with informative error message.
Sourcepub fn create(&self)
pub fn create(&self)
Creates the directory using create_result
or stops the build with
informative error message.
Sourcepub fn create_result(&self) -> Result<()>
pub fn create_result(&self) -> Result<()>
Creates the directory and any missing parent directories on it’s path.
Sourcepub fn content<G: AsRef<str>>(&self, glob: G) -> DirContent<Unit>
pub fn content<G: AsRef<str>>(&self, glob: G) -> DirContent<Unit>
All directory content (files, directories and links) matching given glob
file name pattern
Sourcepub fn dirs<G: AsRef<str>>(&self, glob: G) -> DirContent<Dir>
pub fn dirs<G: AsRef<str>>(&self, glob: G) -> DirContent<Dir>
All subdirectories and directory links matching given glob
file name pattern
Sourcepub fn files<G: AsRef<str>>(&self, glob: G) -> DirContent<File>
pub fn files<G: AsRef<str>>(&self, glob: G) -> DirContent<File>
All files and file links matching given glob
file name pattern
Sourcepub fn dir<P: AsRef<Path>>(&self, path: P) -> Dir
pub fn dir<P: AsRef<Path>>(&self, path: P) -> Dir
Subdirectory at given relative path
Will stop the build with informative error message if path is not relative.
Sourcepub fn dir_result<P: AsRef<Path>>(
&self,
path: P,
) -> Result<Self, Box<dyn Error>>
pub fn dir_result<P: AsRef<Path>>( &self, path: P, ) -> Result<Self, Box<dyn Error>>
Subdirectory at given relative path
Sourcepub fn file<P: AsRef<Path>>(&self, path: P) -> File
pub fn file<P: AsRef<Path>>(&self, path: P) -> File
A file at given relative path
Will stop the build with informative error message if path is not relative.
Sourcepub fn file_result<P: AsRef<Path>>(
&self,
path: P,
) -> Result<File, Box<dyn Error>>
pub fn file_result<P: AsRef<Path>>( &self, path: P, ) -> Result<File, Box<dyn Error>>
A file at given relative path
Sourcepub fn linked_from_inside(self, dir: &Dir) -> Self
pub fn linked_from_inside(self, dir: &Dir) -> Self
Creating a link to this directory from another directory with this directory’s name returning self or stopping the build with informative error message.
If the directory already contains an entry with this name, linking fails.
Sourcepub fn link_from_inside(&self, dir: &Dir)
pub fn link_from_inside(&self, dir: &Dir)
Creating a link to this directory from another directory with this directory’s name or stopping the build with informative error message.
If the directory already contains an entry with this name, linking fails.
Sourcepub fn link_from_inside_result(&self, dir: &Dir, force: bool) -> Result<()>
pub fn link_from_inside_result(&self, dir: &Dir, force: bool) -> Result<()>
Creating a link to this directory from another directory with this directory’s name.
If the directory already contains a file or directory by this name, linking fails.
To allow overwriting existing link with different target set force
to true
or linking to
this directory will also fail.
Sourcepub fn linked_to(self, to: &Dir) -> Self
pub fn linked_to(self, to: &Dir) -> Self
Create a symbolic link at this directory path to given target directory to
creating any
needed directories in the process returning self or stopping the build with informative
error message.
If a file or directory by that name already exists, linking will fail.
Sourcepub fn link_to(&self, to: &Dir)
pub fn link_to(&self, to: &Dir)
Create a symbolic link at this directory path to given target directory to
creating any
needed directories in the process or stopping the build with informative error message.
If a file or directory by that name already exists, linking will fail.
Sourcepub fn link_to_result(&self, to: &Dir, force: bool) -> Result<()>
pub fn link_to_result(&self, to: &Dir, force: bool) -> Result<()>
Create a symbolic link at this directory path to given target directory to
creating any
needed directories in the process.
If a file or directory by that name already exists, linking will fail.
To allow overwriting existing link to a different directory set force
to true
or linking
to a different directory will also fail.
Sourcepub fn touched(self) -> Self
pub fn touched(self) -> Self
Touches the directory using touch
and returns itself or stops the build
with informative error message
Sourcepub fn touch(&self)
pub fn touch(&self)
Touches the directory using touch
and returns itself or stops the build
with informative error message.
Sourcepub fn touch_result(&self) -> Result<()>
pub fn touch_result(&self) -> Result<()>
Touches the directory by updating it’s modification time or creating a new one if it does not exists yet including any needed directories.