Sha256: 57fabc4a093c23f8fe5ddb87ad10956dce6d08793e9f47a2e5f424107f127426
Contents?: true
Size: 757 Bytes
Versions: 2
Compression:
Stored size: 757 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 { assert!(!string.is_null()); 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
faster_path-0.1.7 | src/basename_for_chop.rs |
faster_path-0.1.6 | src/basename_for_chop.rs |