/// <summary> /// Loads the files.dat file containing the records of any existing protected file data /// </summary> private void LoadFileList() { try { using (FileStream metaData = new FileStream(MetaFilePath, FileMode.Open, FileAccess.Read)) { UInt32 version = FileRecord.ReadUInt32(metaData); if (version == 1) { // skip past unused count field FileRecord.ReadUInt32(metaData); } else if (version != META_FILE_VERSION) { throw new Exception("file version mismatch: " + MetaFilePath); } files.Clear(); while (metaData.Position < metaData.Length) { FileRecord r = FileRecord.LoadFromFile(metaData, this); if (r == null) { break; } files[r.Name.ToLower()] = r; } } } catch (Exception e) { env.LogCrash(e); LogFile.Log(String.Format("Error reading {0}: {1}", MetaFilePath, e.Message)); files.Clear(); throw new MetaFileLoadException(MetaFilePath, e); } CalculateMaxBlock(); FileCount = files.Count; }