Exemplo n.º 1
0
        public BlzCoder(IReadOnlyList <string> args)
        {
            int cmd, mode = 0;

            // Title();

            if (args == null || (args.Count != 2))
            {
                throw new Exception("No arguments supplied to BLZ");
            }

            if (args[0].Equals("-d"))
            {
                cmd = CmdDecode;
            }

            else if (args[0].Equals("-en") || args[0].Equals("-en9"))
            {
                cmd  = CmdEncode;
                mode = BlzNormal;
            }
            else if (args[0].Equals("-eo") || args[0].Equals("-eo9"))
            {
                cmd  = CmdEncode;
                mode = BlzBest;
            }
            else
            {
                Console.Write("Command not supported" + Environment.NewLine);
                return;
            }

            if (args.Count < 2)
            {
                Console.Write("Filename not specified" + Environment.NewLine);
            }
            else
            {
                int arg;
                switch (cmd)
                {
                case 0:
                    for (arg = 1; arg < args.Count; arg++)
                    {
                        BlzCoder.BLZ_Decode(args[arg]);
                    }
                    break;

                case 1:
                    this.arm9 = args[0].Length > 3 && args[0][3] == '9';
                    for (arg = 1; arg < args.Count; arg++)
                    {
                        this.BLZ_Encode(args[arg], mode);
                    }
                    break;
                }
            }

            Console.Write(Environment.NewLine + "Done" + Environment.NewLine);
        }
Exemplo n.º 2
0
 private static void BLZ_Decode(string filename)
 {
     try
     {
         Console.Write($"- decoding '{filename}'");
         long      startTime = DateTime.Now.Millisecond;
         byte[]    buf       = File.ReadAllBytes(filename);
         BlzResult result    = BlzCoder.BLZ_Decode(buf);
         if (result != null)
         {
             BlzCoder.Save(filename, result.buffer, result.length);
         }
         Console.Write(" - done, time="
                       + (DateTime.Now.Millisecond - startTime) + "ms");
         Console.Write(Environment.NewLine + "");
     }
     catch (IOException e)
     {
         Console.Write(Environment.NewLine + "File read error" + Environment.NewLine + e);
     }
 }