Ejemplo n.º 1
0
        internal void readOPT()
        {
            bool deleteOpt = false;

            try
            {
                using (BinaryReader br = new BinaryReader(File.Open(optPath, FileMode.Open, FileAccess.Read), Encoding.ASCII))
                {
                    while (br.PeekChar() != -1)
                    {
                        int len = 0;
                        len = br.ReadInt32();
                        string[] optBlocks = des.Decrypt(br.ReadBytes(len)).Split('|');

                        if (optBlocks.Length == 3)
                        {
                            string type  = optBlocks[0];
                            string name  = optBlocks[1];
                            object value = null;

                            switch (type)
                            {
                            case "s":     // string
                                value = optBlocks[2].TrimEnd('\0');
                                break;

                            case "b":     // bool
                                value = Convert.ToBoolean(optBlocks[2]);
                                break;

                            case "n":
                                value = Convert.ToInt32(optBlocks[2]);
                                break;
                            }

                            if (!string.IsNullOrEmpty(name) && value != null)
                            {
                                settingsList.Add(new LauncherSetting()
                                {
                                    Type = type, Name = name, Value = value
                                });
                            }
                        }
                        else
                        {
                            deleteOpt = true;
                            break;
                        }
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        internal void readOPT()
        {
            try
            {
                using (BinaryReader br = new BinaryReader(File.Open(optPath, FileMode.Open, FileAccess.Read), Encoding.ASCII))
                {
                    while (br.PeekChar() != -1)
                    {
                        int len = 0;
                        len = br.ReadInt32();
                        string[] optBlocks = des.Decrypt(br.ReadBytes(len)).Split('|');

                        if (optBlocks.Length == 3)
                        {
                            string type  = optBlocks[0];
                            string name  = optBlocks[1];
                            object value = null;

                            switch (type)
                            {
                            case "s":     // string
                                value = optBlocks[2].TrimEnd('\0');
                                break;

                            case "b":     // bool
                                value = Convert.ToBoolean(optBlocks[2]);
                                break;
                            }

                            if (!string.IsNullOrEmpty(name) && value != null)
                            {
                                Console.WriteLine("Setting: {0}|{1}|{2}", type, name, value);
                            }
                        }
                        else
                        {
                            Console.WriteLine("Failed to read config.opt [CORRUPTED]");
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }