Skip to content

Simple crate to search up from the cwd for a file by name

License

Notifications You must be signed in to change notification settings

bpshaver/file_lookup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

file_lookup

For when you want to look up from the current working directory for a file by name.

Example Usage

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();

Errors

These functions fail if there is a failure to ascertain your current working directory or your home directory:

pub enum FileLookupError {
    CwdNotFound,
    HomeDirNotFound,
};

Installation

This crate is on crates.io.

Install it with cargo:

$ cargo add file_lookup

About

Simple crate to search up from the cwd for a file by name

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages