Exemplo n.º 1
0
        void Run(string[] args)
        {
            int argn = 0;

            if (args[argn].Equals("-l"))
            {
                ListFormats();
                return;
            }
            if (args[argn].Equals("-t"))
            {
                TestArc(args);
                return;
            }
            if (args[argn].Equals("-x"))
            {
                ++argn;
                if (args.Length < 2)
                {
                    Usage();
                    return;
                }
            }
            DeserializeGameData();
            foreach (var file in VFS.GetFiles(args[argn]))
            {
                m_arc_name = file.Name;
                var arc = ArcFile.TryOpen(file);
                if (null == arc)
                {
                    Console.Error.WriteLine("{0}: unknown format", m_arc_name);
                    continue;
                }
                using (arc)
                {
                    if (args.Length > argn + 1)
                    {
                        for (int i = argn + 1; i < args.Length; ++i)
                        {
                            ExtractFile(arc, args[i]);
                        }
                    }
                    else if (args[0].Equals("-x"))
                    {
                        ExtractAll(arc);
                    }
                    else
                    {
                        foreach (var entry in arc.Dir.OrderBy(e => e.Offset))
                        {
                            Console.WriteLine("{0,9} [{2:X8}] {1}", entry.Size, entry.Name, entry.Offset);
                        }
                    }
                }
            }
        }