fxkit 0.1.1

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::c_char;

use crate::{core::fs::file_contains::does_file_contain, utils::convert::cstr::cstr_to_str};

/// # Safety
/// Make sure file and text aren't null.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fxkit_file_contains(file: *const c_char, text: *const c_char) -> bool {
    if file.is_null() || text.is_null() {
        return false;
    }

    let file = unsafe { cstr_to_str(file) };
    let text = unsafe { cstr_to_str(text) };

    does_file_contain(file.as_ref(), text.as_ref())
}