patch: linux set clipboard
Signed-off-by: 蔡略 <cailue@bupt.edu.cn>
This commit is contained in:
parent
af131cd1e5
commit
e5bcfeaad5
@ -555,6 +555,16 @@ impl FuseServer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get files and directory path right in root of FUSE fs
|
||||||
|
pub fn list_root(&self) -> Vec<PathBuf> {
|
||||||
|
let files = self.files.read();
|
||||||
|
let mut paths = Vec::new();
|
||||||
|
for file in files.iter().filter(|f| f.parent == Some(FUSE_ROOT_ID)) {
|
||||||
|
paths.push(PathBuf::from(&file.name));
|
||||||
|
}
|
||||||
|
paths
|
||||||
|
}
|
||||||
|
|
||||||
/// gc filesystem
|
/// gc filesystem
|
||||||
fn gc_files(&self) {
|
fn gc_files(&self) {
|
||||||
{
|
{
|
||||||
|
@ -362,6 +362,13 @@ impl ClipboardContext {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// set clipboard data from file list
|
||||||
|
pub fn set_clipboard(&self, paths: &[PathBuf]) -> Result<(), CliprdrError> {
|
||||||
|
let prefix = self.fuse_mount_point.clone();
|
||||||
|
let paths: Vec<PathBuf> = paths.iter().cloned().map(|p| prefix.join(p)).collect();
|
||||||
|
self.clipboard.set_file_list(&paths)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn listen_clipboard(&self) -> Result<(), CliprdrError> {
|
pub fn listen_clipboard(&self) -> Result<(), CliprdrError> {
|
||||||
while let Ok(v) = self.clipboard.wait_file_list() {
|
while let Ok(v) = self.clipboard.wait_file_list() {
|
||||||
let filtered: Vec<_> = v
|
let filtered: Vec<_> = v
|
||||||
@ -663,8 +670,16 @@ impl ClipboardContext {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
ClipboardFile::FormatDataResponse { .. }
|
ClipboardFile::FormatDataResponse { .. } => {
|
||||||
| ClipboardFile::FileContentsResponse { .. } => {
|
// we don't know its corresponding request, no resend can be performed
|
||||||
|
|
||||||
|
self.fuse_server.recv(conn_id, msg);
|
||||||
|
let paths = self.fuse_server.list_root();
|
||||||
|
self.set_clipboard(&paths)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
ClipboardFile::FileContentsResponse { .. } => {
|
||||||
|
// we don't know its corresponding request, no resend can be performed
|
||||||
self.fuse_server.recv(conn_id, msg);
|
self.fuse_server.recv(conn_id, msg);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user