fn fake_file(proj: ProjectBuilder, dir: &Path, name: &str, kind: FakeKind) -> ProjectBuilder {
    let path = proj.root().join(dir).join(&format!("{}{}", name,
                                                   env::consts::EXE_SUFFIX));
    mkdir_recursive(path.parent().unwrap()).unwrap();
    match kind {
        FakeKind::Executable => {
            File::create(&path).unwrap();
            make_executable(&path);
        },
        FakeKind::Symlink{target} => {
            make_symlink(&path,target);
        }
    }
    return proj;

    #[cfg(unix)]
    fn make_executable(p: &Path) {
        use std::os::unix::prelude::*;

        let mut perms = fs::metadata(p).unwrap().permissions();
        let mode = perms.mode();
        perms.set_mode(mode | 0o111);
        fs::set_permissions(p, perms).unwrap();
    }
    #[cfg(windows)]
    fn make_executable(_: &Path) {}
    #[cfg(unix)]
    fn make_symlink(p: &Path, t: &Path) {
        ::std::os::unix::fs::symlink(t,p).expect("Failed to create symlink");
    }
    #[cfg(windows)]
    fn make_symlink(_: &Path, _: &Path) {
        panic!("Not supported")
    }
}
/// Add an empty file with executable flags (and platform-dependent suffix).
/// TODO: move this to `ProjectBuilder` if other cases using this emerge.
Add an empty file with executable flags (and platform-dependent suffix).
TODO: move this to `ProjectBuilder` if other cases using this emerge.
Add an empty file with executable flags ( and platform - dependent suffix ) . TODO : move this to ` ProjectBuilder ` if other cases using this emerge .
fn fake_file(proj: ProjectBuilder, dir: &Path, name: &str, kind: FakeKind) -> ProjectBuilder {
    let path = proj.root().join(dir).join(&format!("{}{}", name,
                                                   env::consts::EXE_SUFFIX));
    mkdir_recursive(path.parent().unwrap()).unwrap();
    match kind {
        FakeKind::Executable => {
            File::create(&path).unwrap();
            make_executable(&path);
        },
        FakeKind::Symlink{target} => {
            make_symlink(&path,target);
        }
    }
    return proj;
    #[cfg(unix)]
    fn make_executable(p: &Path) {
        use std::os::unix::prelude::*;
        let mut perms = fs::metadata(p).unwrap().permissions();
        let mode = perms.mode();
        perms.set_mode(mode | 0o111);
        fs::set_permissions(p, perms).unwrap();
    }
    #[cfg(windows)]
    fn make_executable(_: &Path) {}
    #[cfg(unix)]
    fn make_symlink(p: &Path, t: &Path) {
        ::std::os::unix::fs::symlink(t,p).expect("Failed to create symlink");
    }
    #[cfg(windows)]
    fn make_symlink(_: &Path, _: &Path) {
        panic!("Not supported")
    }
}
fn fake_file ( proj : ProjectBuilder , dir : & Path , name : & str , kind : FakeKind ) -> ProjectBuilder { let path = proj . root ( ) . join ( dir ) . join ( & format ! ( " " name env consts EXE_SUFFIX ) ) ; mkdir_recursive ( path . parent ( ) . unwrap ( ) ) . unwrap ( ) ; match kind { FakeKind :: Executable => { File :: create ( & path ) . unwrap ( ) ; make_executable ( & path ) ; } , FakeKind :: Symlink { target } => { make_symlink ( & path , target ) ; } } return proj ; # [ cfg ( unix ) ] fn make_executable ( p : & Path ) { use std :: os :: unix :: prelude :: * ; let mut perms = fs :: metadata ( p ) . unwrap ( ) . permissions ( ) ; let mode = perms . mode ( ) ; perms . set_mode ( mode | 0o111 ) ; fs :: set_permissions ( p , perms ) . unwrap ( ) ; } # [ cfg ( windows ) ] fn make_executable ( _ : & Path ) { } # [ cfg ( unix ) ] fn make_symlink ( p : & Path , t : & Path ) { :: std :: os :: unix :: fs :: symlink ( t , p ) . expect ( " " ) ; } # [ cfg ( windows ) ] fn make_symlink ( _ : & Path , _ : & Path ) { panic ! ( " " ) } }
Add an empty file with executable flags (and platform-dependent suffix).
Add an empty file with executable flags ( and platform - dependent suffix ) .
proj
ProjectBuilder
dir
&Path
name
&str
kind
FakeKind
proj
ProjectBuilder
dir
&Path
name
&str
kind
FakeKind