[][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 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

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.