#process #file-path #executable #dll #dylib #current

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

#263 in Filesystem

Download history 1370/week @ 2024-03-14 2069/week @ 2024-03-21 1456/week @ 2024-03-28 1556/week @ 2024-04-04 1845/week @ 2024-04-11 1581/week @ 2024-04-18 1462/week @ 2024-04-25 2343/week @ 2024-05-02 2171/week @ 2024-05-09 2572/week @ 2024-05-16 1929/week @ 2024-05-23 2747/week @ 2024-05-30 2089/week @ 2024-06-06 1476/week @ 2024-06-13 2045/week @ 2024-06-20 2117/week @ 2024-06-27

8,090 downloads per month
Used in 4 crates

MIT/Apache

13KB
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

~185KB