#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

#324 in Filesystem

Download history 1238/week @ 2024-01-22 1604/week @ 2024-01-29 1241/week @ 2024-02-05 2046/week @ 2024-02-12 1495/week @ 2024-02-19 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

7,057 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