private static void CreateFolders(AbsolutePath to, string profile) { Console.WriteLine("Creating output folders"); to.CreateDirectory(); to.Combine("mods", "Cooked Files").CreateDirectory(); to.Combine("profiles", profile).CreateDirectory(); }
public TemporaryDirectory(AbsolutePath name) { FullName = name; if (!FullName.Exists) { FullName.CreateDirectory(); } }
public async Task InitializeAsync() { Queue = new WorkQueue(); _unsub = Utils.LogMessages.Subscribe(f => TestContext.WriteLine(f.ShortDescription)); _stagingFolder.CreateDirectory(); await _bsaFolder.DeleteDirectory(); _bsaFolder.CreateDirectory(); }
public EndToEndTests(ITestOutputHelper helper) : base(helper) { Queue = new WorkQueue(); Consts.TestMode = true; utils = new TestUtils(); utils.Game = Game.SkyrimSpecialEdition; _unsub = Utils.LogMessages.Subscribe(f => XunitContext.WriteLine($"{DateTime.Now} - {f}")); _downloadFolder.CreateDirectory(); }
[InlineData(Game.Fallout4, 43474)] // EM 2 Rifle public async Task BSACompressionRecompression(Game game, int modid) { var filename = await DownloadMod(game, modid); var folder = _bsaFolder.Combine(game.ToString(), modid.ToString()); await folder.DeleteDirectory(); folder.CreateDirectory(); await using var files = await FileExtractor.ExtractAll(Queue, filename); await files.MoveAllTo(folder); foreach (var bsa in folder.EnumerateFiles().Where(f => Consts.SupportedBSAs.Contains(f.Extension))) { TestContext.WriteLine($"From {bsa}"); TestContext.WriteLine("Cleaning Output Dir"); await _tempDir.DeleteDirectory(); _tempDir.CreateDirectory(); TestContext.WriteLine($"Reading {bsa}"); var tempFile = ((RelativePath)"tmp.bsa").RelativeToEntryPoint(); var size = bsa.Size; await using var a = BSADispatch.OpenRead(bsa); await a.Files.PMap(Queue, file => { var absName = _tempDir.Combine(file.Path); ViaJson(file.State); absName.Parent.CreateDirectory(); using (var fs = absName.Create()) { file.CopyDataTo(fs); } Assert.Equal(file.Size, absName.Size); }); // Check Files should be case insensitive Assert.Equal(a.Files.Count(), a.Files.Select(f => f.Path).ToHashSet().Count); Assert.Equal(a.Files.Count(), a.Files.Select(f => f.Path.ToString().ToLowerInvariant()).ToHashSet().Count); TestContext.WriteLine($"Building {bsa}"); await using (var w = ViaJson(a.State).MakeBuilder(size)) { var streams = await a.Files.PMap(Queue, async file => { var absPath = _tempDir.Combine(file.Path); var str = absPath.OpenRead(); await w.AddFile(ViaJson(file.State), str); return(str); }); await w.Build(tempFile); streams.Do(s => s.Dispose()); } TestContext.WriteLine($"Verifying {bsa}"); await using var b = BSADispatch.OpenRead(tempFile); TestContext.WriteLine($"Performing A/B tests on {bsa}"); Assert.Equal(a.State.ToJson(), b.State.ToJson()); // Check same number of files Assert.Equal(a.Files.Count(), b.Files.Count()); await a.Files.Zip(b.Files, (ai, bi) => (ai, bi)) .PMap(Queue, pair => { Assert.Equal(pair.ai.State.ToJson(), pair.bi.State.ToJson()); //Console.WriteLine($" - {pair.ai.Path}"); Assert.Equal(pair.ai.Path, pair.bi.Path); //Equal(pair.ai.Compressed, pair.bi.Compressed); Assert.Equal(pair.ai.Size, pair.bi.Size); Assert.Equal(GetData(pair.ai), GetData(pair.bi)); }); } }
public async Task InitializeAsync() { await VFS_TEST_DIR.DeleteDirectory(); VFS_TEST_DIR.CreateDirectory(); }