Function Seek

Synopsis

#include <include/cstdoutstream.hpp>

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

Description

No description yet.

Source

Lines 52-83 in src/cstdoutstream.cpp. Line 23 in include/cstdoutstream.hpp.

STDMETHODIMP CStdOutStream::Seek( int64_t offset, uint32_t seekOrigin, uint64_t* newPosition ) {
    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 ) { //Tar sometimes uses negative offsets
        return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
    }*/

    mOutputStream.seekp( static_cast< std::ostream::off_type >( offset ), way );

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

    if ( newPosition ) {
        *newPosition = mOutputStream.tellp();
    }

    return S_OK;
}





Add Discussion as Guest

Log in