pub fn absolute_path<P>(path: P) -> io::Result<PathBuf>
where
	P: AsRef<Path>,
{
	let path = path.as_ref();
	let pathbuf = if path.is_absolute() {
		path.to_path_buf()
	} else {
		if path == PathBuf::from("") {
			return Err(io::Error::new(
				io::ErrorKind::InvalidInput,
				"path cannot be empty",
			));
		} else {
			env::current_dir()?.join(path)
		}
	}
	// cleans up the path since we don't want something like `/foo/bar/..`
	.clean();

	Ok(pathbuf)
}
/// Propogates errors from `std::env::current_dir`.
/// Must be used on all paths accepted by public functions since relative paths are generally prone to issues.
/// Example: `PathBuf::from(".").file_name() == None`, `PathBuf::from(".").starts_with("/") == False`
Propogates errors from `std::env::current_dir`.
Must be used on all paths accepted by public functions since relative paths are generally prone to issues.
Propogates errors from ` std :: env :: current_dir ` . Must be used on all paths accepted by public functions since relative paths are generally prone to issues .
pub fn absolute_path<P>(path: P) -> io::Result<PathBuf>
where
	P: AsRef<Path>,
{
	let path = path.as_ref();
	let pathbuf = if path.is_absolute() {
		path.to_path_buf()
	} else {
		if path == PathBuf::from("") {
			return Err(io::Error::new(
				io::ErrorKind::InvalidInput,
				"path cannot be empty",
			));
		} else {
			env::current_dir()?.join(path)
		}
	}
	// cleans up the path since we don't want something like `/foo/bar/..`
	.clean();
	Ok(pathbuf)
}
pub fn absolute_path < P > ( path : P ) -> io :: Result < PathBuf > where P : AsRef < Path > , { let path = path . as_ref ( ) ; let pathbuf = if path . is_absolute ( ) { path . to_path_buf ( ) } else { if path == PathBuf :: from ( " " ) { return Err ( io :: Error :: new ( io :: ErrorKind :: InvalidInput , " " , ) ) ; } else { env :: current_dir ( ) ? . join ( path ) } } // cleans up the path since we don't want something like `/foo/bar/..` . clean ( ) ; Ok ( pathbuf ) }
Propogates errors from `std::env::current_dir`.
Propogates errors from ` std :: env :: current_dir ` .
path
P
path
P