mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -1,4 +1,4 @@
|
||||
use hbb_common::{fs, message_proto::*, log};
|
||||
use hbb_common::{fs, log, message_proto::*};
|
||||
|
||||
use super::{Data, Interface};
|
||||
|
||||
@@ -7,7 +7,12 @@ pub trait FileManager: Interface {
|
||||
fs::get_home_as_string()
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli", feature = "flutter")))]
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "ios",
|
||||
feature = "cli",
|
||||
feature = "flutter"
|
||||
)))]
|
||||
fn read_dir(&self, path: String, include_hidden: bool) -> sciter::Value {
|
||||
match fs::read_dir(&fs::get_path(&path), include_hidden) {
|
||||
Err(_) => sciter::Value::null(),
|
||||
@@ -20,7 +25,12 @@ pub trait FileManager: Interface {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli", feature = "flutter"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "ios",
|
||||
feature = "cli",
|
||||
feature = "flutter"
|
||||
))]
|
||||
fn read_dir(&self, path: &str, include_hidden: bool) -> String {
|
||||
use crate::common::make_fd_to_json;
|
||||
match fs::read_dir(&fs::get_path(path), include_hidden) {
|
||||
@@ -136,4 +146,8 @@ pub trait FileManager: Interface {
|
||||
is_upload,
|
||||
)));
|
||||
}
|
||||
|
||||
fn rename_file(&self, act_id: i32, path: String, new_name: String, is_remote: bool) {
|
||||
self.send(Data::RenameFile((act_id, path, new_name, is_remote)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,6 +817,25 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
Data::RenameFile((id, path, new_name, is_remote)) => {
|
||||
if is_remote {
|
||||
let mut msg_out = Message::new();
|
||||
let mut file_action = FileAction::new();
|
||||
file_action.set_rename(FileRename {
|
||||
id,
|
||||
path,
|
||||
new_name,
|
||||
..Default::default()
|
||||
});
|
||||
msg_out.set_file_action(file_action);
|
||||
allow_err!(peer.send(&msg_out).await);
|
||||
} else {
|
||||
let err = fs::rename_file(&path, &new_name)
|
||||
.err()
|
||||
.map(|e| e.to_string());
|
||||
self.handle_job_status(id, -1, err);
|
||||
}
|
||||
}
|
||||
Data::RecordScreen(start, display, w, h, id) => {
|
||||
let _ = self
|
||||
.video_sender
|
||||
|
||||
Reference in New Issue
Block a user