mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Make dc_msg_get_file return PathBuf, not char*
Adjust call sites as apporiate: * src/dc_imex.rs(dc_continue_key_transfer): use if-let pattern with dc_read_file_safe() and dc_msg_get_file() * src/message.rs(dc_msg_get_setupcodebegin): ditto * src/message.rs(dc_get_msg_info): simplify code to print information about file inside a message. * src/message.rs(dc_msg_get_file): simplify function using dc_get_abs_path_safe() * deltachat-ffi/src/lib.rs(dc_msg_get_file): convert PathBuf to `char *` to preserve C API
This commit is contained in:
@@ -17,7 +17,7 @@ use std::ptr;
|
||||
use std::str::FromStr;
|
||||
|
||||
use deltachat::contact::Contact;
|
||||
use deltachat::dc_tools::{as_str, dc_strdup, StrExt};
|
||||
use deltachat::dc_tools::{as_str, dc_strdup, OsStrExt, StrExt};
|
||||
use deltachat::*;
|
||||
|
||||
// as C lacks a good and portable error handling,
|
||||
@@ -2013,6 +2013,9 @@ pub unsafe extern "C" fn dc_msg_get_file(msg: *mut dc_msg_t) -> *mut libc::c_cha
|
||||
}
|
||||
let ffi_msg = &*msg;
|
||||
message::dc_msg_get_file(&*ffi_msg.context, &ffi_msg.message)
|
||||
.and_then(|p| p.to_c_string().ok())
|
||||
.map(|cs| dc_strdup(cs.as_ptr()))
|
||||
.unwrap_or_else(|| dc_strdup(ptr::null()))
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user