public void SetDefaults() { CacheFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RomVault2_" + DBVersion.Version + ".Cache"); DatRoot = "DatRoot"; ScanLevel = eScanLevel.Level2; FixLevel = eFixLevel.TrrntZipLevel2; IgnoreFiles = new List <string> { "_ReadMe_.txt" }; ResetDirectories(); ReadConfig(); DirPathMap.Sort(); }
private void ReadConfig() { if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RomVault2cfg.xml"))) { using (StreamReader sr = new StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RomVault2cfg.xml"))) { System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(Program.rvSettings.GetType()); Program.rvSettings = (Settings)x.Deserialize(sr); } return; } if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RomVault2.cfg"))) { FileStream fs = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RomVault2.cfg"), FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); int ver = br.ReadInt32(); if (ver == 1) { DatRoot = br.ReadString(); ScanLevel = eScanLevel.Level1; FixLevel = (eFixLevel)br.ReadInt32(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } } if (ver == 2) { DatRoot = br.ReadString(); ScanLevel = (eScanLevel)br.ReadInt32(); FixLevel = (eFixLevel)br.ReadInt32(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } } if (ver == 3) { DatRoot = br.ReadString(); ScanLevel = (eScanLevel)br.ReadInt32(); FixLevel = (eFixLevel)br.ReadInt32(); DebugLogsEnabled = br.ReadBoolean(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } } if (ver == 4) { DatRoot = br.ReadString(); ScanLevel = (eScanLevel)br.ReadInt32(); FixLevel = (eFixLevel)br.ReadInt32(); DebugLogsEnabled = br.ReadBoolean(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } CacheSaveTimerEnabled = br.ReadBoolean(); CacheSaveTimePeriod = br.ReadInt32(); } if (ver == 5) { DatRoot = br.ReadString(); ScanLevel = (eScanLevel)br.ReadInt32(); FixLevel = (eFixLevel)br.ReadInt32(); DebugLogsEnabled = br.ReadBoolean(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } CacheSaveTimerEnabled = br.ReadBoolean(); CacheSaveTimePeriod = br.ReadInt32(); DoubleCheckDelete = br.ReadBoolean(); } if (ver == 6) { DatRoot = br.ReadString(); ScanLevel = (eScanLevel)br.ReadInt32(); FixLevel = (eFixLevel)br.ReadInt32(); DebugLogsEnabled = br.ReadBoolean(); bool UserLongFilenames = br.ReadBoolean(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } CacheSaveTimerEnabled = br.ReadBoolean(); CacheSaveTimePeriod = br.ReadInt32(); DoubleCheckDelete = br.ReadBoolean(); } br.Close(); fs.Close(); } }
private static void ReadConfig() { if (!File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RomVault2.cfg"))) { return; } FileStream fs = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RomVault2.cfg"), FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); int ver = br.ReadInt32(); if (ver == 1) { DatRoot = br.ReadString(); ScanLevel = eScanLevel.Level1; FixLevel = (eFixLevel)br.ReadInt32(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } } if (ver == 2) { DatRoot = br.ReadString(); ScanLevel = (eScanLevel)br.ReadInt32(); FixLevel = (eFixLevel)br.ReadInt32(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } } if (ver == 3) { DatRoot = br.ReadString(); ScanLevel = (eScanLevel)br.ReadInt32(); FixLevel = (eFixLevel)br.ReadInt32(); DebugLogsEnabled = br.ReadBoolean(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } } if (ver == 4) { DatRoot = br.ReadString(); ScanLevel = (eScanLevel)br.ReadInt32(); FixLevel = (eFixLevel)br.ReadInt32(); DebugLogsEnabled = br.ReadBoolean(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } CacheSaveTimerEnabled = br.ReadBoolean(); CacheSaveTimePeriod = br.ReadInt32(); } if (ver == 5) { DatRoot = br.ReadString(); ScanLevel = (eScanLevel)br.ReadInt32(); FixLevel = (eFixLevel)br.ReadInt32(); DebugLogsEnabled = br.ReadBoolean(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } CacheSaveTimerEnabled = br.ReadBoolean(); CacheSaveTimePeriod = br.ReadInt32(); DoubleCheckDelete = br.ReadBoolean(); } if (ver == 6) { DatRoot = br.ReadString(); ScanLevel = (eScanLevel)br.ReadInt32(); FixLevel = (eFixLevel)br.ReadInt32(); DebugLogsEnabled = br.ReadBoolean(); bool UserLongFilenames = br.ReadBoolean(); IgnoreFiles = new List <string>(); int c = br.ReadInt32(); for (int i = 0; i < c; i++) { IgnoreFiles.Add(br.ReadString()); } DirPathMap = new List <DirMap>(); c = br.ReadInt32(); for (int i = 0; i < c; i++) { DirPathMap.Add(new DirMap(br.ReadString(), br.ReadString())); } CacheSaveTimerEnabled = br.ReadBoolean(); CacheSaveTimePeriod = br.ReadInt32(); DoubleCheckDelete = br.ReadBoolean(); } br.Close(); fs.Close(); }