#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

#326 in Filesystem

Download history 1368/week @ 2023-12-14 774/week @ 2023-12-21 524/week @ 2023-12-28 969/week @ 2024-01-04 1398/week @ 2024-01-11 1592/week @ 2024-01-18 1599/week @ 2024-01-25 1326/week @ 2024-02-01 1797/week @ 2024-02-08 1731/week @ 2024-02-15 1273/week @ 2024-02-22 1418/week @ 2024-02-29 1229/week @ 2024-03-07 1370/week @ 2024-03-14 2077/week @ 2024-03-21 1447/week @ 2024-03-28

6,350 downloads per month
Used in 3 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