| 2640 | } |
| 2641 | |
| 2642 | void StreamIndexedIO::Index::readNodeFromSubIndex( DirectoryNode *n ) |
| 2643 | { |
| 2644 | /// guarantees thread safe access to the file and also to the m_subindex variable |
| 2645 | StreamFile::MutexLock lock( m_stream->mutex() ); |
| 2646 | |
| 2647 | if ( n->subindex() == DirectoryNode::LoadedSubIndex ) |
| 2648 | { |
| 2649 | return; |
| 2650 | } |
| 2651 | |
| 2652 | m_stream->seekg( n->offset(), std::ios::beg ); |
| 2653 | |
| 2654 | uint32_t subindexSize = 0; |
| 2655 | readLittleEndian( *m_stream, subindexSize ); |
| 2656 | |
| 2657 | char *data = m_stream->ioBuffer(subindexSize); |
| 2658 | m_stream->read( data, subindexSize ); |
| 2659 | |
| 2660 | io::filtering_istream indexInStream; |
| 2661 | |
| 2662 | if (m_version >= 7) |
| 2663 | { |
| 2664 | std::vector<char> decompressedIndex; |
| 2665 | decompress( data, subindexSize, decompressedIndex, 1 ); |
| 2666 | |
| 2667 | MemoryStreamSource source( &decompressedIndex[0], decompressedIndex.size(), false ); |
| 2668 | indexInStream.push( source ); |
| 2669 | assert( indexInStream.is_complete() ); |
| 2670 | |
| 2671 | uint32_t nodeCount = 0; |
| 2672 | |
| 2673 | readLittleEndian( indexInStream, nodeCount ); |
| 2674 | |
| 2675 | for( uint32_t i = 0; i < nodeCount; i++ ) |
| 2676 | { |
| 2677 | NodeBase *child = m_version >= 6 ? readNode( indexInStream ) : readNodeV5( indexInStream ); |
| 2678 | n->registerChild( child ); |
| 2679 | } |
| 2680 | } |
| 2681 | else |
| 2682 | { |
| 2683 | MemoryStreamSource source( data, subindexSize, false ); |
| 2684 | |
| 2685 | indexInStream.push( io::gzip_decompressor() ); |
| 2686 | indexInStream.push( source ); |
| 2687 | assert( indexInStream.is_complete() ); |
| 2688 | |
| 2689 | uint32_t nodeCount = 0; |
| 2690 | |
| 2691 | readLittleEndian( indexInStream, nodeCount ); |
| 2692 | |
| 2693 | for( uint32_t i = 0; i < nodeCount; i++ ) |
| 2694 | { |
| 2695 | NodeBase *child = m_version >= 6 ? readNode( indexInStream ) : readNodeV5( indexInStream ); |
| 2696 | n->registerChild( child ); |
| 2697 | } |
| 2698 | } |
| 2699 |
no test coverage detected