/// <summary> /// Helper method for the treeification of a list of directory descriptors. /// </summary> /// <param name="directoryId"></param> /// <param name="context"></param> private void DeserializeTreeifyDirectoryDescriptor( uint directoryId, DeserializationContext context, ReleaseManifestDirectoryEntry parent = null) { // construct node at index var directoryDescriptor = context.DirectoryDescriptors[directoryId]; var directoryNode = new ReleaseManifestDirectoryEntry(directoryId, context.ReleaseManifest, directoryDescriptor, parent); context.DirectoryTable[directoryId] = directoryNode; // associate with directory's files // The if statement stops us from setting lastFileId to UINT32.MAX when we are // a childless dir 0 if (directoryDescriptor.FileCount != 0) { var lastFileId = directoryDescriptor.FileStart + directoryDescriptor.FileCount - 1; for (var fileId = directoryDescriptor.FileStart; fileId <= lastFileId; fileId++) { context.FileParentTable[fileId] = directoryNode; } } // load subdirectories var lastSubdirectoryId = directoryDescriptor.SubdirectoryStart + directoryDescriptor.SubdirectoryCount - 1; for (var subdirectoryId = directoryDescriptor.SubdirectoryStart; subdirectoryId <= lastSubdirectoryId; subdirectoryId++) { DeserializeTreeifyDirectoryDescriptor(subdirectoryId, context, directoryNode); } }
private void SerializeDirectory(BinaryWriter writer, ReleaseManifestDirectoryEntry directory) { writer.Write((UInt32)directory.NameStringTableIndex); writer.Write((UInt32)directory.SubdirectoryStart); writer.Write((UInt32)directory.SubdirectoryCount); writer.Write((UInt32)directory.FileStart); writer.Write((UInt32)directory.FileCount); }
internal ReleaseManifestFileEntry( uint fileId, ReleaseManifest releaseManifest, ReleaseManifestFileEntryDescriptor fileDescriptor, ReleaseManifestDirectoryEntry parent) : base(releaseManifest.StringTable[fileDescriptor.NameIndex]) { m_id = fileId; m_releaseManifest = releaseManifest; m_descriptor = fileDescriptor; m_parent = parent; m_parent.m_files.Add(this); m_parent.AddChild(this); // TODO: Override to remove duplication Name = m_releaseManifest.StringTable[NameStringTableIndex]; }
internal ReleaseManifestDirectoryEntry( uint directoryId, ReleaseManifest releaseManifest, ReleaseManifestDirectoryDescriptor descriptor, ReleaseManifestDirectoryEntry parent) : base(releaseManifest.StringTable[descriptor.NameIndex]) { m_id = directoryId; m_releaseManifest = releaseManifest; m_descriptor = descriptor; m_parent = parent; if (m_parent != null) { m_parent.m_directories.Add(this); m_parent.AddChild(this); // TODO: Override to remove duplication } m_directories = new List <ReleaseManifestDirectoryEntry>((int)descriptor.SubdirectoryCount); m_files = new List <ReleaseManifestFileEntry>((int)descriptor.FileCount); this.Name = releaseManifest.StringTable[descriptor.NameIndex]; }