private void ExportDeviceFileToLocalSync() { int idx = 0; int total = need_backup_files.Count; foreach (var file in need_backup_files) { var dist_dir = Path.Combine(SettingController.Setting.LocalBackupPath, file.ParentName); if (!Directory.Exists(dist_dir)) { Directory.CreateDirectory(dist_dir); } var device_path = file.Path.Replace(" ", @"\ "); var cmd = $"pull {device_path} {dist_dir}"; var adbPath = ShellHelper.GetAdbPath(SettingController.Setting.AndroidSdkRootPath); ShellHelper.RunCommand(adbPath, cmd, out string output, out string errors); if (!string.IsNullOrEmpty(errors)) { throw new Exception($"手机 GetDeviceFiles导出出错\r\n\r\n{errors}"); } else { RaiseExportedOneFileEvent(new ExportedOneFileEventArgs { FileData = file, DistPath = dist_dir, Index = idx, TotalCount = total }); } idx++; } }
public override void RemoveRemoteFile(FileData file) { var parent = SettingController.Instance.GetPathMapWithName(file.ParentName).RemotePath; var remote_path = parent + "/" + file.Name; var adbPath = ShellHelper.GetAdbPath(SettingController.Setting.AndroidSdkRootPath); ShellHelper.RunCommand(adbPath, "shell rm " + remote_path, out string output, out string errors); if (!string.IsNullOrEmpty(errors)) { throw new Exception($"手机文件 {remote_path} 删除出错\r\n\r\n{errors}"); } }
public override void GetDeviceFiles(PathMap map) { var cmd = "shell ls " + map.RemotePath.Replace(" ", @"\ "); var adbPath = ShellHelper.GetAdbPath(SettingController.Setting.AndroidSdkRootPath); ShellHelper.RunCommand(adbPath, cmd, out string output, out string errors); if (!string.IsNullOrEmpty(errors)) { throw new Exception($"手机 GetDeviceFiles导出出错\r\n\r\n{errors}"); } var device_files_path = output.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < device_files_path.Length; i++) { var fd = new FileData(map.RemotePath + "/" + device_files_path[i]); device_files.Add(fd); } }