// TODO: The package should be mounted into its own context to avoid name collisions with installed files public static bool ExtractFromPackage(FileSystem.FileSystem fileSystem, string srcPath, string package, Dictionary <string, string[]> filesByDirectory, string destPath, bool overwrite, ContentInstaller.FilenameCase caseModifier, Action <string> onProgress, Action <string> onError) { Directory.CreateDirectory(destPath); Log.Write("debug", "Mounting {0}".F(srcPath)); fileSystem.Mount(srcPath); Log.Write("debug", "Mounting {0}".F(package)); fileSystem.Mount(package); foreach (var directory in filesByDirectory) { var targetDir = directory.Key; foreach (var file in directory.Value) { var containingDir = Path.Combine(destPath, targetDir); var dest = Path.Combine(containingDir, GetFileName(file, caseModifier)); if (File.Exists(dest)) { if (overwrite) { File.Delete(dest); } else { Log.Write("debug", "Skipping {0}".F(dest)); continue; } } Directory.CreateDirectory(containingDir); using (var sourceStream = fileSystem.Open(file)) using (var destStream = File.Create(dest)) { Log.Write("debug", "Extracting {0} to {1}".F(file, dest)); onProgress("Extracting " + file); destStream.Write(sourceStream.ReadAllBytes()); } } } return(true); }
void IUtilityCommand.Run(Utility utility, string[] args) { var filename = Path.GetFileName(args[1]); var path = Path.GetDirectoryName(args[1]); var fs = new FileSystem.FileSystem(utility.Mods); fs.Mount(path, "parent"); var package = new InstallShieldPackage(fs, "parent|" + filename); foreach (var kv in package.Index) { Console.WriteLine("{0}:", kv.Key); Console.WriteLine("\tOffset: {0}", 255 + kv.Value.Offset); Console.WriteLine("\tLength: {0}", kv.Value.Length); } }
void IUtilityCommand.Run(Utility utility, string[] args) { var filename = Path.GetFileName(args[1]); var path = Path.GetDirectoryName(args[1]); var fs = new FileSystem.FileSystem(utility.Mods); // Needed to access the global mix database fs.LoadFromManifest(utility.ModData.Manifest); fs.Mount(path, "parent"); var package = new MixFile(fs, "parent|" + filename); foreach (var kv in package.Index.OrderBy(kv => kv.Value.Offset)) { Console.WriteLine("{0}:", kv.Key); Console.WriteLine("\tOffset: {0}", kv.Value.Offset); Console.WriteLine("\tLength: {0}", kv.Value.Length); } }