searchpath 0.1.3

A small unix and windows lib to search for executables in PATH folders
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 5.11 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 279.59 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • robiot/searchpath
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • robiot

A small unix and windows lib to search for executables in path folders.

Example:

use searchpath::search_path;
use std::ffi::OsString;

fn main() {
    let path = std::env::var_os("PATH");
    let files = search_path("ba", path.as_ref().map(OsString::as_os_str), None);
    for file in files {
        println!("{}", file);
    }
}

Will print something like

bat
bashbug
bash
base32
basenc
basename
base64

Windows example:

use searchpath::search_path;
use std::ffi::OsString;

fn main() {
    let path = std::env::var_os("path");
    let path_ext = std::env::var_os("pathext");
    let files = search_path("explo", path.as_ref().map(OsString::as_os_str), path_ext.as_ref().map(OsString::as_os_str));
    for file in files {
        println!("{}", file);
    }
}