From 37b23b8c0e2a18765a8ff0393606470365a17816 Mon Sep 17 00:00:00 2001 From: yanjuguang Date: Thu, 27 Jul 2023 00:53:01 +0800 Subject: [PATCH] CI --- ulib/axlibc/src/file.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ulib/axlibc/src/file.rs b/ulib/axlibc/src/file.rs index 3a5a6affdc..e20ab6992b 100644 --- a/ulib/axlibc/src/file.rs +++ b/ulib/axlibc/src/file.rs @@ -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)) }) }