MCPcopy Create free account
hub / github.com/faern/rustscript / hash_path

Function hash_path

src/hash.rs:17–22  ·  view source on GitHub ↗
(p: P)

Source from the content-addressed store, hash-verified

15}
16
17fn hash_path<P: AsRef<Path>>(p: P) -> Result<String> {
18 // let current_dir = ::std::env::current_dir().error_chain(|| "Unable to get current directory")?;
19 let absolute_path =
20 p.as_ref().canonicalize().chain_err(|| "Unable to get absolute path to script")?;
21 Ok(hash(absolute_path.to_str().unwrap().as_bytes()))
22}
23
24fn hash(data: &[u8]) -> String {
25 let mut hasher = Sha256::new();

Callers 1

hash_scriptFunction · 0.85

Calls 1

hashFunction · 0.85

Tested by

no test coverage detected