fxkit 0.1.4

Useful utilities for writting Rust CLI tools
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::ffi::{CStr, c_char};

use crate::core::tools::does_cmd_exist::does_cmd_exist;

/// Checks if a command exists
/// # Safety
/// Make sure cmd isn't null.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fxkit_cmd_exists(cmd: *const c_char) -> bool {
    if cmd.is_null() {
        return false;
    }

    let cmd = unsafe { CStr::from_ptr(cmd).to_string_lossy() };

    does_cmd_exist(cmd.as_ref())
}