| Crates.io | process_path |
| lib.rs | process_path |
| version | 0.1.4 |
| created_at | 2017-01-04 00:25:49.86817+00 |
| updated_at | 2022-06-27 14:30:06.198744+00 |
| description | Gets the path of the currently executing process or dynamic library. |
| homepage | |
| repository | https://github.com/wesleywiser/process_path |
| max_upload_size | |
| id | 7911 |
| size | 26,854 |
A Rust library to get the path of the currently executing process or the the current dynamic library.
The latter is particularly useful for ‘plug-in‘ type dynamic libraries that need to load resources stored relative to the location of the library in the file system.
Add this to your Cargo.toml:
[dependencies]
process_path = "0.1.4"
and this to your crate root:
use process_path;
This program prints its path to stdout:
use process_path::get_executable_path;
fn main() {
let path = get_executable_path();
match path {
None => println!("The process path could not be determined"),
Some(path) => println!("{:?}", path)
}
}
| Platform | Underlying API get_executable_path() |
get_dylib_path() |
|---|---|---|
| Linux | readlink(/proc/self/exe) |
dladdr() |
| FreeBSD | sysctl(3) or readlink(/proc/curproc/file) |
dladdr() |
| NetBSD | readlink(/proc/curproc/exe) |
dladdr() |
| DragonflyBSD | readlink(/proc/curproc/file) |
dladdr() |
| macOS | _NSGetExecutablePath() |
dladdr() |
| Windows | GetModuleFileName() |
GetModuleHandleEx() |
Copyright Wesley Wiser and process_path contributors.
Licensed under either of
at your option.