Impl Ref::hash_path() (changes returntype)
This commit is contained in:
parent
4ccbb174fa
commit
130ea0db13
1 changed files with 13 additions and 2 deletions
|
@ -178,8 +178,19 @@ impl<'a> Ref<'a> {
|
||||||
|
|
||||||
/// Creates a Hash from a PathBuf by making the PathBuf absolute and then running a hash
|
/// Creates a Hash from a PathBuf by making the PathBuf absolute and then running a hash
|
||||||
/// algorithm on it
|
/// algorithm on it
|
||||||
fn hash_path(pb: &PathBuf) -> String {
|
fn hash_path(pb: &PathBuf) -> Result<String> {
|
||||||
unimplemented!()
|
use std::io::Read;
|
||||||
|
use crypto::sha1::Sha1;
|
||||||
|
use crypto::digest::Digest;
|
||||||
|
|
||||||
|
match pb.to_str() {
|
||||||
|
Some(s) => {
|
||||||
|
let mut hasher = Sha1::new();
|
||||||
|
hasher.input_str(s);
|
||||||
|
Ok(hasher.result_str())
|
||||||
|
},
|
||||||
|
None => return Err(REK::PathUTF8Error.into_error()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// check whether the pointer the Ref represents still points to a file which exists
|
/// check whether the pointer the Ref represents still points to a file which exists
|
||||||
|
|
Loading…
Reference in a new issue