private void ParseHeader() { string archivePath = Path.Combine(directoryLocation, GetArchiveName(DIR_PAK) + ".vpk"); if (File.Exists(archivePath)) { header = new VPKHeader(); preloadStream = new FileStream(archivePath, FileMode.Open, FileAccess.Read); uint signature = DataParser.ReadUInt(preloadStream); if (signature != VPKHeader.Signature) { return; } header.Version = DataParser.ReadUInt(preloadStream); header.TreeSize = DataParser.ReadUInt(preloadStream); headerSize = 12; if (header.Version > 1) { header.FileDataSectionSize = DataParser.ReadUInt(preloadStream); header.ArchiveMD5SectionSize = DataParser.ReadUInt(preloadStream); header.OtherMD5SectionSize = DataParser.ReadUInt(preloadStream); header.SignatureSectionSize = DataParser.ReadUInt(preloadStream); headerSize += 16; } ParseTree(preloadStream); } }
protected virtual void Dispose(bool disposing) { if (disposing) { preloadStream?.Dispose(); foreach (var streamWrapper in openStreams) { streamWrapper.stream?.Dispose(); } archivesNotFound.Clear(); archivesNotFound = null; header = null; if (tree != null) { foreach (var extPair in tree) { if (extPair.Value != null) { foreach (var dirPair in extPair.Value) { if (dirPair.Value != null) { foreach (var entryPair in dirPair.Value) { entryPair.Value.Dispose(); } dirPair.Value.Clear(); } } extPair.Value.Clear(); } } tree.Clear(); } tree = null; } }