using System;
using System.Collections.Generic;
using System.IO;

namespace Zone_Fix
{
    class FileSystem
    {
        public Dictionary<String, String> Settings = new Dictionary<String, String>();

        public FileSystem()
        {
            Program.Writer.WriteLine(WriteType.Information, false, "Attempting To Initialize FileSystem!");

            if (!File.Exists(Properties.Settings.Default.ConfigFile)) { File.WriteAllBytes(Properties.Settings.Default.ConfigFile, Properties.Resources.Config); }

            LoadSettings();

            Program.Writer.WriteLine(WriteType.Information, true, "FileSystem Initialized!");
        }

        private void LoadSettings()
        {
            using (StreamReader Reader = new StreamReader(Properties.Settings.Default.ConfigFile))
            {
                String CurrentLine;

                while ((CurrentLine = Reader.ReadLine()) != null)
                {
                    if (CurrentLine.StartsWith("//") || CurrentLine.StartsWith("#") || CurrentLine.StartsWith(";") || CurrentLine == "") { }
                    else
                    {
                        String[] LineSplit = CurrentLine.Split(new String[] { ": " }, StringSplitOptions.None);

                        Settings.Add(LineSplit[0], LineSplit[1]);
                    }
                }
            }
        }
    }
}
