public static async Task <DirectoryMetadata> Load(IBinaryDataAccessor data, IvfcLevelHeader header, int offsetOffDirTable) { var offset = header.DirectoryMetadataTableOffset + offsetOffDirTable; var metadata = new DirectoryMetadata(data, header); metadata.ParentDirectoryOffset = await data.ReadInt32Async(offset + 0); metadata.SiblingDirectoryOffset = await data.ReadInt32Async(offset + 4); metadata.FirstChildDirectoryOffset = await data.ReadInt32Async(offset + 8); metadata.FirstFileOffset = await data.ReadInt32Async(offset + 0xC); metadata.NextDirectoryOffset = await data.ReadInt32Async(offset + 0x10); metadata.NameLength = await data.ReadInt32Async(offset + 0x14); if (metadata.NameLength > 0) { metadata.Name = Encoding.Unicode.GetString(await data.ReadArrayAsync(offset + 0x18, Math.Min(metadata.NameLength, MaxFilenameLength))); } await Task.WhenAll( metadata.LoadChildDirectories(), metadata.LoadChildFiles() ); return(metadata); }
public static async Task <FileMetadata> Load(IBinaryDataAccessor data, IvfcLevelHeader header, long offsetFromMetadataTable) { var offset = header.FileMetadataTableOffset + offsetFromMetadataTable; var metadata = new FileMetadata(data, header); metadata.ContainingDirectoryOffset = await data.ReadInt32Async(offset + 0); metadata.NextSiblingFileOffset = await data.ReadInt32Async(offset + 4); metadata.FileDataOffset = await data.ReadInt64Async(offset + 8); metadata.FileDataLength = await data.ReadInt64Async(offset + 0x10); metadata.NextFileOffset = await data.ReadInt32Async(offset + 0x18); metadata.NameLength = await data.ReadInt32Async(offset + 0x1C); if (metadata.NameLength > 0) { metadata.Name = Encoding.Unicode.GetString(await data.ReadArrayAsync(offset + 0x20, Math.Min(metadata.NameLength, MaxFilenameLength))); } return(metadata); }