Sha256: 430c393c78a8c6bdc16cef820aa79627c70ccedf4fc48163a2c968b633aa59c3

Contents?: true

Size: 581 Bytes

Versions: 8

Compression:

Stored size: 581 Bytes

Contents

#[no_mangle]
pub extern fn dirname(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();

  if r_str.is_empty() {
    return string
  }

  let path = Path::new(r_str).parent().unwrap_or(Path::new(""));

  let out_str = if !path.to_str().unwrap().is_empty() {
    format!("{}{}", path.to_str().unwrap(), MAIN_SEPARATOR)
  } else {
    format!("{}", path.to_str().unwrap())
  };

  let output = CString::new(out_str).unwrap();
  output.into_raw()
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
faster_path-0.1.5 src/dirname.rs
faster_path-0.1.4 src/dirname.rs
faster_path-0.1.3 src/dirname.rs
faster_path-0.1.2 src/dirname.rs
faster_path-0.1.1 src/dirname.rs
faster_path-0.1.0 src/dirname.rs
faster_path-0.0.9 src/dirname.rs
faster_path-0.0.8 src/dirname.rs