Sha256: 9cc0c1c60487df02a3fd941b640cd47b437017e3539fa5429d02610db6ac764a
Contents?: true
Size: 777 Bytes
Versions: 5
Compression:
Stored size: 777 Bytes
Contents
use std::path::MAIN_SEPARATOR; use libc::c_char; use std::ffi::{CStr,CString}; use std::str; #[no_mangle] pub extern fn basename_for_chop(string: *const c_char) -> *const c_char { let c_str = unsafe { if string.is_null() { return string; } CStr::from_ptr(string) }; let r_str = str::from_utf8(c_str.to_bytes()).unwrap(); let mut offset = 0; let mut trailing_slashes = r_str.chars().rev(); loop { match trailing_slashes.next() { Some(MAIN_SEPARATOR) => { offset = offset + 1 }, _ => { break }, } } let r_str = &r_str[0..r_str.len()-offset]; let part = r_str.rsplit_terminator(MAIN_SEPARATOR).nth(0).unwrap_or(""); let output = CString::new(part).unwrap(); output.into_raw() }
Version data entries
5 entries across 5 versions & 1 rubygems