private void SaveDfuAndTetherFiles() { LogUtil.LogEvent($"Saving {MiscUtils.KERNEL_CACHE_FILE_NAME} and {MiscUtils.IBSS_FILE_NAME} files"); MiscUtils.RecreateDirectory(_firmwareVersionModel.AppDataFolder); LogUtil.LogEvent($"Directory {_firmwareVersionModel.AppDataFolder} recreated successfully"); string kernelcache = Path.Combine(MiscUtils.WORKING_FOLDER, MiscUtils.OUTPUT_FOLDER_NAME, MiscUtils.KERNEL_CACHE_FILE_NAME); if (SafeFile.Exists(kernelcache)) { SafeFile.Copy(kernelcache, Path.Combine(_firmwareVersionModel.AppDataFolder, MiscUtils.KERNEL_CACHE_FILE_NAME), true); LogUtil.LogEvent($"{MiscUtils.KERNEL_CACHE_FILE_NAME} file copied successfully"); } string iBss = Path.Combine(MiscUtils.WORKING_FOLDER, MiscUtils.OUTPUT_FOLDER_NAME, MiscUtils.FIRMWARE_FOLDER_NAME, MiscUtils.DFU_FOLDER_NAME, MiscUtils.IBSS_FILE_NAME); if (SafeFile.Exists(iBss)) { SafeFile.Copy(iBss, Path.Combine(_firmwareVersionModel.AppDataFolder, MiscUtils.IBSS_FILE_NAME), true); LogUtil.LogEvent($"{MiscUtils.IBSS_FILE_NAME} file copied successfully"); } string iBec = Path.Combine(MiscUtils.WORKING_FOLDER, MiscUtils.OUTPUT_FOLDER_NAME, MiscUtils.FIRMWARE_FOLDER_NAME, MiscUtils.DFU_FOLDER_NAME, MiscUtils.IBEC_FILE_NAME); if (_firmwareVersionModel.SelectedVersion.SaveIBec && SafeFile.Exists(iBec)) { SafeFile.Copy(iBec, Path.Combine(_firmwareVersionModel.AppDataFolder, MiscUtils.IBEC_FILE_NAME), true); LogUtil.LogEvent($"{MiscUtils.IBEC_FILE_NAME} file copied successfully"); } }
private void RestoreDfuAndTetherFiles() { LogUtil.LogEvent("Restoring DFU and Tether file"); string kernelCache = Path.Combine(_firmwareVersionModel.AppDataFolder, MiscUtils.KERNEL_CACHE_FILE_NAME); if (SafeFile.Exists(kernelCache)) { SafeFile.Copy(kernelCache, Path.Combine(MiscUtils.BIN_DIRECTORY, MiscUtils.KERNEL_CACHE_FILE_NAME), true); } string iBss = Path.Combine(_firmwareVersionModel.AppDataFolder, MiscUtils.IBSS_FILE_NAME); if (SafeFile.Exists(iBss)) { SafeFile.Copy(iBss, Path.Combine(MiscUtils.BIN_DIRECTORY, MiscUtils.IBSS_FILE_NAME), true); } string iBec = Path.Combine(_firmwareVersionModel.AppDataFolder, MiscUtils.IBEC_FILE_NAME); if (SafeFile.Exists(iBec)) { SafeFile.Copy(iBec, Path.Combine(MiscUtils.BIN_DIRECTORY, MiscUtils.IBEC_FILE_NAME), true); } }
public override ICommandResult Execute(IDictionary <string, string> vars, params string[] args) { if (args.Length != 2) { return(ArgsCountError(2, args)); } SubstituteVariables(vars, args); string from = args[0]; string to = args[1]; if (string.IsNullOrWhiteSpace(from)) { return(Error("the source path was empty or white space")); } if (string.IsNullOrWhiteSpace(to)) { return(Error("the destination path was empty or white space")); } SafeFile.Copy(Path.Combine(SafeDirectory.GetCurrentDirectory(), from), Path.Combine(SafeDirectory.GetCurrentDirectory(), to)); return(Success()); }
private void SaveDFUAndTetherFiles() { LogUtil.LogEvent(string.Format("Saving {0} and {1} files", MiscUtils.KERNEL_CACHE_FILE_NAME, MiscUtils.IBSS_FILE_NAME)); MiscUtils.RecreateDirectory(firmwareVersionModel.AppDataFolder); LogUtil.LogEvent(string.Format("Directory {0} recreated successfully", firmwareVersionModel.AppDataFolder)); string kernelcache = Path.Combine(MiscUtils.WORKING_FOLDER, MiscUtils.OUTPUT_FOLDER_NAME, MiscUtils.KERNEL_CACHE_FILE_NAME); if (SafeFile.Exists(kernelcache)) { SafeFile.Copy(kernelcache, Path.Combine(firmwareVersionModel.AppDataFolder, MiscUtils.KERNEL_CACHE_FILE_NAME), true); LogUtil.LogEvent(string.Format("{0} file copied successfully", MiscUtils.KERNEL_CACHE_FILE_NAME)); } string iBSS = Path.Combine(MiscUtils.WORKING_FOLDER, MiscUtils.OUTPUT_FOLDER_NAME, MiscUtils.FIRMWARE_FOLDER_NAME, MiscUtils.DFU_FOLDER_NAME, MiscUtils.IBSS_FILE_NAME); if (SafeFile.Exists(iBSS)) { SafeFile.Copy(iBSS, Path.Combine(firmwareVersionModel.AppDataFolder, MiscUtils.IBSS_FILE_NAME), true); LogUtil.LogEvent(string.Format("{0} file copied successfully", MiscUtils.IBSS_FILE_NAME)); } string iBEC = Path.Combine(MiscUtils.WORKING_FOLDER, MiscUtils.OUTPUT_FOLDER_NAME, MiscUtils.FIRMWARE_FOLDER_NAME, MiscUtils.DFU_FOLDER_NAME, MiscUtils.IBEC_FILE_NAME); if (firmwareVersionModel.SelectedVersion.Save_iBEC && SafeFile.Exists(iBEC)) { SafeFile.Copy(iBEC, Path.Combine(firmwareVersionModel.AppDataFolder, MiscUtils.IBEC_FILE_NAME), true); LogUtil.LogEvent(string.Format("{0} file copied successfully", MiscUtils.IBEC_FILE_NAME)); } }
private void RestoreDFUFile() { LogUtil.LogEvent("Restoring DFU file"); string iBSS = Path.Combine(firmwareVersionModel.AppDataFolder, MiscUtils.IBSS_FILE_NAME); if (SafeFile.Exists(iBSS)) { SafeFile.Copy(iBSS, Path.Combine(MiscUtils.BIN_DIRECTORY, MiscUtils.IBSS_FILE_NAME), true); } string iBEC = Path.Combine(firmwareVersionModel.AppDataFolder, MiscUtils.IBEC_FILE_NAME); if (SafeFile.Exists(iBEC)) { SafeFile.Copy(iBEC, Path.Combine(MiscUtils.BIN_DIRECTORY, MiscUtils.IBEC_FILE_NAME), true); } }
private void PerformStart() { if (SafeFile.Exists(_firmwareVersionModel.ExistingFirmwarePath) && MiscUtils.ComputeMd5(_firmwareVersionModel.ExistingFirmwarePath) == _firmwareVersionModel.CorrectFirmwareMd5) { LogUtil.LogEvent("Original firmware found on disk"); SafeFile.Copy(_firmwareVersionModel.ExistingFirmwarePath, Path.Combine(MiscUtils.WORKING_FOLDER, MiscUtils.DOWNLOADED_FILE_PATH), true); if (DownloadCompleted != null) { DownloadCompleted(this, EventArgs.Empty); } return; } LogUtil.LogEvent("Starting download"); _webClient.DownloadFileAsync(new Uri(_firmwareVersionModel.DownloadUri), _fileName); }
private void webClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (e.Error != null) { LogUtil.LogEvent(string.Format("Download failed:\n{0}", e.Error)); Percentage = 0; if (ProgressChanged != null) { ProgressChanged(sender, e); } if (!e.Cancelled) { if (DownloadFailed != null) { DownloadFailed(sender, e); } return; } else { LogUtil.LogEvent("Download was cancelled by the user"); if (DownloadCanceled != null) { DownloadCanceled(sender, e); } return; } } LogUtil.LogEvent("Download completed"); SafeFile.Copy(Path.Combine(MiscUtils.WORKING_FOLDER, MiscUtils.DOWNLOADED_FILE_PATH), _firmwareVersionModel.ExistingFirmwarePath, true); LogUtil.LogEvent("Downloaded file copied to Documents folder"); if (DownloadCompleted != null) { DownloadCompleted(sender, e); } }
private void PerformPatch() { _patch = GetPatch(); _patch.CurrentMessageChanged += patch_CurrentMessageChanged; _patch.CurrentProgressChanged += patch_CurrentProgressChanged; string resultFile = _patch.PerformPatch(); _patch.CurrentMessageChanged -= patch_CurrentMessageChanged; _patch.CurrentProgressChanged -= patch_CurrentProgressChanged; _patch = null; SaveDfuAndTetherFiles(); SafeFile.Copy(resultFile, _firmwareVersionModel.PatchedFirmwarePath, true); if (Finished != null) { Finished(this, EventArgs.Empty); } }