#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

#296 in Filesystem

Download history 1327/week @ 2024-02-26 1422/week @ 2024-03-04 1283/week @ 2024-03-11 1659/week @ 2024-03-18 1954/week @ 2024-03-25 1219/week @ 2024-04-01 1934/week @ 2024-04-08 1568/week @ 2024-04-15 1654/week @ 2024-04-22 1717/week @ 2024-04-29 2021/week @ 2024-05-06 2316/week @ 2024-05-13 2564/week @ 2024-05-20 2378/week @ 2024-05-27 2256/week @ 2024-06-03 1810/week @ 2024-06-10

9,080 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