file rename (#9089)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2024-08-16 12:55:58 +08:00
committed by GitHub
parent 579e0fac36
commit ed18e3c786
59 changed files with 507 additions and 50 deletions

View File

@@ -881,6 +881,9 @@ async fn handle_fs(
}
}
}
ipc::FS::Rename { id, path, new_name } => {
rename_file(path, new_name, id, tx).await;
}
_ => {}
}
}
@@ -945,6 +948,17 @@ async fn create_dir(path: String, id: i32, tx: &UnboundedSender<Data>) {
.await;
}
#[cfg(not(any(target_os = "ios")))]
async fn rename_file(path: String, new_name: String, id: i32, tx: &UnboundedSender<Data>) {
handle_result(
spawn_blocking(move || fs::rename_file(&path, &new_name)).await,
id,
0,
tx,
)
.await;
}
#[cfg(not(any(target_os = "ios")))]
async fn remove_dir(path: String, id: i32, recursive: bool, tx: &UnboundedSender<Data>) {
let path = fs::get_path(&path);