Пример #1
0
        /// <summary>
        /// Main function for extracting archives.
        /// </summary>
        static void ExtractArchive(string[] args)
        {
            GenericArchive arc;
            string         arcname = extension.ToUpperInvariant();

            Console.WriteLine("Extracting {0} file: {1}", arcname.Substring(1, arcname.Length - 1), filePath);
            byte[] arcdata = File.ReadAllBytes(filePath);
            outputPath = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
            switch (extension.ToLowerInvariant())
            {
            case (".rel"):
                outputPath = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath) + "_dec.rel");
                Console.WriteLine("Output file: {0}", outputPath);
                byte[] inputData  = File.ReadAllBytes(args[0]);
                byte[] outputData = SplitTools.HelperFunctions.DecompressREL(inputData);
                File.WriteAllBytes(outputPath, outputData);
                Console.WriteLine("File extracted!");
                return;

            case (".pvmx"):
                arc = new PVMXFile(arcdata);
                break;

            case (".arcx"):
                arc = new ARCXFile(arcdata);
                break;

            case (".prs"):
                arcdata = FraGag.Compression.Prs.Decompress(arcdata);
                if (ARCXFile.Identify(arcdata))
                {
                    arc = new ARCXFile(arcdata);
                }
                else if (PuyoFile.Identify(arcdata) == PuyoArchiveType.Unknown)
                {
                    outputPath = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath) + ".bin");
                    Console.WriteLine("Output file: {0}", Path.GetFullPath(outputPath));
                    File.WriteAllBytes(outputPath, arcdata);
                    Console.WriteLine("Archive extracted!");
                    return;
                }
                else
                {
                    arc = new PuyoFile(arcdata);
                }
                break;

            case (".pvm"):
            case (".gvm"):
                arc = new PuyoFile(arcdata);
                break;

            case (".xvm"):
                arc = new XVM(arcdata);
                break;

            case (".pb"):
                arc = new PBFile(arcdata);
                break;

            case (".pak"):
                arc = new PAKFile(filePath);
                break;

            case (".dat"):
                arc = new DATFile(arcdata);
                break;

            case (".mdl"):
                arc = new MDLArchive(arcdata);
                break;

            case (".mdt"):
                arc = new MDTArchive(arcdata);
                break;

            case (".mld"):
                arc = new MLDArchive(arcdata);
                break;

            case (".mlt"):
            case (".gcaxmlt"):
                string test = System.Text.Encoding.ASCII.GetString(arcdata, 0, 4);
                if (test == "gcax")
                {
                    arc = new gcaxMLTFile(arcdata, Path.GetFileNameWithoutExtension(filePath));
                }
                else
                {
                    arc = new MLTFile(arcdata, Path.GetFileNameWithoutExtension(filePath));
                }
                break;

            default:
                Console.WriteLine("Unknown archive type");
                return;
            }
            Console.WriteLine("Output folder: {0}", Path.GetFullPath(outputPath));
            Directory.CreateDirectory(outputPath);
            foreach (GenericArchiveEntry entry in arc.Entries)
            {
                if (entry.Data == null)
                {
                    Console.WriteLine("Entry {0} has no data", entry.Name);
                    continue;
                }
                Console.WriteLine("Extracting file: {0}", entry.Name);
                if (arc is ARCXFile)
                {
                    ARCXFile.ARCXEntry ARCXentry = (ARCXFile.ARCXEntry)entry;
                    Directory.CreateDirectory(Path.Combine(outputPath, ARCXentry.Folder));
                    File.WriteAllBytes(Path.Combine(outputPath, ARCXentry.Folder, entry.Name), entry.Data);
                }
                else
                {
                    File.WriteAllBytes(Path.Combine(outputPath, entry.Name), entry.Data);
                }
            }
            arc.CreateIndexFile(outputPath);
            Console.WriteLine("Archive extracted!");
        }
Пример #2
0
        /// <summary>
        /// Main function for extracting archives.
        /// </summary>
        static void ExtractArchive(string[] args)
        {
            GenericArchive arc;
            string         arcname = extension.ToUpperInvariant();

            Console.WriteLine("Extracting {0} file: {1}", arcname.Substring(1, arcname.Length - 1), filePath);
            byte[] arcdata = File.ReadAllBytes(filePath);
            outputPath = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
            switch (extension.ToLowerInvariant())
            {
            case (".rel"):
                outputPath = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath) + "_dec.rel");
                Console.WriteLine("Output file: {0}", outputPath);
                byte[] inputData  = File.ReadAllBytes(args[0]);
                byte[] outputData = SA_Tools.HelperFunctions.DecompressREL(inputData);
                File.WriteAllBytes(outputPath, outputData);
                Console.WriteLine("File extracted!");
                return;

            case (".pvmx"):
                arc = new PVMXFile(arcdata);
                break;

            case (".prs"):
                arcdata = FraGag.Compression.Prs.Decompress(arcdata);
                if (PuyoFile.Identify(arcdata) == PuyoArchiveType.Unknown)
                {
                    outputPath = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath) + ".bin");
                    Console.WriteLine("Output file: {0}", Path.GetFullPath(outputPath));
                    File.WriteAllBytes(outputPath, arcdata);
                    Console.WriteLine("Archive extracted!");
                    return;
                }
                arc = new PuyoFile(arcdata);
                break;

            case (".pvm"):
            case (".gvm"):
                arc = new PuyoFile(arcdata);
                break;

            case (".pb"):
                arc = new PBFile(arcdata);
                break;

            case (".pak"):
                arc = new PAKFile(filePath);
                break;

            case (".dat"):
                arc = new DATFile(arcdata);
                break;

            case (".mdl"):
                arc = new MDLArchive(arcdata);
                break;

            case (".mdt"):
                arc = new MDTArchive(arcdata);
                break;

            case (".mld"):
                arc = new MLDArchive(arcdata);
                break;

            case (".mlt"):
                arc = new MLTArchive(arcdata);
                break;

            default:
                Console.WriteLine("Unknown archive type");
                return;
            }
            Console.WriteLine("Output folder: {0}", Path.GetFullPath(outputPath));
            Directory.CreateDirectory(outputPath);
            foreach (GenericArchiveEntry entry in arc.Entries)
            {
                Console.WriteLine("Extracting file: {0}", entry.Name);
                File.WriteAllBytes(Path.Combine(outputPath, entry.Name), entry.Data);
            }
            arc.CreateIndexFile(outputPath);
            Console.WriteLine("Archive extracted!");
        }