Skip to content

A Rust library to get the path of the currently executing process

License

Notifications You must be signed in to change notification settings

VOICEVOX/process_path

 
 

Repository files navigation

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()
illumos readlink(/proc/self/exe) dladdr()

License

Copyright Wesley Wiser and process_path contributors.

Licensed under either of

at your option.

About

A Rust library to get the path of the currently executing process

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%