static void ExtractFromMSCab(string path, MiniYaml actionYaml, List <string> extractedFiles, Action <string> updateMessage) { var sourcePath = Path.Combine(path, actionYaml.Value); // Try as an absolute path if (!File.Exists(sourcePath)) { sourcePath = Platform.ResolvePath(actionYaml.Value); } using (var source = File.OpenRead(sourcePath)) { var reader = new MSCabCompression(source); foreach (var node in actionYaml.Nodes) { var targetPath = Platform.ResolvePath(node.Key); if (File.Exists(targetPath)) { Log.Write("install", "Skipping installed file " + targetPath); continue; } extractedFiles.Add(targetPath); Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); using (var target = File.OpenWrite(targetPath)) { Log.Write("install", "Extracting {0} -> {1}".F(sourcePath, targetPath)); var displayFilename = Path.GetFileName(Path.GetFileName(targetPath)); Action <int> onProgress = percent => updateMessage("Extracting {0} ({1}%)".F(displayFilename, percent)); reader.ExtractFile(node.Value.Value, target, onProgress); } } } }
static void ExtractFromMSCab(string path, MiniYaml actionYaml, List <string> extractedFiles, Action <string> updateMessage) { // Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected disc path var sourcePath = actionYaml.Value.StartsWith("^") ? Platform.ResolvePath(actionYaml.Value) : Path.Combine(path, actionYaml.Value); using (var source = File.OpenRead(sourcePath)) { var reader = new MSCabCompression(source); foreach (var node in actionYaml.Nodes) { var targetPath = Platform.ResolvePath(node.Key); if (File.Exists(targetPath)) { Log.Write("install", "Skipping installed file " + targetPath); continue; } extractedFiles.Add(targetPath); Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); using (var target = File.OpenWrite(targetPath)) { Log.Write("install", "Extracting {0} -> {1}".F(sourcePath, targetPath)); var displayFilename = Path.GetFileName(Path.GetFileName(targetPath)); Action <int> onProgress = percent => updateMessage("Extracting {0} ({1}%)".F(displayFilename, percent)); reader.ExtractFile(node.Value.Value, target, onProgress); } } } }
void IUtilityCommand.Run(Utility utility, string[] args) { var package = new MSCabCompression(File.OpenRead(args[1])); foreach (var file in package.Contents) { Console.WriteLine("{0}", file); } }
public void Run(ModData modData, string[] args) { var package = new MSCabCompression(File.OpenRead(args[1])); foreach (var file in package.Contents) { Console.WriteLine("{0}", file); } }