private static ExpandEraFileResult ExpandEraFile(ExpandEraFileParameters args) { var result = ExpandEraFileResult.Error; using (var expander = new KSoft.Phoenix.Resource.EraFileExpander(args.EraPath)) { expander.Options = args.EraOptions; expander.ExpanderOptions = args.EraExpanderOptions; expander.VerboseOutput = args.VerboseOutput; do { if (!expander.Read()) { result = ExpandEraFileResult.ReadFailed; break; } if (!expander.ExpandTo(args.OutputPath, args.ListingName)) { result = ExpandEraFileResult.ExpandFailed; break; } result = ExpandEraFileResult.Success; } while (false); } return(result); }
static void Expand(string eraPath, string listingName, string outputPath, string switches) { if (string.IsNullOrWhiteSpace(outputPath)) { outputPath = Path.GetDirectoryName(eraPath); } Collections.BitVector32 options, expanderOptions; ExpandParseSwitches(switches, out options, out expanderOptions); if (expanderOptions.Test(KSoft.Phoenix.Resource.EraFileExpanderOptions.Decrypt)) { eraPath += KSoft.Phoenix.Resource.EraFileUtil.kExtensionEncrypted; } else { eraPath += KSoft.Phoenix.Resource.EraFileExpander.kNameExtension; } if (!File.Exists(eraPath)) { Console.WriteLine("Error: Input ERA does not exist '{0}'", eraPath); return; } StreamWriter debug_output = false //options.Test(KSoft.Phoenix.Resource.EraFileUtilOptions.DumpDebugInfo) ? new StreamWriter("debug_expander.txt") : null; using (var expander = new KSoft.Phoenix.Resource.EraFileExpander(eraPath)) { expander.Options = options; expander.ExpanderOptions = expanderOptions; expander.VerboseOutput = Console.Out; expander.DebugOutput = debug_output; if (expander.Read()) { expander.ExpandTo(outputPath, listingName); } } if (debug_output != null) { debug_output.Close(); } }
public bool UnpackEra(string relativeEraPath) { if (IsEraUnpacked(relativeEraPath)) { return(false); } Console.WriteLine($"Unpacking {relativeEraPath}"); var absoluteEraPath = GetAbsoluteGamePath(relativeEraPath); var expander = new KSoft.Phoenix.Resource.EraFileExpander(absoluteEraPath); expander.Options.Set(KSoft.Phoenix.Resource.EraFileUtilOptions.x64); expander.Options.Set(KSoft.Phoenix.Resource.EraFileUtilOptions .SkipVerification); expander.ExpanderOptions.Set(KSoft.Phoenix.Resource.EraFileExpanderOptions .Decrypt); expander.ExpanderOptions.Set(KSoft.Phoenix.Resource.EraFileExpanderOptions .DontOverwriteExistingFiles); expander.ExpanderOptions.Set(KSoft.Phoenix.Resource.EraFileExpanderOptions .DecompressUIFiles); expander.ExpanderOptions.Set(KSoft.Phoenix.Resource.EraFileExpanderOptions .TranslateGfxFiles); if (!expander.Read()) { return(false); } if (!expander.ExpandTo(ScratchDirectory, Path.GetFileNameWithoutExtension( absoluteEraPath))) { return(false); } return(true); }