Ejemplo n.º 1
0
 static void Main(string[] args)
 {
     try
     {
         var program = new ImageConverter();
         program.Run (args);
     }
     catch (Exception X)
     {
         Console.Error.WriteLine ("{0}: {1}", ProgramName, X.Message);
     }
 }
Ejemplo n.º 2
0
        void Run(string[] args)
        {
            int argn = 0;

            while (argn < args.Length)
            {
                if (args[argn].Equals("-l"))
                {
                    ListFormats();
                    return;
                }
                else if (args[argn].Equals("-t"))
                {
                    TestArc(args);
                    return;
                }
                else if (args[argn].Equals("-c"))
                {
                    if (argn + 1 >= args.Length)
                    {
                        Usage();
                        return;
                    }
                    var tag = args[argn + 1];
                    m_image_format = ImageConverter.FindFormat(tag);
                    if (null == m_image_format)
                    {
                        Console.Error.WriteLine("{0}: unknown format specified", tag);
                        return;
                    }
                    argn += 2;
                }
                else if (args[argn].Equals("-x"))
                {
                    m_extract_all = true;
                    ++argn;
                    if (args.Length <= argn)
                    {
                        Usage();
                        return;
                    }
                }
                else
                {
                    break;
                }
            }
            if (argn >= args.Length)
            {
                Usage();
                return;
            }
            DeserializeGameData();
            foreach (var file in VFS.GetFiles(args[argn]))
            {
                m_arc_name = file.Name;
                try
                {
                    VFS.ChDir(m_arc_name);
                }
                catch (Exception X)
                {
                    Console.Error.WriteLine("{0}: unknown format", m_arc_name);
                    continue;
                }
                var arc = (ArchiveFileSystem)VFS.Top;
                if (args.Length > argn + 1)
                {
                    for (int i = argn + 1; i < args.Length; ++i)
                    {
                        ExtractFile(arc.Source, args[i]);
                    }
                }
                else if (m_extract_all)
                {
                    ExtractAll(arc.Source);
                }
                else
                {
                    foreach (var entry in arc.Source.Dir.OrderBy(e => e.Offset))
                    {
                        Console.WriteLine("{0,9} [{2:X8}] {1}", entry.Size, entry.Name, entry.Offset);
                    }
                }
            }
        }