https://github.com/robiot/searchpath
A small unix and windows lib to search for executables in PATH folders.
https://github.com/robiot/searchpath
Last synced: 4 months ago
JSON representation
A small unix and windows lib to search for executables in PATH folders.
- Host: GitHub
- URL: https://github.com/robiot/searchpath
- Owner: robiot
- License: mit
- Created: 2021-11-07T18:22:03.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-07T23:02:24.000Z (over 4 years ago)
- Last Synced: 2025-04-02T09:44:43.018Z (about 1 year ago)
- Language: Rust
- Homepage: https://crates.io/crates/searchpath
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A small unix and windows lib to search for executables in path folders.
Example:
```rs
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:
```rs
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);
}
}
```