Use tempfile (#1980)

This commit is contained in:
LoveSy
2024-08-15 16:28:05 +08:00
committed by GitHub
parent 2dac1c701c
commit bbc31bdbca
4 changed files with 59 additions and 87 deletions

View File

@@ -211,7 +211,10 @@ pub fn restore(
magiskboot_path: Option<PathBuf>,
flash: bool,
) -> Result<()> {
let tmpdir = tempdir::TempDir::new("KernelSU").context("create temp dir failed")?;
let tmpdir = tempfile::Builder::new()
.prefix("KernelSU")
.tempdir()
.context("create temp dir failed")?;
let workdir = tmpdir.path();
let magiskboot = find_magiskboot(magiskboot_path, workdir)?;
@@ -366,7 +369,10 @@ fn do_patch(
);
}
let tmpdir = tempdir::TempDir::new("KernelSU").context("create temp dir failed")?;
let tmpdir = tempfile::Builder::new()
.prefix("KernelSU")
.tempdir()
.context("create temp dir failed")?;
let workdir = tmpdir.path();
// extract magiskboot