absolutize path common functions

This commit is contained in:
veeso
2021-08-24 09:28:49 +02:00
parent 0cb9254e63
commit 214ec0c5a5
5 changed files with 26 additions and 58 deletions

View File

@@ -25,6 +25,7 @@
use super::{ConfigClient, FileTransferActivity, LogLevel, LogRecord};
use crate::system::environment;
use crate::system::sshkey_storage::SshKeyStorage;
use crate::utils::path;
// Ext
use std::env;
use std::path::{Path, PathBuf};
@@ -124,27 +125,13 @@ impl FileTransferActivity {
///
/// Convert a path to absolute according to local explorer
pub(super) fn local_to_abs_path(&self, path: &Path) -> PathBuf {
match path.is_relative() {
true => {
let mut d: PathBuf = self.local().wrkdir.clone();
d.push(path);
d
}
false => path.to_path_buf(),
}
path::absolutize(self.local().wrkdir.as_path(), path)
}
/// ### remote_to_abs_path
///
/// Convert a path to absolute according to remote explorer
pub(super) fn remote_to_abs_path(&self, path: &Path) -> PathBuf {
match path.is_relative() {
true => {
let mut wrkdir: PathBuf = self.remote().wrkdir.clone();
wrkdir.push(path);
wrkdir
}
false => path.to_path_buf(),
}
path::absolutize(self.remote().wrkdir.as_path(), path)
}
}