Пример #1
0
        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("============================================================================");
            }
        }
Пример #2
0
        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("============================================================================");
            }
        }