Пример #1
0
RPFToc* RPFTOCRead(const char* pszFilename, NITFFile* psFile)
{
    int TRESize;
    const char* pachTRE = NITFFindTRE( psFile->pachTRE, psFile->nTREBytes, 
                           "RPFHDR", &TRESize );
    if (pachTRE == NULL)
    {
        CPLError( CE_Failure, CPLE_NotSupported, 
                  "Invalid TOC file. Can't find RPFHDR." );
        return NULL;
    }

    if (TRESize < 48)
    {
        CPLError( CE_Failure, CPLE_NotSupported, 
                  "Not enough bytes in RPFHDR." );
        return NULL;
    }

    int nRemainingBytes = psFile->nTREBytes - (pachTRE - psFile->pachTRE);
    if (nRemainingBytes < 48)
    {
        CPLError(CE_Failure, CPLE_AppDefined,
                "Cannot read RPFHDR TRE. Not enough bytes");
        return NULL;
    }

    return  RPFTOCReadFromBuffer(pszFilename, psFile->fp, pachTRE);
}
Пример #2
0
RPFToc* RPFTOCRead(const char* pszFilename, NITFFile* psFile)
{
    int nTRESize;
    const char* pachTRE = NITFFindTRE( psFile->pachTRE, psFile->nTREBytes,
                           "RPFHDR", &nTRESize );
    if (pachTRE == nullptr)
    {
        CPLError( CE_Failure, CPLE_NotSupported,
                  "Invalid TOC file. Can't find RPFHDR." );
        return nullptr;
    }

    if (nTRESize != 48)
    {
        CPLError( CE_Failure, CPLE_NotSupported,
                  "RPFHDR TRE wrong size." );
        return nullptr;
    }

    return  RPFTOCReadFromBuffer(pszFilename, psFile->fp, pachTRE);
}