public int DllCopy(FileCopier fc, List <string> DestPathes, Dictionary <int, List <string> > DllNames, string DllDirPath) { foreach (int key in DllNames.Keys) { foreach (string dllName in DllNames[key]) { string dllPath = BuildDllPath(dllName, DllDirPath, key); if (dllPath != "") { foreach (string destPath in DestPathes) { string[] lparams = new string[2]; lparams[0] = dllPath; lparams[1] = destPath + "\\" + dllName; fc.Copy(lparams); } } else { MessageBox.Show("Unable to find " + dllName); return(-1); } } } return(0); }
public async void Process() { var startTime = DateTime.Now; ReadFile readFile = new ReadFile(); String fileData = readFile.ReadFileAsync(this.file).Result; FileCopier fileCopier = new FileCopier(); String lockFileName = this.file.Substring(this.file.LastIndexOf(Path.DirectorySeparatorChar) + 1); String fileNameWithoutLock = lockFileName.Substring(0, lockFileName.Length - 5); await fileCopier.copy(Config.GetRawPath() + Path.DirectorySeparatorChar + fileNameWithoutLock, fileData); JsonToObjectConverter converter = new JsonToObjectConverter(); var jsonObject = converter.Convert(fileData); Stat stat = new Stat(fileNameWithoutLock); ValidationApplier validationApplier = new ValidationApplier(); List <bool> validationResult = validationApplier.Validate(jsonObject, this.validators); EventSeparator eventSeparator = new EventSeparator(); eventSeparator.Separate(jsonObject, validationResult); var endTime = DateTime.Now; Double elapsedMilliseconds = ((TimeSpan)(endTime - startTime)).TotalMilliseconds; stat.UpdateStat(jsonObject, validationResult, elapsedMilliseconds); EventLog log = new EventLog(); Console.WriteLine(log.Generate(stat)); Console.WriteLine("---------------------------------"); File.Delete(file); }
public void Should_Copy_Multiple_Files_Absolute_Path() { const string filePath1 = "./src/a/a.txt"; const string filePath2 = "./src/b/b.txt"; const string dstPath = "./dst"; // Given var fixture = new FileCopierFixture(); fixture.EnsureFileExists(filePath1); fixture.EnsureFileExists(filePath2); fixture.EnsureDirectoryExists(dstPath); // When FileCopier.CopyFiles( fixture.Context, new[] { fixture.MakeAbsolute(filePath1), fixture.MakeAbsolute(filePath2) }, new DirectoryPath(dstPath), true); // Then Assert.True(fixture.ExistsFile($"{dstPath}/a/a.txt")); Assert.True(fixture.ExistsFile($"{dstPath}/b/b.txt")); }
public override bool Execute() { if (InputAppBundles.Length == 0) { Log.LogError(MSBStrings.E7073 /* At least one app bundle must be specified. */); return(false); } // If we only have a single input directory, then we can just copy that as-is if (InputAppBundles.Length == 1) { var sourceDirectory = Path.GetFullPath(InputAppBundles [0].ItemSpec); var targetDirectory = Path.GetFullPath(OutputAppBundle); // Make sure we have a trailing directory, so that UpdateDirectory copies the directory contents of the source directory. if (sourceDirectory [sourceDirectory.Length - 1] != Path.DirectorySeparatorChar) { sourceDirectory += Path.DirectorySeparatorChar; } Log.LogMessage(MessageImportance.Low, $"Copying the single input directory {sourceDirectory} to {targetDirectory}"); FileCopier.UpdateDirectory(sourceDirectory, targetDirectory, FileCopierReportErrorCallback, FileCopierLogCallback); return(!Log.HasLoggedErrors); } if (!MergeAppBundles()) { return(false); } return(!Log.HasLoggedErrors); }
public Boolean Execute() { if (BuildEnvironment.IsDebug) { Debugger.Launch(); } MdbGenerator generator = new MdbGenerator(this); generator.BeginGenerateMdbSymbols(); FileCopier copier = FileCopier.TryGetFileCopier(this); if (copier != null) { copier.BeginCopyDll(); copier.BeginCopyPdb(); } // Wait until .mdb symbols generated to able to copy it generator.EndGenerateMdbSymbols(); if (copier != null) { copier.BeginCopyMdb(); copier.EndCopy(); } return(true); }
void MergeMachOFiles(string output, IList <Entry> input) { if (input.Any(v => v.DependentFiles?.Any() == true)) { Log.LogError(MSBStrings.E7078 /* Invalid app bundle: the Mach-O file {0} has dependent files. */, input.First().RelativePath); return; } var sourceFiles = input.Select(v => v.FullPath).ToArray(); if (FileCopier.IsUptodate(sourceFiles, new string [] { output }, FileCopierReportErrorCallback, FileCopierLogCallback)) { return; } Log.LogMessage(MessageImportance.Low, $"Lipoing '{input [0].RelativePath}' for the merged app bundle from the following sources:\n\t{string.Join ("\n\t", input.Select (v => v.FullPath))}"); var arguments = new List <string> (); arguments.Add("-create"); arguments.Add("-output"); arguments.Add(output); arguments.AddRange(sourceFiles); ExecuteAsync("lipo", arguments, sdkDevPath: SdkDevPath).Wait(); }
public int DllCopyThread(DataMover DMover) { FileCopier fc = DMover.fileCopier; List <string> DestPathes = DMover.DestPathes; Dictionary <int, List <string> > DllNames = DMover.DllNames; string DllDirPath = DMover.DllFolder; foreach (int key in DllNames.Keys) { foreach (string dllName in DllNames[key]) { string dllPath = BuildDllPath(dllName, DllDirPath, key); if (dllPath != "") { foreach (string destPath in DestPathes) { string[] lparams = new string[2]; lparams[0] = dllPath; lparams[1] = destPath + dllName; fc.Copy(lparams); } } else { return(-1); } } } return(0); }
private static void StartWatching(CommandOptions options) { ILogger logger = new ConsoleLoggger(); logger.LogInfo("Watching has started"); options.SourceDirectoryPath = string.IsNullOrWhiteSpace(options.SourceDirectoryPath) ? Directory.GetCurrentDirectory() : options.SourceDirectoryPath; IPluginLoader loader = new PluginLoader(logger, options.Debug); IFileCopier copier = new FileCopier(logger, options); if (options.Delay > 0) { copier = new QueuedFileCopier(copier, logger, options); } IFileWatcher fileWatcher = new FileWatcher(copier, logger); loader.Subscribe((IPreCopyEventBroadcaster)copier, (IPostCopyEventBroadcaster)copier); fileWatcher.Watch(options); }
public void FileCopier_SupportedType_IsFileCopy() { var logger = Substitute.For <ILogger <IFileCreator> >(); var sut = new FileCopier(logger); sut.SupportedType.Should().Be <IFileCopy>(); }
public void Migrate(Job job) { var lister = new SourceFilesLister(); var sourceFiles = lister.GetSourceFiles(job.Source.Criteria); var fileCopier = new FileCopier(); var targetFiles = fileCopier.CopyFiles(sourceFiles, job.Source.ProjectFolder, job.Target.ProjectFolder); }
public void TestCopier() { IFileCopier pfc = new FileCopier(); pfc.Copy(SRC_PATH, DST_PATH, true); Assert.IsTrue(File.Exists(DST_PATH)); Assert.IsTrue(FileComparer.Compare(SRC_PATH, DST_PATH)); }
public void Should_Throw_If_Context_Is_Null() { // When var result = Record.Exception(() => FileCopier.CopyFiles(null, Enumerable.Empty <FilePath>(), new DirectoryPath(""), true)); // Then AssertEx.IsArgumentNullException(result, "context"); }
public void CopyPdfFormToBlazorProject_InvalidPathToPdfFormSource_ShouldThrow() { Action action = () => FileCopier.CopyPdfFormToBlazorProject(@"C:\IShouldNotExist.pdf", string.Empty); var exception = Assert.Throws <ArgumentException>(action); Assert.Equal("Invalid path to source PDF form.", exception.Message); }
public void CopyPdfFormToBlazorProject_PdfFormSourceNotProvided_ShouldThrow() { Action action = () => FileCopier.CopyPdfFormToBlazorProject(string.Empty, string.Empty); var exception = Assert.Throws <ArgumentException>(action); Assert.Equal("Path to source PDF form not provided.", exception.Message); }
public void CopyTo(string outputDirectory, string subDirectory = null) { string outputFile; if (subDirectory == null) { outputFile = Path.Combine(outputDirectory, RelativePath); } else { var relativeAppDir = Path.GetDirectoryName(RelativePath); if (string.IsNullOrEmpty(relativeAppDir)) { outputFile = Path.Combine(outputDirectory, subDirectory, RelativePath); } else { outputFile = Path.Combine(outputDirectory, relativeAppDir, subDirectory, Path.GetFileName(RelativePath)); } } if (Type == FileType.Directory) { Directory.CreateDirectory(outputFile); } else if (Type == FileType.Symlink) { Directory.CreateDirectory(Path.GetDirectoryName(outputFile)); var symlinkTarget = PathUtils.GetSymlinkTarget(FullPath); if (File.Exists(outputFile) && PathUtils.IsSymlink(outputFile) && PathUtils.GetSymlinkTarget(outputFile) == symlinkTarget) { File.SetLastWriteTimeUtc(outputFile, DateTime.UtcNow); // update the timestamp, because the file the symlink points to might have changed. Task.Log.LogMessage(MessageImportance.Low, "Target '{0}' is up-to-date", outputFile); } else { PathUtils.FileDelete(outputFile); PathUtils.Symlink(symlinkTarget, outputFile); } } else { Directory.CreateDirectory(Path.GetDirectoryName(outputFile)); if (!FileCopier.IsUptodate(FullPath, outputFile, Task.FileCopierReportErrorCallback, Task.FileCopierLogCallback)) { File.Copy(FullPath, outputFile, true); } } if (DependentFiles != null) { foreach (var file in DependentFiles) { file.CopyTo(outputDirectory, subDirectory); } } }
public void CopyTo(string outputDirectory, string subDirectory = null) { string outputFile; if (subDirectory == null) { outputFile = Path.Combine(outputDirectory, RelativePath); } else { var relativeAppDir = Path.GetDirectoryName(RelativePath); if (string.IsNullOrEmpty(relativeAppDir)) { outputFile = Path.Combine(outputDirectory, subDirectory, RelativePath); } else { outputFile = Path.Combine(outputDirectory, relativeAppDir, subDirectory, Path.GetFileName(RelativePath)); } } if (Type == FileType.Directory) { Directory.CreateDirectory(outputFile); } else if (Type == FileType.Symlink) { Directory.CreateDirectory(Path.GetDirectoryName(outputFile)); var symlinkTarget = PathUtils.GetSymlinkTarget(FullPath); if (File.Exists(outputFile) && PathUtils.IsSymlink(outputFile) && PathUtils.GetSymlinkTarget(outputFile) == symlinkTarget) { Task.Log.LogMessage(MessageImportance.Low, "Target '{0}' is up-to-date", outputFile); } else { PathUtils.FileDelete(outputFile); PathUtils.Symlink(symlinkTarget, outputFile); } } else { Directory.CreateDirectory(Path.GetDirectoryName(outputFile)); if (!FileCopier.IsUptodate(FullPath, outputFile)) { File.Copy(FullPath, outputFile, true); } } if (DependentFiles != null) { foreach (var file in DependentFiles) { file.CopyTo(outputDirectory, subDirectory); } } }
public void SortsJjSymbols() { FileCopier fc = new FileCopier(); fc.SymbolsFromFile(); var s = fc.Symbols; Assert.IsTrue(s.Count > 0); Assert.IsTrue(s.Contains("ABEV")); }
public void Should_Throw_If_Target_Directory_Path_Is_Null() { // Given var fixture = new FileCopierFixture(); // When var result = Record.Exception(() => FileCopier.CopyFiles(fixture.Context, Enumerable.Empty <FilePath>(), null, true)); // Then AssertEx.IsArgumentNullException(result, "targetDirectoryPath"); }
public void Should_Throw_If_File_Paths_Is_Null() { // Given var fixture = new FileCopierFixture(); // When var result = Record.Exception(() => FileCopier.CopyFiles(fixture.Context, (List <FilePath>)null, new DirectoryPath(""), true)); // Then AssertEx.IsArgumentNullException(result, "filePaths"); }
protected override void GivenThat() { base.GivenThat(); var podcast1 = new PodcastInfo(ControlFile) { Folder = "pod1" }; podcast1.Pattern.Value = "*.mp3"; podcast1.MaximumNumberOfFiles.Value = 2; podcast1.AscendingSort.Value = true; podcast1.DeleteEmptyFolder.Value = true; podcast1.SortField.Value = PodcastFileSortField.FileName; var podcast2 = new PodcastInfo(ControlFile) { Folder = "AnotherPodcast" }; podcast2.Pattern.Value = "*.wma"; podcast2.MaximumNumberOfFiles.Value = 3; podcast2.AscendingSort.Value = false; podcast2.DeleteEmptyFolder.Value = false; podcast2.SortField.Value = PodcastFileSortField.CreationTime; PodcastFiles1 = new List <IFileInfo> { GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>() }; PodcastFiles2 = new List <IFileInfo> { GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>() }; ControlFile.Stub(c => c.GetPodcasts()) .Return(new List <PodcastInfo> { podcast1, podcast2 }); ControlFile.Stub(c => c.GetSourceRoot()) .Return(@"c:\media\blah"); ControlFile.Stub(c => c.GetDestinationRoot()) .Return(@"k:\podcasts"); ControlFile.Stub(c => c.GetFreeSpaceToLeaveOnDestination()) .Return(500); FileFinder.Stub(f => f.GetFiles(@"c:\media\blah\pod1", "*.mp3", 2, PodcastFileSortField.FileName, true)) .Return(PodcastFiles1); FileFinder.Stub(f => f.GetFiles(@"c:\media\blah\AnotherPodcast", "*.wma", 3, PodcastFileSortField.CreationTime, false)) .Return(PodcastFiles2); FileCopier.Stub(c => c.CopyFilesToTarget(null, null, null, 0, false)) .IgnoreArguments() .WhenCalled(invocation => FilesToCopy = (List <FileSyncItem>)invocation.Arguments[0]); }
public void FileCopier_Create_ThrowsWithSnippet() { var logger = Substitute.For <ILogger <IFileCreator> >(); var output = Substitute.For <ISnippet>(); var sut = new FileCopier(logger); var act = () => sut.Create(output); act.Should().Throw <NotSupportedException>(); }
public void FileCopier_Create_WritesFIle() { var logger = Substitute.For <ILogger <IFileCreator> >(); var output = Substitute.For <IFileCopy>(); var sut = new FileCopier(logger); sut.Create(output); //writer.ReceivedCalls().Should().HaveCount(2); }
public void Run() { ConsolePrinter successPrinter = new ConsolePrinter(ConsoleColor.Green); ConsolePrinter errorPrinter = new ConsolePrinter(ConsoleColor.Red); FileCopier copier = new FileCopier(); FileCopier.Printer printerSuccess = successPrinter.Print; FileCopier.Printer printerError = errorPrinter.Print; copier.StartCopying(printerSuccess, printerError); }
private void Init(string fileName) { if (nonPersistent) { var tempFile = TemporaryFilesManager.Instance.GetTemporaryFile(); FileCopier.Copy(fileName, tempFile, true); fileName = tempFile; } stream = new SerializableStreamView(new FileStream(fileName, FileMode.OpenOrCreate), size, 0xFF); size2n = (byte)Misc.Logarithm2(size); buffer = new byte[DesiredBufferSize]; }
private static void ParseFlags(string flags) { if (flags.Length > 3 || flags.Length < 2 || flags[0] != '-') { return; } switch (flags.Length) { case 2: { var flag = flags[1]; switch (flag) { case 'o': _overwrite = true; break; case 'p': _fileCopier = new ParallelFileCopier(); break; case 'c': _fileCopier = new CustomThreadPoolBasedParallelFileCopier(); break; } break; } case 3: { var owerwrite = flags[1]; if (owerwrite == 'o') { _overwrite = true; } var copierType = flags[2]; { switch (copierType) { case 'p': _fileCopier = new ParallelFileCopier(); break; case 'c': _fileCopier = new CustomThreadPoolBasedParallelFileCopier(); break; } } break; } } }
public void Run() { Logger logger = new Logger(); FileCopier.Printer printerConsole = logger.LogToConsole; FileCopier.Printer printerFile = logger.LogToFile; FileCopier.Printer printerCombined = printerConsole + printerFile; FileCopier copier = new FileCopier(); copier.StartCopying(printerCombined, null); }
private void Init(string fileName) { if (nonPersistent) { var tempFile = TemporaryFilesManager.Instance.GetTemporaryFile(); FileCopier.Copy(fileName, tempFile, true); fileName = tempFile; } stream = new SerializableFileStreamWrapper(fileName); CheckUnderlyingFile(); size2n = (byte)Misc.Logarithm2(size); buffer = new byte[DesiredBufferSize]; }
private void CopyLogFilesIfChanged() { string originalPath = applicationConfiguration.LogFilePath; if (string.IsNullOrEmpty(originalPath)) { originalPath = ApplicationPaths.AppDataPath(); } if (!originalPath.Equals(workingApplicationConfiguration.LogFilePath, StringComparison.OrdinalIgnoreCase)) { FileCopier.CopyFilesToFolder(originalPath, workingApplicationConfiguration.LogFilePath, "*.json"); } }
public void Should_Throw_If_Target_Directory_Does_Not_Exist() { const string dstPath = "/dst"; // Given var fixture = new FileCopierFixture(); // When var result = Record.Exception(() => FileCopier.CopyFiles(fixture.Context, Enumerable.Empty <FilePath>(), new DirectoryPath(dstPath), true)); // Then AssertEx.IsExceptionWithMessage <DirectoryNotFoundException>(result, $"The directory '{dstPath}' does not exist."); }
static void Main(string[] args) { var configuration = new Configuration(args); var paths = new AssemblyPaths(configuration); var managedFilesFileCopier = new FileCopier(configuration.ManagedOutputPath); var staticFilesFileCopier = new FileCopier(configuration.OutputPath); var assemblies = new Assemblies(configuration, paths); var artifactsEmbedder = new ArtifactsEmbedder(configuration, assemblies); artifactsEmbedder.Perform(); managedFilesFileCopier.Copy(assemblies.AllImportedAssemblyPaths); managedFilesFileCopier.Copy(assemblies.AllImportedAssemblyDebugSymbolPaths); staticFilesFileCopier.Copy(new[] { Path.Combine(paths.Sdk, "debug", "mono.js"), Path.Combine(paths.Sdk, "debug", "mono.wasm"), Path.Combine(paths.Sdk, "debug", "mono.wasm.map"), Path.Combine(paths.Sdk, "debug", "mono.wast") }); var managedFiles = new List <string>(); managedFiles.AddRange(assemblies.AllImportedAssemblyPaths); managedFiles.AddRange(assemblies.AllImportedAssemblyDebugSymbolPaths); var assembliesFilePath = Path.Combine(configuration.OutputPath, "assemblies.json"); var fileList = string.Join(",\n\t\t", managedFiles.Select(_ => $"\"{Path.GetFileName(_)}\"").ToArray()); File.WriteAllText(assembliesFilePath, $"[\n\t\t{fileList}\n]"); var monoConfigPath = Path.Combine(configuration.OutputPath, "mono-config.js"); File.WriteAllText(monoConfigPath, $"config = {{\n\tvfs_prefix: 'managed',\n\tdeploy_prefix: 'managed',\n\tenable_debugging: 0, \n\tfile_list: [\n\t\t{fileList}\n\t ],\n\tadd_bindings: function() {{ \n\t\tModule.mono_bindings_init ('[WebAssembly.Bindings]WebAssembly.Runtime');\n\t}}\n}}" ); var monoJsSource = Path.Combine(paths.Sdk, "debug", "mono.js"); var monoJsDestination = Path.Combine(configuration.OutputPath, "mono.js"); var monoJs = File.ReadAllText(monoJsSource); monoJs = monoJs.Replace("this.mono_wasm_runtime_is_ready=true;debugger", "this.mono_wasm_runtime_is_ready=true;"); monoJs = monoJs.Replace( " this.mono_wasm_runtime_is_ready = true;\n"+ " debugger;\n", " this.mono_wasm_runtime_is_ready = true;\n"); File.WriteAllText(monoJsDestination, monoJs); }
public void CopyFileTest() { const string fileToCopyPath = @"c:\test.txt"; const string targetDirectoryPath = @"d:\"; var fileSystem = new Mock<IFileSystem>(); var fileToCopy = new Mock<IFile>(); var targetDirectory = new Mock<IDirectory>(); fileSystem.Setup(s => s.GetFile(fileToCopyPath)).Returns(fileToCopy.Object); fileSystem.Setup(s => s.GetDirectory(targetDirectoryPath)).Returns(targetDirectory.Object); fileToCopy.Setup(f => f.CopyTo(targetDirectory.Object, true)); IoCContainer.Clear(); IoCContainer.RegisterInstance(typeof (IFileSystem), fileSystem.Object); var fileCopier = new FileCopier(); fileCopier.CopyFile(fileToCopyPath, targetDirectoryPath, true); fileSystem.VerifyAll(); fileToCopy.VerifyAll(); targetDirectory.VerifyAll(); }