public void TempFolder_Exists() { var filepath = Path.Combine(Path.GetTempPath(), $"CSharpEXT/Test"); using (var tmp = TempFolder.FactoryByPath(filepath, deleteAfter: true)) { Directory.Exists(filepath).Should().BeTrue(); } Directory.Exists(filepath).Should().BeFalse(); }
public ITempFolder Create( string path, bool deleteAfter = true, bool throwIfUnsuccessfulDisposal = true) { return(TempFolder.FactoryByPath( new DirectoryPath(path), deleteAfter: deleteAfter, throwIfUnsuccessfulDisposal: throwIfUnsuccessfulDisposal, fileSystem: _fileSystem)); }
public (TempFolder TempFolder, Test Test) SetupProcessedFiles() { var tmp = TempFolder.FactoryByPath(Path.Combine(Path.GetTempPath(), $"Mutagen_Binary_Tests/{Nickname}"), deleteAfter: Settings.DeleteCachesAfter); var test = new Test( $"Setup Processed Files", parallel: Settings.Parallel, toDo: async(o) => { o.OnNext(this.Nickname); var outputPath = ExportFileName(tmp); var observableOutputPath = ObservableExportFileName(tmp); var decompressedPath = UncompressedFileName(tmp); var alignedPath = AlignedFileName(tmp); var orderedPath = OrderedFileName(tmp); var preprocessedPath = alignedPath; var processedPath = ProcessedPath(tmp); if (!Settings.CacheReuse.ReuseDecompression || !File.Exists(decompressedPath)) { try { using var outStream = new FileStream(decompressedPath, FileMode.Create, FileAccess.Write); ModDecompressor.Decompress( streamCreator: () => new MutagenBinaryReadStream(this.FilePath, this.GameRelease), outputStream: outStream); } catch (Exception) { if (File.Exists(decompressedPath)) { File.Delete(decompressedPath); } throw; } } if (!Settings.CacheReuse.ReuseAlignment || !File.Exists(alignedPath)) { ModRecordAligner.Align( inputPath: decompressedPath, outputPath: alignedPath.Path, gameMode: this.GameRelease, alignmentRules: GetAlignmentRules(), temp: tmp); } BinaryFileProcessor.Config instructions; if (!Settings.CacheReuse.ReuseProcessing || !File.Exists(processedPath)) { instructions = new BinaryFileProcessor.Config(); var processor = this.ProcessorFactory(); if (processor != null) { await processor.Process( tmpFolder: tmp, logging: o, sourcePath: this.FilePath, preprocessedPath: alignedPath, outputPath: processedPath); } } }); test.AddDisposeAction(tmp); return(tmp, test); }