private void ExtractMod(DirectoryInfo outDirectory, SimpleMod mod, SqPackStream dataStream) { PluginLog.Log(" -> Extracting {0} at {1}", mod.FullPath, mod.ModOffset.ToString("X")); try { var data = dataStream.ReadFile <FileResource>(mod.ModOffset); var extractedFile = new FileInfo(Path.Combine(outDirectory.FullName, mod.FullPath)); extractedFile.Directory?.Create(); File.WriteAllBytes(extractedFile.FullName, data.Data); } catch (Exception ex) { PluginLog.LogError(ex, "Could not export mod."); } }
private List <FileInfo> Extract(ModsJson mods, SqPackStream pack, DirectoryInfo outputDirectory) { Console.WriteLine(" > " + mods.FullPath); FileResource dat = pack.ReadFile <FileResource>(mods.ModOffset); FileInfo fileInfo = new FileInfo(outputDirectory.FullName + "/" + mods.FullPath); if (!fileInfo.Directory.Exists) { fileInfo.Directory.Create(); } dat.SaveFile(fileInfo.FullName); if (fileInfo.Extension == ".meta") { return(Metadata.Expand(fileInfo)); } return(new List <FileInfo>() { fileInfo }); }