| 15 | static const char* NamedChunkedDataMagic = "NamedChunkedData"; |
| 16 | |
| 17 | TNamedChunkedDataReader::TNamedChunkedDataReader(const TBlob& blob) |
| 18 | : TChunkedDataReader(blob) |
| 19 | { |
| 20 | if (TChunkedDataReader::GetBlocksCount() < 1) |
| 21 | throw yexception() << "Too few blocks"; |
| 22 | |
| 23 | size_t block = TChunkedDataReader::GetBlocksCount() - 1; |
| 24 | size_t magicLen = strlen(NamedChunkedDataMagic); |
| 25 | if (GetBlockLen(block) < magicLen || memcmp(GetBlock(block), NamedChunkedDataMagic, magicLen) != 0) |
| 26 | throw yexception() << "Not a valid named chunked data file"; |
| 27 | |
| 28 | TMemoryInput input(static_cast<const char*>(GetBlock(block)) + magicLen, GetBlockLen(block) - magicLen); |
| 29 | Load(&input, Names); |
| 30 | |
| 31 | size_t index = 0; |
| 32 | for (TVector<TString>::const_iterator it = Names.begin(); it != Names.end(); ++it, ++index) { |
| 33 | if (!it->empty()) |
| 34 | NameToIndex[*it] = index; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | /*************************** TNamedChunkedDataWriter ***************************/ |
| 39 | |