Пример #1
0
OGRDataSource *OGRGeoconceptDriver::CreateDataSource( const char* pszName,
                                                      char** papszOptions )

{
    VSIStatBufL  sStat;
    /* int bSingleNewFile = FALSE; */

    if( pszName==nullptr || strlen(pszName)==0 )
    {
        CPLError( CE_Failure, CPLE_AppDefined,
                  "Invalid datasource name (null or empty)");
        return nullptr;
    }

/* -------------------------------------------------------------------- */
/*      Is the target a valid existing directory?                       */
/* -------------------------------------------------------------------- */
    if( VSIStatL( pszName, &sStat ) == 0 )
    {
        if( !VSI_ISDIR(sStat.st_mode) )
        {
            CPLError( CE_Failure, CPLE_AppDefined,
                      "%s is not a valid existing directory.",
                      pszName );
            return nullptr;
        }
    }

/* -------------------------------------------------------------------- */
/*      Does it end with the extension .gxt indicating the user likely  */
/*      wants to create a single file set?                              */
/* -------------------------------------------------------------------- */
    else if(
             EQUAL(CPLGetExtension(pszName),"gxt")  ||
             EQUAL(CPLGetExtension(pszName),"txt")
           )
    {
        /* bSingleNewFile = TRUE; */
    }

/* -------------------------------------------------------------------- */
/*      Return a new OGRDataSource()                                    */
/* -------------------------------------------------------------------- */
    OGRGeoconceptDataSource  *poDS = new OGRGeoconceptDataSource();
    if( !poDS->Create( pszName, papszOptions ) )
    {
        delete poDS;
        return nullptr;
    }
    return poDS;
}
Пример #2
0
OGRDataSource *OGRGeoconceptDriver::Open( const char* pszFilename,
                                          int bUpdate )

{
    OGRGeoconceptDataSource  *poDS;

/* -------------------------------------------------------------------- */
/*      We will only consider .gxt and .txt files.                      */
/* -------------------------------------------------------------------- */
    const char* pszExtension = CPLGetExtension(pszFilename);
    if( !EQUAL(pszExtension,"gxt") && !EQUAL(pszExtension,"txt") )
    {
        return NULL;
    }

    poDS = new OGRGeoconceptDataSource();

    if( !poDS->Open( pszFilename, TRUE, bUpdate ) )
    {
        delete poDS;
        return NULL;
    }
    return poDS;
}
Пример #3
0
OGRDataSource *OGRGeoconceptDriver::Open( const char* pszFilename,
                                          int bUpdate )

{
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/* -------------------------------------------------------------------- */
/*      We will only consider .gxt and .txt files.                      */
/* -------------------------------------------------------------------- */
    const char* pszExtension = CPLGetExtension(pszFilename);
    if( !EQUAL(pszExtension,"gxt") && !EQUAL(pszExtension,"txt") )
    {
        return nullptr;
    }
#endif

    OGRGeoconceptDataSource  *poDS = new OGRGeoconceptDataSource();

    if( !poDS->Open( pszFilename, true, CPL_TO_BOOL(bUpdate) ) )
    {
        delete poDS;
        return nullptr;
    }
    return poDS;
}