Sha256: 25bec336116a0bd052a02818b5e8dfd6b356c0fe9fabdeab76afe5d83c6bfafc

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 Bytes

Contents

#[no_mangle]
pub extern fn basename(string: *const c_char, comp_ext: *const c_char) -> *const c_char {
  let c_str1 = unsafe {
    assert!(!string.is_null());
    CStr::from_ptr(string)
  };
  let c_str2 = unsafe {
    assert!(!comp_ext.is_null());
    CStr::from_ptr(comp_ext)
  };
  let r_str = str::from_utf8(c_str1.to_bytes()).unwrap();
  let r_str_chomp = str::from_utf8(c_str2.to_bytes()).unwrap();

  let r_str = if !r_str_chomp.is_empty() {
    chomp_pathish_regex(r_str, r_str_chomp)
  } else { r_str.to_string() };

  let part = Path::new(&r_str[..]).file_name().unwrap_or(OsStr::new("")).to_str();
  
  let output = CString::new(format!("{}", part.unwrap())).unwrap();
  output.into_raw()
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faster_path-0.1.2 src/basename.rs