Skip to content

Commit

Permalink
Fixed a bug in find() and bumped version number to 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdavidmackenzie committed Feb 11, 2018
1 parent c2ece9f commit 28f313a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "simpath"
version = "1.1.0"
version = "1.2.0"
authors = ["Andrew Mackenzie <[email protected]>"]
description = "Search for files on a path defined in an environment variable"
license = "MIT"
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ impl Simpath {
for search_dir in &self.dirs {
for entry in fs::read_dir(search_dir)? {
let file = entry?;
if file.path().to_str().unwrap() == file_name {
return Ok(file.path())
if let Some(filename) = file.file_name().to_str() {
if filename == file_name {
return Ok(file.path());
}
}
}
}

Err(Error::new(ErrorKind::NotFound,
format!("Could not find '{}' in search path '{}'",
file_name, self.name)))
Expand Down

0 comments on commit 28f313a

Please sign in to comment.