refactor: replace &PathBuf with &Path to enhance generality (#10332)

This commit is contained in:
Integral
2024-12-23 20:28:04 +08:00
committed by GitHub
parent 7289dbc80f
commit 49dabd3533
13 changed files with 44 additions and 40 deletions

View File

@@ -15,7 +15,7 @@ use shared_memory::*;
use std::{
mem::size_of,
ops::{Deref, DerefMut},
path::PathBuf,
path::Path,
sync::{Arc, Mutex},
time::Duration,
};
@@ -92,7 +92,7 @@ impl SharedMemory {
}
};
log::info!("Create shared memory, size: {}, flink: {}", size, flink);
set_path_permission(&PathBuf::from(flink), "F").ok();
set_path_permission(Path::new(&flink), "F").ok();
Ok(SharedMemory { inner: shmem })
}
@@ -586,8 +586,8 @@ pub mod client {
let mut exe = std::env::current_exe()?.to_string_lossy().to_string();
#[cfg(feature = "flutter")]
{
if let Some(dir) = PathBuf::from(&exe).parent() {
if set_path_permission(&PathBuf::from(dir), "RX").is_err() {
if let Some(dir) = Path::new(&exe).parent() {
if set_path_permission(Path::new(dir), "RX").is_err() {
*SHMEM.lock().unwrap() = None;
bail!("Failed to set permission of {:?}", dir);
}