public void CopySingleFileAsInput(string fileName) { var target = FromRootDirectory("Data\\Target"); var source = FromRootDirectory($"Data\\Source\\{fileName}"); var filecopy = new FileCopy() { TargetDirectory = new InArgument<string>(target) }; var app = new WorkflowTestApplication(filecopy); app.Inputs.Add("SourceFiles", new List<string>(new[] {source})); app.Run(); Assert.IsTrue(File.Exists(FromRootDirectory($"Data\\Target\\{fileName}")), "The expected file does not exists"); }
public void CopyFilesNotExists() { var target = FromRootDirectory("Data\\Target"); var source = FromRootDirectory("Data\\Source\\SomeFileNotExists.txt"); var filecopy = new FileCopy() { TargetDirectory = new InArgument<string>(target) }; var app = new WorkflowTestApplication(filecopy); app.Inputs.Add("SourceFiles", new List<string>(new[] { source })); var result = app.Run(); Assert.IsTrue(result.Exception != null && result.Exception.GetType() == typeof(FileNotFoundException), "exception FileNotFoundException wasn't thrown"); }
public void CopySingleFileAsArgument(string fileName) { var target = FromRootDirectory("Data\\Target"); var source = FromRootDirectory($"Data\\Source\\{fileName}"); var filecopy = new FileCopy() { SourceFiles = new InArgument<List<string>>(context => new List<string>(new[] { source })), TargetDirectory = target }; var app = new WorkflowTestApplication(filecopy); var result = app.Run(); var expectedfilename = FromRootDirectory($"Data\\Target\\{fileName}"); Assert.IsTrue((result["Result"] as List<string>)?.Contains(expectedfilename), "The expected file is not a part of the result"); Assert.IsTrue(File.Exists(expectedfilename), "The expected file does not exists"); }
public async Task Copies_file_to_destination() { var source = CreateRandomFile(0x10000); var copy = new FileCopy(0x1000); copy.ProgressChanged += (o, e) => { Console.WriteLine(e.Percent); }; var destination = Guid.NewGuid().ToString(); await copy.CopyAsync(source, destination, CancellationToken.None); var sourceBytes = F.ReadAllBytes(source); var destBytes = F.ReadAllBytes(destination); destBytes.ShouldBeEquivalentTo(sourceBytes, o => o.WithStrictOrdering()); F.Delete(destination); F.Delete(source); }
public async void GetDataAsync() { //readImages (); var dbPath = await FileCopy.GetFingerDataBaseFolder(); var dbPathEvent = await FileCopy.GetFingerEventDataBaseFolder(); m_SEN0188SQLite.DBDataBasePath = dbPath; m_FingertEventDatabase.DBDataBaseName = dbPathEvent; m_SEN0188SQLite.InitializeDatabase(); m_FingertEventDatabase.InitializeDatabase(); m_SEN0188SQLite.GetDataSets(); m_GPIOInOutBanks = await GPIOOInOutBanks.GPIOOInOutBanksAsync(m_GPIOInputServiceConnectorConfig); await m_GPIOEnvironmentConnectors.InitializeAsync(); }
public void FileCopy_MakesBackup() { // Create the test file CreateTestFile(pathToTestFile, testContent); try { //Create new FileCopy object with the test file's path FileCopy fcObj = new FileCopy(pathToTestFile); fcObj.MakeBackup(); // Compare the content of the file with original test Assert.IsTrue(Utils.FileCompare(pathToTestFile, FileCopy.BACKUP_FOLDER + testFileName), "Backup invalid"); } finally { // Delete test file if (File.Exists(pathToTestFile)) { File.Delete(pathToTestFile); } } }
//string appendPathFname(WinSysDBFile winsysFile) //{ // if (winsysFile.WinSysDBFileName.Length > 0 && winsysFile.WinSysDBFilePath.Length > 0) // return winsysFile.WinSysDBFilePath + winsysFile.WinSysDBFileName; // else if (winsysFile.WinSysDBFileName.Length > 0 && winsysFile.WinSysDBFilePath.Length == 0) // return winsysFile.WinSysDBFileName; // else if (winsysFile.WinSysDBFileName.Length == 0 && winsysFile.WinSysDBFilePath.Length > 0) // return winsysFile.WinSysDBFilePath; // else // throw new Exception("Erroneaous file and path names."); //} public FileCopy CopyFiles() { FileCopy fc = new FileCopy(); fc.status = eStatus.InProgress; fc.datetime = DateTime.Now; try { string[] files = FileTransfer.GetFiles(srcPath, "*.tps", SearchOption.TopDirectoryOnly); foreach (string file in files) { System.IO.File.Copy(@file, @dstPath + file.Remove(0, file.LastIndexOf("\\")), true); fc.files.Add(file); } fc.status = eStatus.Success; } catch (Exception ex) { Logger.Debug($" {MobileDeliveryManagerAPI.AppName} - Error Copying tps Winsys files : " + ex.Message); fc.status = eStatus.Failed; } return(fc); }
public void FileCopy_CopyExecutive() { // Create the test file CreateTestFile(pathToTestFile, testContent); File.Copy(pathToTestFile, Path.GetDirectoryName(pathToTestFile) + "\\original", true); //Create new FileCopy object with the test file's path FileCopy fcObj = new FileCopy(pathToTestFile); fcObj.CopyExecutive(@"C:\Windows\explorer.exe"); Assert.IsFalse(Utils.FileCompare(Path.GetDirectoryName(pathToTestFile) + "\\original", pathToTestFile), "Files wasn't replaced"); // Delete test file if (File.Exists(pathToTestFile)) { File.Delete(pathToTestFile); } if (File.Exists(Path.GetDirectoryName(pathToTestFile) + "\\original")) { File.Delete(Path.GetDirectoryName(pathToTestFile) + "\\original"); } }
public static bool TryCommand(string Data) { string[] FullCommandWithArguments; FullCommandWithArguments = Data.Split(null); switch (FullCommandWithArguments[0]) { case "about": About.Command(); return(true); case "%execution.path%": ExecutionPaths.Command(); return(true); case "copy": FileCopy.Command(FullCommandWithArguments); return(true); case "exit": Exit.Command(FullCommandWithArguments); return(true); case "stacktolog": StackToLog.Command(); return(true); case "vars": Vars.Command(FullCommandWithArguments); return(true); case "clear": ClearScreen.Command(); return(true); case "lastcommand": LastCommand.Command(); return(true); case "cd": Cd.Command(FullCommandWithArguments); return(true); case "collectgarbage": Functions.AppOnlyScope.Disposal.RunCleanup(); return(true); case "ls": Ls.Command(FullCommandWithArguments); return(true); case "ping": Ping.Command(FullCommandWithArguments); return(true); case "ipinfo": IpInfo.Command(FullCommandWithArguments); return(true); case "commands": CommandList.Command(); return(true); case "help": CommandList.Command(); return(true); case "download": Download.Command(FullCommandWithArguments); return(true); case "start": Run.Command(FullCommandWithArguments); return(true); case "run": Run.Command(FullCommandWithArguments); return(true); default: return(false); } }
private void ExportDataBase_Click(object sender, RoutedEventArgs e) { FileCopy.ExportFingerDataBaseToLocalFolder(); }
private void btnStart_Click(object sender, EventArgs e) { // check if read var question = MessageBox.Show(this, $@"Start the copy process now?{Environment.NewLine}This might take a few seconds so please be patient.", @"Please choose", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (question != DialogResult.OK) { return; } // get files in backup folder var fileHandlerBackup = new FileHandler(Path.Combine(_pathBackup, "a")); var fileListBackup = fileHandlerBackup.GetFileListWithoutExtensions(); if (fileListBackup.Count < 1) { MessageBox.Show(this, @"Error while parsing the backup folder!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // file -> RomFsFile var romFsFiles = new List <RomFsFile>(); foreach (var file in fileListBackup) { romFsFiles.Add(new RomFsFile(file)); } // get cro files // X:0, Y:1, OR:2, AS:3, Su:4, Mo:5, US: 6, UM: 7 var selectedGame = (Pokemon.Version)cboGameSelection.SelectedIndex; var fileHandlerCro = new FileHandler(_pathRomFs); var croFiles = fileHandlerCro.GetCroFileList(selectedGame); if (croFiles.Count < 1) { MessageBox.Show(this, @"Error while parsing the .cro files!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // get code.bin var exefsFolderPath = Path.Combine(Directory.GetParent(_pathRomFs).FullName, "exefs"); var fileHandlerCodeBin = new FileHandler(exefsFolderPath); var fileListCodeBin = fileHandlerCodeBin.GetCodeBinFile(); if (fileListCodeBin.Count < 1) { MessageBox.Show(this, @"Could not find code.bin in exefs folder!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (fileListCodeBin.Count > 1) { MessageBox.Show(this, $@"There ist more than one file namend code* in the exefs folder.{Environment.NewLine}Please make sure there is only one, otherwise PokeTool might use the wrong file!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var codeBin = fileListCodeBin.First(); // copy process var copyResult = FileCopy.CopyAllNecessaryFiles(selectedGame, romFsFiles, _pathRomFs, croFiles, codeBin); if (copyResult) { MessageBox.Show(this, @"Finished copying all files!", @"Done", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show(this, $@"Error while copying the files!{Environment.NewLine}Check error-log.txt for more information.", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } // reset if successful if (!copyResult) { return; } ChangeValidationState(lblBackupValidator, false, Validation.Backup); ChangeValidationState(lblRomFsValidator, false, Validation.RomFs); }