Function GetStream

Synopsis

#include <include/opencallback.hpp>

STDMETHOD() GetStream(const wchar_t *name, IInStream **inStream)

Description

No description yet.

Source

Lines 88-115 in src/opencallback.cpp. Line 53 in include/opencallback.hpp.

STDMETHODIMP OpenCallback::GetStream( const wchar_t* name, IInStream** inStream ) {
    try {
        *inStream = nullptr;
        if ( mSubArchiveMode ) {
            return S_FALSE;
        }
        if ( mFileItem.isDir() ) {
            return S_FALSE;
        }
        wstring stream_path = mFileItem.path();
        if ( name != nullptr ) {
            stream_path = fsutil::dirname( stream_path ) + WCHAR_PATH_SEPARATOR + name;
            if ( !fsutil::pathExists( stream_path ) || fsutil::isDirectory( stream_path ) ) {
                return S_FALSE;
            }
        }
        auto* inFile = new CInFileStream;
        CMyComPtr< IInStream > inStreamTemp = inFile;
        if ( !inFile->Open( stream_path.c_str() ) ) {
            DWORD last_error = ::GetLastError();
            return ( last_error == 0 ) ? E_FAIL : HRESULT_FROM_WIN32( last_error );
        }
        *inStream = inStreamTemp.Detach();
        return S_OK;
    } catch ( ... ) {
        return E_OUTOFMEMORY;
    }
}





Add Discussion as Guest

Log in