private void CacheARC(List <RunProcessJob> runProcessJobs, IFileSystem filesDir, string filePath, string dirPath, Cache cache) { cache.ContainerDirs[filePath] = ContainerType.ARC; mLogger.Information($"Unpacking {filePath}"); // Copy archive to cache (but only if not already in cache) mCacheFilesDir.CreateDirectory(dirPath); if (!mCacheFilesDir.FileExists(filePath)) { filesDir.CopyFile(filePath, mCacheFilesDir, filePath, false); // If the directory the arc is being extracted to is in the same directory as the file itself, delete the original file if (PathHelper.AreInSameDirectory(filePath, dirPath)) { mCacheFilesDir.DeleteFile(filePath); } } // Extract it var process = new Process(); process.StartInfo = new ProcessStartInfo(mConfiguration.ArcExtractPath, Path.GetFullPath(mCacheFilesDir.GetPhysicalPath(filePath))) { RedirectStandardOutput = false, CreateNoWindow = true }; process.Start(); runProcessJobs.Add(new RunProcessJob(process) { TemporaryFiles = { Path.GetFullPath(mCacheFilesDir.GetPhysicalPath(filePath)) } }); }
private void PatchAW(string dirPath, string relDirPath) { // Get base files if (!mBinDir.FileExists(BAA_PATH)) { mCacheFilesDir.CopyFile(BAA_PATH, mBinDir, BAA_PATH, true); } var awFileName = Path.ChangeExtension(relDirPath, ".aw"); if (!mBinDir.FileExists(awFileName)) { mCacheFilesDir.CopyFile(awFileName, mBinDir, awFileName, true); } // Build BAA patch mLogger.Information("Build BAA patch"); BAAPatch patch; using (var baaStream = mBinDir.OpenFile(BAA_PATH, FileMode.Open, FileAccess.Read)) using (var awStream = mBinDir.OpenFile(awFileName, FileMode.Open, FileAccess.Read)) { var baaPatchBuilder = new BAAPatchBuilder(mLogger); baaPatchBuilder.SetBAAStream(baaStream); baaPatchBuilder.PatchAW(awStream, mBinDir, dirPath); patch = baaPatchBuilder.Build(); } // Overwrite BAA in output directory using (var baaStream = mBinDir.CreateFile(BAA_PATH)) { mLogger.Information($"Writing {BAA_PATH}"); patch.BAAStream.CopyTo(baaStream); } // Overwrite wave files in output directory foreach (var awPatch in patch.AWStreams) { var patchedAwFileName = "AudioRes/Waves/" + awPatch.Key; mLogger.Information($"Writing {awFileName}"); using (var awStream = mBinDir.CreateFile(patchedAwFileName)) awPatch.Value.CopyTo(awStream); } // Delete directory from output mBinDir.DeleteDirectory(dirPath, true); }