Ejemplo n.º 1
0
        public byte[] Extract(Stream stream, XboxIsoFileEntry entry)
        {
            stream.Position = entry.StartSector * 0x800L;
            var reader = new BinaryReader(stream);

            return(reader.ReadBytes(entry.FileSize));
        }
Ejemplo n.º 2
0
        private IEnumerable <XboxIsoFileEntry> ReadDirectory(BinaryReader reader, string path, long basePosition)
        {
            var binaryTableLeft  = reader.ReadInt16() * 4;
            var binaryTableRight = reader.ReadInt16() * 4;

            var entry = new XboxIsoFileEntry
            {
                StartSector = reader.ReadInt32(),
                FileSize    = reader.ReadInt32(),
                Attributes  = (XboxIsoFileAttributes)reader.ReadByte()
            };

            var nameLength = reader.ReadByte();

            entry.FileName = $"{path}{Encodings.UTF8.GetString(reader.ReadBytes(nameLength))}";

            if (!entry.Attributes.HasFlag(XboxIsoFileAttributes.Directory))
            {
                yield return(entry);
            }

            if (binaryTableLeft > 0)
            {
                reader.BaseStream.Position = basePosition + binaryTableLeft;
                foreach (var e in ReadDirectory(reader, path, basePosition))
                {
                    yield return(e);
                }
            }

            if (binaryTableRight > 0)
            {
                reader.BaseStream.Position = basePosition + binaryTableRight;
                foreach (var e in ReadDirectory(reader, path, basePosition))
                {
                    yield return(e);
                }
            }

            if (entry.Attributes.HasFlag(XboxIsoFileAttributes.Directory))
            {
                var newBase = entry.StartSector * 0x800L;
                reader.BaseStream.Position = newBase;
                foreach (var e in ReadDirectory(reader, $"{entry.FileName}/", newBase))
                {
                    yield return(e);
                }
            }
        }