[][src]Struct reef::Paths

pub struct Paths;

Functionality to help determine system paths

Implementations

impl Paths[src]

pub fn home() -> PathBuf[src]

Get the user home PathBuf

Example

use reef::Paths;
let home = Paths::home();
assert!(home.exists());

pub fn dev_root() -> PathBuf[src]

The path that serves as the development root directory The default value is home, may be set to a custom value with the enviroment variable DEV_ROOT

pub fn build() -> PathBuf[src]

The path that serves as the build directory

pub fn work() -> PathBuf[src]

The path the serves as the work directory

pub fn log() -> PathBuf[src]

pub fn cache() -> PathBuf[src]

pub fn repo() -> PathBuf[src]

pub fn tmp(rel_path: &str) -> Result<PathBuf>[src]

pub fn env(env_name: &str) -> Option<PathBuf>[src]

Get a path from an environment variable

pub fn which(name: &str) -> Option<PathBuf>[src]

uses the PATH environment variable to search for a filename matching the specified name. if a matching filename is not found, it will check for the existence of name.exe and name.bat

Example

use reef::Paths;
let git_path = Paths::which("git").unwrap();
assert!(git_path.exists());

pub fn shebang(path: &Path) -> Result<String>[src]

extracts the text following the shebang #!

Example

given a file with the contents:

#!C:/Ruby26-x64/bin/ruby.exe

the shebang method will return C:/Ruby26-x64/bin/ruby.exe

use reef::Paths;
use std::env;
let path = std::env::temp_dir().join("test.rb");
std::fs::write(&path,b"#!C:/Ruby26-x64/bin/ruby.exe")?;
let target = Paths::shebang(&path).unwrap();
assert_eq!("C:/Ruby26-x64/bin/ruby.exe",target);

pub fn application_path<P: AsRef<Path>>(
    qualifier: &str,
    organization: &str,
    application: &str,
    rel_path: P
) -> PathBuf
[src]

get an application specific path

pub fn normalize(str_path: &str) -> PathBuf[src]

pub fn rel_path(origin: &str) -> PathBuf[src]

get a valid relative path from a remote origin string

Example

use reef::Paths;
let path = Paths::rel_path("https://gitlab.com/crates-rs/reef");
//assert_eq!("gitlab.com/crates-rs/reef",path.to_str().unwrap());

pub fn clobber(path: &Path) -> Result<()>[src]

pub fn parent(path: &Path) -> Result<&Path>[src]

pub fn name(path: &Path) -> Result<String>[src]

pub fn commit_path(origin: &str, commit_id: &str) -> Result<PathBuf>[src]

pub fn clear_read_only(path: &Path) -> Result<()>[src]

pub fn is_git_path(path: &Path) -> bool[src]

pub fn collect_git_paths(path: &Path) -> Result<Vec<PathBuf>>[src]

pub fn import_remote_origins(path: &Path) -> Result<HashSet<String>>[src]

Auto Trait Implementations

impl RefUnwindSafe for Paths

impl Send for Paths

impl Sync for Paths

impl Unpin for Paths

impl UnwindSafe for Paths

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,