Struct cli_sandbox::Project
source · pub struct Project { /* private fields */ }Implementations§
source§impl Project
impl Project
sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Gets the std::path::Path for the Project’s temporary directory.
sourcepub fn new_file<P: AsRef<Path>>(
&mut self,
path: P,
contents: &str
) -> Result<()>
pub fn new_file<P: AsRef<Path>>( &mut self, path: P, contents: &str ) -> Result<()>
Creates a new file with a relative path to the project’s directory.
path gets redirected to the project’s real path (temporary and unknown).
sourcepub fn check_file<P: AsRef<Path>>(&self, path: P, contents: &str) -> Result<()>
pub fn check_file<P: AsRef<Path>>(&self, path: P, contents: &str) -> Result<()>
Checks that the contents of a file are correct. It will panic if they aren’t, and show the differences if the feature pretty_assertions is enabled
path gets redirected to the project’s real path (temporary and unknown)
Panics
Will panic if the contents of the file at path aren’t encoded as UTF-8
sourcepub fn command<I, S>(&self, args: I) -> Result<Output>where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
pub fn command<I, S>(&self, args: I) -> Result<Output>where I: IntoIterator<Item = S>, S: AsRef<OsStr>,
Executes a command relative to the project’s directory
sourcepub fn is_bin<P: AsRef<Path>>(&self, path: P) -> bool
pub fn is_bin<P: AsRef<Path>>(&self, path: P) -> bool
Checks the file signature of a file and returns true if the file in that path is an executable.
The checked file signatures are the following, if the file’s signature is any of the following, the function will return true.
4D 5A- DOS MZ executable and descendants | (.exe, .scr, .sys, .dll, .fon, .cpl, .iec, .ime, .rs, .tsp, .mz)
5A 4D- DOS ZM executable and descendants, rare | (.exe)
7F 45 4C 46- ELF files
64 65 78 0A 30 33 35 004A 6F 79 21- Preferred Executable Format
00 00 03 F3- Amiga Hunk executable file
sourcepub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, dst: Q)
pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, dst: Q)
Creates a symbolic link, both paths are relative to the temporary project’s path.
Panics
This function will panic if the OS can’t create a system between the two paths.
sourcepub fn clean_env(&self, prefix: &str)
pub fn clean_env(&self, prefix: &str)
Cleans your environment used in the working directory (i.e. removing all environment variables that start with a prefix).
(Note that “localized” environment variables are taken into account)
Panics
This function will panic if it couldn’t get the current working directory, or; it can’t set the current working directory to the temporary project’s path, or; it can’t set the current working directory to the original working directory.