#file-path #process #executable #dylib #dll #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

#256 in Filesystem

Download history 3570/week @ 2024-08-03 2266/week @ 2024-08-10 1462/week @ 2024-08-17 2253/week @ 2024-08-24 2177/week @ 2024-08-31 2073/week @ 2024-09-07 1560/week @ 2024-09-14 2304/week @ 2024-09-21 2184/week @ 2024-09-28 3355/week @ 2024-10-05 2748/week @ 2024-10-12 2930/week @ 2024-10-19 3110/week @ 2024-10-26 2874/week @ 2024-11-02 3024/week @ 2024-11-09 2703/week @ 2024-11-16

12,217 downloads per month
Used in 8 crates (6 directly)

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