| Crates.io | file_lookup |
| lib.rs | file_lookup |
| version | 0.2.2 |
| created_at | 2023-04-22 00:29:13.495629+00 |
| updated_at | 2023-10-17 00:28:16.45093+00 |
| description | Simple functions to search up in the file tree for a file by name. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 845758 |
| size | 5,516 |
file_lookupFor when you want to look up from the current working directory for a file by name.
Find a file within your home directory, looking up from your current working directory:
use file_lookup::home_find_file;
let path = home_find_file("some_file.json").unwrap();
Find a file within your root directory (or anywhere else), looking up from your current working directory:
use std::path::PathBuf;
use file_lookup::find_file;
let path = find_file("some_file.json", &PathBuf::from("/")).unwrap();
These functions fail if there is a failure to ascertain your current working directory or your home directory:
pub enum FileLookupError {
CwdNotFound,
HomeDirNotFound,
};
This crate is on crates.io.
Install it with cargo:
$ cargo add file_lookup