Function Seek

Synopsis

#include <include/cstdinstream.hpp>

STDMETHOD() Seek(int64_t offset, uint32_t seekOrigin, uint64_t *newPosition)

Description

No description yet.

Source

Lines 50-83 in src/cstdinstream.cpp. Line 41 in include/cstdinstream.hpp.

STDMETHODIMP CStdInStream::Seek( int64_t offset, uint32_t seekOrigin, uint64_t* newPosition ) {
    mInputStream.clear();

    std::ios_base::seekdir way;
    switch ( seekOrigin ) {
        case STREAM_SEEK_SET:
            way = std::ios_base::beg;
            break;
        case STREAM_SEEK_CUR:
            way = std::ios_base::cur;
            break;
        case STREAM_SEEK_END:
            way = std::ios_base::end;
            break;
        default:
            return STG_E_INVALIDFUNCTION;
    }

    /*if ( offset < 0 ) { // GZip uses negative offsets!
        return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
    }*/

    mInputStream.seekg( static_cast< std::istream::off_type >( offset ), way );

    if ( mInputStream.bad() ) {
        return HRESULT_FROM_WIN32( ERROR_SEEK );
    }

    if ( newPosition ) {
        *newPosition = mInputStream.tellg();
    }

    return S_OK;
}





Add Discussion as Guest

Log in