Skip to content

Commit

Permalink
CI
Browse files Browse the repository at this point in the history
  • Loading branch information
coolyjg committed Jul 26, 2023
1 parent c0d7e07 commit 37b23b8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ulib/axlibc/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,16 @@ pub unsafe extern "C" fn ax_getcwd(buf: *mut c_char, size: usize) -> *mut c_char
})
}

/// Rename `old` file to `new`
/// Rename `old` to `new`
/// If new exists, it is first removed.
///
/// Return 0 if the operation succeeds, otherwise return -1.
#[no_mangle]
pub unsafe extern "C" fn ax_rename(old: *const c_char, new: *const c_char) -> c_int {
ax_call_body!(ax_rename, {
let old_path = char_ptr_to_str(old)?;
let new_path = char_ptr_to_str(new)?;
debug!("ax_rename <= old: {:?}, new: {:?}", old_path, new_path);
fs::rename(old_path, new_path)
fs::rename(old_path, new_path).map_or_else(|e| Err(LinuxError::from(e)), |_| Ok(0))
})
}

0 comments on commit 37b23b8

Please sign in to comment.