diff --git a/interfaces/kits/rust/include/rust_file.h b/interfaces/kits/rust/include/rust_file.h index e6349905ecdd86845701615a4f2ddeb115a68e82..930fb9a73537cb392a587ca1ee84bfa236185d2c 100644 --- a/interfaces/kits/rust/include/rust_file.h +++ b/interfaces/kits/rust/include/rust_file.h @@ -104,12 +104,14 @@ long long int Lseek(int fd, long long offset, enum SeekPos pos); * @brief Creates a new directory at the given path. * @param path direction path. * @param mode creating ways. + * @retval 0 Created successfully. + * @retval -1 Creation failed. * @attention * 1.The input `path` must be in valid UTF-8 format. * 2.Errors are stored in errno. * @li rust_file.h:The file where the interface is located. */ -void Mkdirs(char* path, enum MakeDirectionMode mode); +int Mkdirs(char* path, enum MakeDirectionMode mode); /** * @ingroup rust diff --git a/interfaces/kits/rust/src/ffi.rs b/interfaces/kits/rust/src/ffi.rs index 8e2dde341b54f6ccf08e98729eb98811cd4d57b5..6cdc9540abd6200cb769f8984967a648f4b1ff9c 100644 --- a/interfaces/kits/rust/src/ffi.rs +++ b/interfaces/kits/rust/src/ffi.rs @@ -17,7 +17,7 @@ use crate::adapter::{ create_dir, error_control, get_parent, next_line, reader_iterator, seek, MakeDirectionMode, SeekPos, Str, }; -use libc::{c_char, c_longlong, c_void}; +use libc::{c_char, c_int, c_longlong, c_void}; use std::ffi::CString; use std::ptr::null_mut; @@ -55,10 +55,13 @@ pub extern "C" fn Lseek(fd: i32, offset: i64, pos: SeekPos) -> c_longlong { } #[no_mangle] -pub extern "C" fn Mkdirs(path: *const c_char, mode: MakeDirectionMode) { +pub extern "C" fn Mkdirs(path: *const c_char, mode: MakeDirectionMode) -> c_int { match create_dir(path, mode) { - Ok(_) => {} - Err(e) => unsafe { error_control(e) }, + Ok(_) => 0, + Err(e) => unsafe { + error_control(e); + -1 + }, } }