forked from Cutieguwu/raven
Most of the refactor. Need to switch machines.
This commit is contained in:
45
retired/nest_lib_rs_old/lib.rs
Normal file
45
retired/nest_lib_rs_old/lib.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
mod class;
|
||||
mod dependency;
|
||||
mod error;
|
||||
//mod lock;
|
||||
mod meta;
|
||||
mod nest;
|
||||
mod package;
|
||||
pub mod prelude;
|
||||
mod prey;
|
||||
mod workspace;
|
||||
|
||||
pub use error::{Error, Result};
|
||||
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub const FN_NEST: &str = "Nest";
|
||||
pub const FN_PREY: &str = "Prey";
|
||||
|
||||
pub const F_NEST_TOML: &str = const_format::concatcp!(FN_NEST, fs::EXT_TOML);
|
||||
pub const F_NEST_LOCK: &str = const_format::concatcp!(FN_NEST, fs::EXT_LOCK);
|
||||
pub const F_PREY_TOML: &str = const_format::concatcp!(FN_PREY, fs::EXT_TOML);
|
||||
pub const F_PREY_LOCK: &str = const_format::concatcp!(FN_PREY, fs::EXT_LOCK);
|
||||
|
||||
/// Return the location of the parent `Nest.toml` as [`PathBuf`]
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Possible cases:
|
||||
///
|
||||
/// * `Nest.toml` cannot be located.
|
||||
/// * Current working directory does not exist.
|
||||
/// * There are insufficient permissions to access the current directory.
|
||||
pub fn locate_nest() -> io::Result<PathBuf> {
|
||||
let cwd = std::env::current_dir()?;
|
||||
let mut probe = cwd.clone();
|
||||
|
||||
while !probe.join(F_NEST_TOML).exists() {
|
||||
if !probe.pop() {
|
||||
return Err(io::ErrorKind::NotFound.into());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(probe)
|
||||
}
|
||||
Reference in New Issue
Block a user