public NesVcExtractor(string dumpPath, RpxFile rpxFile) { string nesDictionaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, NES_DICTIONARY_CSV_PATH); nesDictionary = new RomNameDictionary(nesDictionaryPath); nesRomHeader = new byte[NES_HEADER_LENGTH]; romPosition = 0; vcNamePosition = 0; this.rpxFile = rpxFile; }
/// <summary> /// Initializes a new instance of the <see cref="NesVcExtractor"/> class. /// </summary> /// <param name="rpxFile">RPX file to parse.</param> /// <param name="verbose">whether to provide verbose output.</param> public NesVcExtractor(RpxFile rpxFile, bool verbose = false) { this.verbose = verbose; string nesDictionaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, NesDictionaryCsvPath); this.nesDictionary = new RomNameDictionary(nesDictionaryPath); this.nesRomHeader = new byte[NesHeaderLength]; this.romPosition = 0; this.vcNamePosition = 0; this.rpxFile = rpxFile; }
public SnesVcExtractor(string dumpPath, RpxFile rpxFile) { string snesDictionaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SNES_DICTIONARY_CSV_PATH); snesDictionary = new RomNameDictionary(snesDictionaryPath); snesLoRomHeader = new byte[SNES_HEADER_LENGTH]; snesHiRomHeader = new byte[SNES_HEADER_LENGTH]; headerType = SnesHeaderType.NotDetermined; romPosition = 0; vcNamePosition = 0; this.rpxFile = rpxFile; }
public FdsVcExtractor(RpxFile rpxFile, bool verbose = false) { this.verbose = verbose; string nesDictionaryPath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, NES_DICTIONARY_CSV_PATH); nesDictionary = new RomNameDictionary(nesDictionaryPath); fdsRomHeader = new byte[FDS_HEADER_LENGTH]; romPosition = 0; vcNamePosition = 0; numberOfSides = 1; this.rpxFile = rpxFile; }
static void Main(string[] args) { if (args.Length == 0 || args.Length > 2) { PrintUsage(); return; } if (args.Length == 1) { if (args[0] == "--version") { PrintVersion(); return; } } bool verbose = false; if (args[0] == "-v") { verbose = true; Console.WriteLine("Verbose output mode is set"); } string sourcePath = args[args.Length - 1]; if (verbose) { Console.WriteLine("Source extract file is " + Path.GetFullPath(sourcePath)); } if (!File.Exists(sourcePath)) { Console.WriteLine("Could not find file at " + sourcePath + ". Please ensure that your filename is correct."); return; } Console.WriteLine("============================================================================"); Console.WriteLine("Starting extraction of rom from " + sourcePath + "..."); Console.WriteLine("============================================================================"); string extractedRomPath = ""; RpxFile rpxFile = null; PsbFile psbFile = null; PkgFile pkgFile = null; SrlFile srlFile = null; // Identifies filetype of the file argument, // then instantiates file with file's location and verbose if (RpxFile.IsRpx(sourcePath)) { Console.WriteLine("RPX file detected!"); rpxFile = new RpxFile(sourcePath, verbose); } else if (PsbFile.IsPsb(sourcePath)) { Console.WriteLine("PSB file detected!"); psbFile = new PsbFile(sourcePath, verbose); } else if (PkgFile.IsPkg(sourcePath)) { pkgFile = new PkgFile(sourcePath, verbose); } else if (SrlFile.IsSrl(sourcePath)) { Console.WriteLine("SRL file detected!"); srlFile = new SrlFile(sourcePath, verbose); } // Create the list of rom extractors List <IRomExtractor> romExtractors = new List <IRomExtractor>(); if (rpxFile != null) { romExtractors.Add(new NesVcExtractor(rpxFile, verbose)); romExtractors.Add(new SnesVcExtractor(rpxFile.DecompressedPath, verbose)); romExtractors.Add(new FdsVcExtractor(rpxFile, verbose)); } else if (psbFile != null) { romExtractors.Add(new GbaVcExtractor(psbFile, verbose)); } else if (pkgFile != null) { romExtractors.Add(new PceVcExtractor(pkgFile, verbose)); } else if (Path.GetExtension(sourcePath) == ".sfrom") { romExtractors.Add(new SnesVcExtractor(sourcePath, verbose)); } else if (srlFile != null) { romExtractors.Add(new DsVcExtractor(srlFile, verbose)); } // Check with each extractor until a valid rom is found, // Then extract the rom with the appropriate extractor foreach (var romExtractor in romExtractors) { if (romExtractor.IsValidRom()) { extractedRomPath = romExtractor.ExtractRom(); break; } } if (!String.IsNullOrEmpty(extractedRomPath)) { Console.WriteLine("============================================================================"); Console.WriteLine(sourcePath + " has been extracted to " + extractedRomPath + " successfully."); Console.WriteLine("============================================================================"); } else { Console.WriteLine("============================================================================"); Console.WriteLine("FAILURE: Could not successfully identify the rom type for " + sourcePath); Console.WriteLine("============================================================================"); } }
static void Main(string[] args) { if (args.Length != 1) { PrintUsage(); return; } string sourcePath = args[0]; if (!File.Exists(sourcePath)) { Console.WriteLine("Could not find file at " + sourcePath + ". Please ensure that your filename is correct."); return; } Console.WriteLine("============================================================================"); Console.WriteLine("Starting extraction of rom from " + sourcePath + "..."); Console.WriteLine("============================================================================"); string extractedRomPath = ""; RpxFile rpxFile = null; PsbFile psbFile = null; if (RpxFile.IsRpx(sourcePath)) { Console.WriteLine("RPX file detected!"); rpxFile = new RpxFile(sourcePath); } else if (PsbFile.IsPsb(sourcePath)) { Console.WriteLine("PSB file detected!"); psbFile = new PsbFile(sourcePath); } // Create the list of rom extractors List <IRomExtractor> romExtractors = new List <IRomExtractor>(); if (rpxFile != null) { romExtractors.Add(new NesVcExtractor(sourcePath, rpxFile)); romExtractors.Add(new SnesVcExtractor(sourcePath, rpxFile)); } else if (psbFile != null) { romExtractors.Add(new GbaVcExtractor(sourcePath, psbFile)); } foreach (var romExtractor in romExtractors) { if (romExtractor.IsValidRom()) { extractedRomPath = romExtractor.ExtractRom(); break; } } if (!String.IsNullOrEmpty(extractedRomPath)) { Console.WriteLine("============================================================================"); Console.WriteLine(sourcePath + " has been extracted to " + extractedRomPath + " successfully."); Console.WriteLine("============================================================================"); } else { Console.WriteLine("============================================================================"); Console.WriteLine("FAILURE: Could not successfully identify the rom type for " + sourcePath); Console.WriteLine("============================================================================"); } }