示例#1
0
文件: zxzip.cpp 项目: kacmem/zxtune
Archived::Container::Ptr ParseArchive(const Packed::Decoder& decoder, const Binary::Container& data)
{
    const TRDos::CatalogueBuilder::Ptr builder = TRDos::CatalogueBuilder::CreateGeneric();
    const std::size_t archSize = data.Size();
    std::size_t rawOffset = 0;
    for (std::size_t flatOffset = 0; rawOffset < archSize;)
    {
        const Binary::Container::Ptr rawData = data.GetSubcontainer(rawOffset, archSize - rawOffset);
        const Formats::Packed::Container::Ptr fileData = decoder.Decode(*rawData);
        if (!fileData)
        {
            break;
        }
        const String fileName = ExtractFileName(rawData->Start());
        const std::size_t fileSize = fileData->Size();
        const std::size_t usedSize = fileData->PackedSize();
        const TRDos::File::Ptr file = TRDos::File::Create(fileData, fileName, flatOffset, fileSize);
        builder->AddFile(file);
        rawOffset += usedSize;
        flatOffset += fileSize;
    }
    if (rawOffset)
    {
        builder->SetRawData(data.GetSubcontainer(0, rawOffset));
        return builder->GetResult();
    }
    else
    {
        return Archived::Container::Ptr();
    }
}
示例#2
0
 ScanDataContainer(Binary::Container::Ptr delegate, std::size_t offset)
   : Delegate(delegate)
   , OriginalSize(delegate->Size())
   , OriginalData(static_cast<const uint8_t*>(delegate->Start()))
   , Offset(offset)
 {
 }