Exemplo n.º 1
0
        private void InternalRead(BinaryReader reader)
        {
            long posStart  = reader.GetPosition();
            byte length    = reader.ReadByte();
            byte extLength = reader.ReadByte();

            mLba = reader.ReadInt32();
            reader.Seek(0x04, SeekOrigin.Current); // LBA_BE

            mSize = reader.ReadInt32();
            reader.Seek(0x04 + 0x07, SeekOrigin.Current); // size_BE + datetime

            mFlags = reader.ReadByte();
            reader.Seek(0x06, SeekOrigin.Current); // unit size + interleave gap + volume seq number

            byte nameLength = reader.ReadByte();

            byte[] nameBytes = reader.ReadBytes(nameLength);

            if (nameBytes.Length == 1)
            {
                if (nameBytes[0] == 0)
                {
                    mName = ".";
                }
                else if (nameBytes[0] == 1)
                {
                    mName = "..";
                }
            }
            else
            {
                mName = Encoding.ASCII.GetString(nameBytes).Split(';')[0];
            }

            bool isDirectory = (mFlags & (int)RecordFlags.DirectoryRecord) == (int)RecordFlags.DirectoryRecord;
            bool isNotParentOrGrandparentDirectory = nameLength != 1 || mParent == null;

            if (isDirectory && isNotParentOrGrandparentDirectory)
            {
                reader.Seek(CvmFile.CVM_HEADER_SIZE + ((long)mLba * CvmFile.ISO_BLOCKSIZE), SeekOrigin.Begin);
                mSubEntries = new List <IsoDirectoryRecord>();

                // Set the initial sector start position
                long posSubEntriesSectorStart = reader.BaseStream.Position;
                long posSubEntriesDataEnd     = posSubEntriesSectorStart + mSize;

                while (reader.BaseStream.Position < posSubEntriesDataEnd)
                {
                    IsoDirectoryRecord record = new IsoDirectoryRecord(reader, this);

                    mSubEntries.Add(record);

                    // Skip padding
                    while (reader.ReadByte() == 0 && reader.BaseStream.Position < posSubEntriesDataEnd)
                    {
                        ;
                    }

                    // Break out of the loop if we've read to or past the end position
                    if (reader.BaseStream.Position >= posSubEntriesDataEnd)
                    {
                        break;
                    }

                    // We've found a non-zero byte, seek back
                    reader.BaseStream.Position -= 1;
                }
            }

            reader.Seek(posStart + length + extLength, SeekOrigin.Begin);
        }
Exemplo n.º 2
0
 internal IsoDirectoryRecord(BinaryReader reader, IsoDirectoryRecord parent)
 {
     mParent = parent;
     InternalRead(reader);
 }