mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 03:16:29 +03:00
Change argument type of write_asc_to_file from const char * to &Path
This commit is contained in:
@@ -1093,7 +1093,7 @@ unsafe fn export_key_to_asc_file(
|
|||||||
}
|
}
|
||||||
info!(context, "Exporting key {}", as_str(file_name),);
|
info!(context, "Exporting key {}", as_str(file_name),);
|
||||||
dc_delete_file(context, as_path(file_name));
|
dc_delete_file(context, as_path(file_name));
|
||||||
if !key.write_asc_to_file(file_name, context) {
|
if !key.write_asc_to_file(as_path(file_name), context) {
|
||||||
error!(context, "Cannot write key to {}", as_str(file_name),);
|
error!(context, "Cannot write key to {}", as_str(file_name),);
|
||||||
} else {
|
} else {
|
||||||
context.call_cb(
|
context.call_cb(
|
||||||
|
|||||||
11
src/key.rs
11
src/key.rs
@@ -1,6 +1,7 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
use pgp::composed::{Deserializable, SignedPublicKey, SignedSecretKey};
|
use pgp::composed::{Deserializable, SignedPublicKey, SignedSecretKey};
|
||||||
@@ -216,17 +217,13 @@ impl Key {
|
|||||||
.expect("failed to serialize key")
|
.expect("failed to serialize key")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_asc_to_file(&self, file: *const libc::c_char, context: &Context) -> bool {
|
pub fn write_asc_to_file(&self, file: impl AsRef<Path>, context: &Context) -> bool {
|
||||||
if file.is_null() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let file_content = self.to_asc(None).into_bytes();
|
let file_content = self.to_asc(None).into_bytes();
|
||||||
|
|
||||||
if dc_write_file_safe(context, as_path(file), &file_content) {
|
if dc_write_file_safe(context, &file, &file_content) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
error!(context, "Cannot write key to {}", as_str(file));
|
error!(context, "Cannot write key to {}", file.as_ref().display());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user