start of the libportage, first ebuild created
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
use std::{env, path::{Path,PathBuf}};
|
||||
use std::io::Result;
|
||||
|
||||
fn getwcd() -> Result<PathBuf> {
|
||||
let cwd = match env::current_dir() {
|
||||
Ok(p) => p,
|
||||
Err(_) => {
|
||||
env::set_current_dir("/")?;
|
||||
PathBuf::from("/")
|
||||
}
|
||||
};
|
||||
|
||||
Ok(cwd)
|
||||
}
|
||||
|
||||
fn abssymlink(symlink: &Path, target: Option<PathBuf>) -> Result<PathBuf> {
|
||||
let mut mylink = if target.is_some() {
|
||||
target.unwrap()
|
||||
} else {
|
||||
std::fs::read_link(symlink)?
|
||||
};
|
||||
if !mylink.has_root() {
|
||||
let mydir = mylink.parent().unwrap();
|
||||
let link_name = mylink.clone();
|
||||
mylink = Path::new(mydir).join(link_name);
|
||||
}
|
||||
|
||||
Ok(mylink)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user