Function GetProperty

Synopsis

#include <include/streamupdatecallback.hpp>

STDMETHOD() GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)

Description

IArchiveUpdateCallback2.

Source

Lines 47-88 in src/streamupdatecallback.cpp. Line 43 in include/streamupdatecallback.hpp.

HRESULT StreamUpdateCallback::GetProperty( UInt32 index, PROPID propID, PROPVARIANT* value ) {
    BitPropVariant prop;

    if ( propID == kpidIsAnti ) {
        prop = false;
    } else if ( index < mOldArcItemsCount ) {
        prop = mOldArc->getItemProperty( index, static_cast< BitProperty >( propID ) );
    } else {
        switch ( propID ) {
            case kpidPath:
                prop = ( mStreamName.empty() ) ? kEmptyFileAlias : mStreamName;
                break;
            case kpidIsDir:
                prop = false;
                break;
            case kpidSize: {
                auto original_pos = mStream.tellg();
                mStream.seekg( 0, std::ios::end ); // seeking to the end of the stream
                prop = static_cast< uint64_t >( mStream.tellg() - original_pos ); // size of the stream
                mStream.seekg( original_pos ); // seeking back to the original position in the stream
                break;
            }
            case kpidAttrib:
                prop = static_cast< uint32_t >( FILE_ATTRIBUTE_NORMAL );
                break;
            case kpidCTime:
            case kpidATime:
            case kpidMTime: {
                FILETIME ft;
                SYSTEMTIME st;

                GetSystemTime( &st ); // gets current time
                SystemTimeToFileTime( &st, &ft ); // converts to file time format
                prop = ft;
                break;
            }
        }
    }

    *value = prop;
    return S_OK;
}





Add Discussion as Guest

Log in