#current #process #executable #dylib #dll

process_path

Gets the path of the currently executing process or dynamic library

4 releases

0.1.4 Jun 27, 2022
0.1.3 Jan 7, 2021
0.1.1 Jan 4, 2017
0.1.0 Jan 4, 2017

#132 in Filesystem

Download history 1789/week @ 2023-02-03 1690/week @ 2023-02-10 2139/week @ 2023-02-17 1239/week @ 2023-02-24 2220/week @ 2023-03-03 1915/week @ 2023-03-10 779/week @ 2023-03-17 356/week @ 2023-03-24 542/week @ 2023-03-31 412/week @ 2023-04-07 1137/week @ 2023-04-14 614/week @ 2023-04-21 1083/week @ 2023-04-28 1010/week @ 2023-05-05 813/week @ 2023-05-12 542/week @ 2023-05-19

3,612 downloads per month
Used in 2 crates

MIT/Apache

12KB
212 lines

process_path

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.

Usage

Add this to your Cargo.toml:

[dependencies]
process_path = "0.1.4"

and this to your crate root:

use process_path;

Example

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)
    }
}

Supported Platforms

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

License

Copyright Wesley Wiser and process_path contributors.

Licensed under either of

at your option.

Dependencies

~36KB