diff --git a/libs/hbb_common/src/fs.rs b/libs/hbb_common/src/fs.rs index 8aa36dee4..da56cf6b6 100644 --- a/libs/hbb_common/src/fs.rs +++ b/libs/hbb_common/src/fs.rs @@ -767,6 +767,13 @@ pub fn create_dir(dir: &str) -> ResultType<()> { Ok(()) } +#[inline] +pub fn transform_windows_path(entries: &mut Vec) { + for entry in entries { + entry.name = entry.name.replace("\\", "/"); + } +} + pub enum DigestCheckResult { IsSame, NeedConfirm(FileTransferDigest), diff --git a/src/mobile.rs b/src/mobile.rs index 6487d0d25..200c0b24d 100644 --- a/src/mobile.rs +++ b/src/mobile.rs @@ -4,9 +4,8 @@ use hbb_common::{ allow_err, compress::decompress, config::{Config, LocalConfig}, - fs, - fs::{can_enable_overwrite_detection, get_string, new_send_confirm, DigestCheckResult}, - get_version_number, log, + fs, log, + fs::{can_enable_overwrite_detection, new_send_confirm, DigestCheckResult, get_string, transform_windows_path}, message_proto::*, protobuf::Message as _, rendezvous_proto::ConnType, @@ -662,7 +661,10 @@ impl Connection { } Some(message::Union::file_response(fr)) => match fr.union { Some(file_response::Union::dir(fd)) => { - let entries = fd.entries.to_vec(); + let mut entries = fd.entries.to_vec(); + if self.session.peer_platform() == "Windows" { + fs::transform_windows_path(&mut entries); + } let id = fd.id; self.session.push_event( "file_dir", diff --git a/src/ui/remote.rs b/src/ui/remote.rs index d168e190a..ac32726aa 100644 --- a/src/ui/remote.rs +++ b/src/ui/remote.rs @@ -1644,7 +1644,15 @@ impl Remote { ); let m = make_fd(job.id(), job.files(), true); self.handler.call("updateFolderFiles", &make_args!(m)); + #[cfg(not(windows))] let files = job.files().clone(); + #[cfg(windows)] + let mut files = job.files().clone(); + #[cfg(windows)] + if self.handler.peer_platform() != "Windows" { + // peer is not windows, need transform \ to / + fs::transform_windows_path(&mut files); + } self.read_jobs.push(job); self.timer = time::interval(MILLI1); allow_err!(peer.send(&fs::new_receive(id, to, file_num, files)).await); @@ -2019,7 +2027,13 @@ impl Remote { Some(message::Union::file_response(fr)) => { match fr.union { Some(file_response::Union::dir(fd)) => { - let entries = fd.entries.to_vec(); + let mut entries = fd.entries.to_vec(); + #[cfg(not(windows))] + { + if self.handler.peer_platform() == "Windows" { + fs::transform_windows_path(&mut entries); + } + } let mut m = make_fd(fd.id, &entries, fd.id > 0); if fd.id <= 0 { m.set_item("path", fd.path);