mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-07 08:02:22 +00:00
Replace all CStr usage to Utf8CStr
This commit is contained in:
@@ -155,8 +155,8 @@ impl Cpio {
|
||||
|
||||
pub(crate) fn load_from_file(path: &Utf8CStr) -> anyhow::Result<Self> {
|
||||
eprintln!("Loading cpio: [{}]", path);
|
||||
let data = MappedFile::open(path.as_ref())?;
|
||||
Self::load_from_data(data.as_ref())
|
||||
let file = MappedFile::open(path)?;
|
||||
Self::load_from_data(file.as_ref())
|
||||
}
|
||||
|
||||
fn dump(&self, path: &str) -> anyhow::Result<()> {
|
||||
|
||||
@@ -7,7 +7,7 @@ use byteorder::{BigEndian, ReadBytesExt};
|
||||
use protobuf::{EnumFull, Message};
|
||||
|
||||
use base::libc::c_char;
|
||||
use base::{ptr_to_str_result, ReadSeekExt, StrErr};
|
||||
use base::{ReadSeekExt, StrErr, Utf8CStr};
|
||||
use base::{ResultExt, WriteExt};
|
||||
|
||||
use crate::ffi;
|
||||
@@ -26,9 +26,9 @@ macro_rules! bad_payload {
|
||||
const PAYLOAD_MAGIC: &str = "CrAU";
|
||||
|
||||
fn do_extract_boot_from_payload(
|
||||
in_path: &str,
|
||||
partition_name: Option<&str>,
|
||||
out_path: Option<&str>,
|
||||
in_path: &Utf8CStr,
|
||||
partition_name: Option<&Utf8CStr>,
|
||||
out_path: Option<&Utf8CStr>,
|
||||
) -> anyhow::Result<()> {
|
||||
let mut reader = BufReader::new(if in_path == "-" {
|
||||
unsafe { File::from_raw_fd(0) }
|
||||
@@ -193,13 +193,13 @@ pub fn extract_boot_from_payload(
|
||||
partition: *const c_char,
|
||||
out_path: *const c_char,
|
||||
) -> anyhow::Result<()> {
|
||||
let in_path = ptr_to_str_result(in_path)?;
|
||||
let partition = match ptr_to_str_result(partition) {
|
||||
let in_path = unsafe { Utf8CStr::from_ptr(in_path) }?;
|
||||
let partition = match unsafe { Utf8CStr::from_ptr(partition) } {
|
||||
Ok(s) => Some(s),
|
||||
Err(StrErr::NullPointerError) => None,
|
||||
Err(e) => Err(e)?,
|
||||
};
|
||||
let out_path = match ptr_to_str_result(out_path) {
|
||||
let out_path = match unsafe { Utf8CStr::from_ptr(out_path) } {
|
||||
Ok(s) => Some(s),
|
||||
Err(StrErr::NullPointerError) => None,
|
||||
Err(e) => Err(e)?,
|
||||
|
||||
Reference in New Issue
Block a user