internal static long LoadOffset(BinaryReader reader, NintendoOpticalDiscSystem system) { switch (system) { case NintendoOpticalDiscSystem.Wii: return(reader.ReadUInt32() * 4L); case NintendoOpticalDiscSystem.GameCube: return(reader.ReadUInt32()); default: throw new NotImplementedException(); } }
internal static void LoadFileTable(FolderAsset parent, BinaryReader reader, NintendoOpticalDiscSystem system) { reader.BaseStream.Position = 0x424; long fileTableOffset = LoadOffset(reader, system); reader.BaseStream.Position = fileTableOffset + 8; int count = reader.ReadInt32(); for (int index = 1; index < count;) { LoadFile(parent, reader, ref index, system); } foreach (Asset asset in parent.Children) { LoadFileName(asset, reader, fileTableOffset + count * 12); } }
internal NintendoOpticalDiscPartitionFile(FolderAsset parent, int index, int nameOffset, BinaryReader reader, NintendoOpticalDiscSystem system) : base(parent, "") { Index = index; NameOffset = nameOffset; DataOffset = NintendoOpticalDiscPartition.LoadOffset(reader, system); Size = reader.ReadUInt32(); }
internal NintendoOpticalDiscPartitionFolder(FolderAsset parent, ref int index, int nameOffset, BinaryReader reader, NintendoOpticalDiscSystem system) : base(parent, "") { Index = index; NameOffset = nameOffset; int firstIndex = reader.ReadInt32(); /*if (firstIndex != index + 1) * throw new InvalidDataException();*/ int endIndex = reader.ReadInt32(); index++; while (index < endIndex) { NintendoOpticalDiscPartition.LoadFile(this, reader, ref index, system); } }
internal static Asset LoadFile(FolderAsset parent, BinaryReader reader, ref int index, NintendoOpticalDiscSystem system) { int nameOffset = reader.ReadInt32(); bool isDirectory = (nameOffset & 0xFF000000) != 0; nameOffset &= 0xFFFFFF; if (isDirectory) { return(new NintendoOpticalDiscPartitionFolder(parent, ref index, nameOffset, reader, system)); } else { return(new NintendoOpticalDiscPartitionFile(parent, index++, nameOffset, reader, system)); } }
internal NintendoOpticalDiscPartitionFolder(FolderAsset parent, ref int index, int nameOffset, BinaryReader reader, NintendoOpticalDiscSystem system) : base(parent, "") { Index = index; NameOffset = nameOffset; int firstIndex = reader.ReadInt32(); /*if (firstIndex != index + 1) throw new InvalidDataException();*/ int endIndex = reader.ReadInt32(); index++; while (index < endIndex) NintendoOpticalDiscPartition.LoadFile(this, reader, ref index, system); }
internal static long LoadOffset(BinaryReader reader, NintendoOpticalDiscSystem system) { switch (system) { case NintendoOpticalDiscSystem.Wii: return reader.ReadUInt32() * 4L; case NintendoOpticalDiscSystem.GameCube: return reader.ReadUInt32(); default: throw new NotImplementedException(); } }
internal static void LoadFileTable(FolderAsset parent, BinaryReader reader, NintendoOpticalDiscSystem system) { reader.BaseStream.Position = 0x424; long fileTableOffset = LoadOffset(reader, system); reader.BaseStream.Position = fileTableOffset + 8; int count = reader.ReadInt32(); for (int index = 1; index < count; ) LoadFile(parent, reader, ref index, system); foreach (Asset asset in parent.Children) LoadFileName(asset, reader, fileTableOffset + count * 12); }
internal static Asset LoadFile(FolderAsset parent, BinaryReader reader, ref int index, NintendoOpticalDiscSystem system) { int nameOffset = reader.ReadInt32(); bool isDirectory = (nameOffset & 0xFF000000) != 0; nameOffset &= 0xFFFFFF; if (isDirectory) return new NintendoOpticalDiscPartitionFolder(parent, ref index, nameOffset, reader, system); else return new NintendoOpticalDiscPartitionFile(parent, index++, nameOffset, reader, system); }