void CInArchive::ReadDir(CDir &d, int level) { if (!d.IsDir()) return; SeekToBlock(d.ExtentLocation); UInt64 startPos = _position; bool firstItem = true; for (;;) { UInt64 offset = _position - startPos; if (offset >= d.DataLength) break; Byte len = ReadByte(); if (len == 0) continue; CDir subItem; ReadDirRecord2(subItem, len); if (firstItem && level == 0) IsSusp = subItem.CheckSusp(SuspSkipSize); if (!subItem.IsSystemItem()) d._subItems.Add(subItem); firstItem = false; } for (int i = 0; i < d._subItems.Size(); i++) ReadDir(d._subItems[i], level + 1); }
void CInArchive::ReadBootInfo() { if (!_bootIsDefined) return; if (memcmp(_bootDesc.BootSystemId, kElToritoSpec, sizeof(_bootDesc.BootSystemId)) != 0) return; const Byte *p = (const Byte *)_bootDesc.BootSystemUse; UInt32 blockIndex = p[0] | ((UInt32)p[1] << 8) | ((UInt32)p[2] << 16) | ((UInt32)p[3] << 24); SeekToBlock(blockIndex); Byte b = ReadByte(); if (b != NBootEntryId::kValidationEntry) return; { CBootValidationEntry e; e.PlatformId = ReadByte(); if (ReadUInt16Spec() != 0) throw 1; ReadBytes(e.Id, sizeof(e.Id)); /* UInt16 checkSum = */ ReadUInt16Spec(); if (ReadByte() != 0x55) throw 1; if (ReadByte() != 0xAA) throw 1; } b = ReadByte(); if (b == NBootEntryId::kInitialEntryBootable || b == NBootEntryId::kInitialEntryNotBootable) { CBootInitialEntry e; e.Bootable = (b == NBootEntryId::kInitialEntryBootable); e.BootMediaType = ReadByte(); e.LoadSegment = ReadUInt16Spec(); e.SystemType = ReadByte(); if (ReadByte() != 0) throw 1; e.SectorCount = ReadUInt16Spec(); e.LoadRBA = ReadUInt32Le(); if (ReadByte() != 0) throw 1; BootEntries.Add(e); } else return; }
void CIszImageStream::SyncCache() { uint64 currentSector = (m_position / m_header.sectorSize); uint64 neededBlock = (currentSector * m_header.sectorSize) / m_header.blockSize; if(neededBlock == m_cachedBlockNumber) { return; } if(neededBlock >= m_header.blockNumber) { throw std::runtime_error("Trying to read past eof."); } const BLOCKDESCRIPTOR& blockDescriptor = SeekToBlock(neededBlock); memset(m_cachedBlock, 0, m_header.blockSize); switch(blockDescriptor.storageType) { case ADI_ZERO: ReadZeroBlock(blockDescriptor.size); break; case ADI_DATA: ReadDataBlock(blockDescriptor.size); break; case ADI_ZLIB: ReadGzipBlock(blockDescriptor.size); break; #ifdef HAVE_BZIP case ADI_BZ2: ReadBz2Block(blockDescriptor.size); break; #endif default: throw std::runtime_error("Unsupported block storage mode."); break; } m_cachedBlockNumber = neededBlock; }