Exemple #1
0
CNcbiIstream*
CLDS2_UrlHandler_GZipFile::OpenStream(const SLDS2_File& file_info,
                                      Int8              stream_pos,
                                      CLDS2_Database*   db)
{
    auto_ptr<CNcbiIfstream> in(
        new CNcbiIfstream(file_info.name.c_str(), ios::binary));
    if ( !in->is_open() ) {
        return NULL;
    }
    if ( db ) {
        // Try to use chunks information to optimize loading
        SLDS2_Chunk chunk;
        if ( db->FindChunk(file_info, chunk, stream_pos) ) {
            if (chunk.raw_pos > 0) {
                in->seekg(NcbiInt8ToStreampos(chunk.raw_pos));
            }
            stream_pos -= chunk.stream_pos;
        }
    }
    auto_ptr<CCompressionIStream> zin(
        new CCompressionIStream(
        *in.release(),
        new CZipStreamDecompressor(CZipCompression::fGZip),
        CCompressionStream::fOwnAll));
    zin->ignore(NcbiInt8ToStreampos(stream_pos));
    return zin.release();
}
Exemple #2
0
CNcbiIstream*
CLDS2_UrlHandler_File::OpenStream(const SLDS2_File& file_info,
                                  Int8              stream_pos,
                                  CLDS2_Database*   /*db*/)
{
    auto_ptr<CNcbiIfstream> in(
        new CNcbiIfstream(file_info.name.c_str(), ios::binary));
    // Chunks are not supported for regular files,
    /// offset is relative to the file start.
    if (stream_pos > 0) {
        in->seekg(NcbiInt8ToStreampos(stream_pos));
    }
    return in.release();
}
Exemple #3
0
CT_POS_TYPE CMemoryLineReader::GetPosition(void) const
{
    return NcbiInt8ToStreampos(m_Pos - m_Start);
}