本文整理汇总了C++中VSIUnlink函数的典型用法代码示例。如果您正苦于以下问题:C++ VSIUnlink函数的具体用法?C++ VSIUnlink怎么用?C++ VSIUnlink使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VSIUnlink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPLFree
OGRGPSBabelDataSource::~OGRGPSBabelDataSource()
{
CPLFree(pszName);
CPLFree(pszGPSBabelDriverName);
CPLFree(pszFilename);
CloseDependentDatasets();
if (osTmpFileName.size() > 0)
VSIUnlink(osTmpFileName.c_str());
}
示例2: CPLUnlockFile
void CPLUnlockFile( void *hLock )
{
char *pszLockFilename = (char *) hLock;
if( hLock == NULL )
return;
VSIUnlink( pszLockFilename );
CPLFree( pszLockFilename );
}
示例3: Finalize
OGRSQLiteExecuteSQLLayer::~OGRSQLiteExecuteSQLLayer()
{
/* This is a bit peculiar: we must "finalize" the OGRLayer, since */
/* it has objects that depend on the datasource, that we are just */
/* going to destroy afterwards. The issue here is that we destroy */
/* our own datasource ! */
Finalize();
delete poDS;
VSIUnlink(pszTmpDBName);
CPLFree(pszTmpDBName);
}
示例4: QString
QgsFields QgsOgrUtils::stringToFields( const QString& string, QTextCodec* encoding )
{
QgsFields fields;
if ( string.isEmpty() )
return fields;
QString randomFileName = QString( "/vsimem/%1" ).arg( QUuid::createUuid().toString() );
// create memory file system object from buffer
QByteArray ba = string.toUtf8();
VSIFCloseL( VSIFileFromMemBuffer( TO8( randomFileName ), reinterpret_cast< GByte* >( ba.data() ),
static_cast< vsi_l_offset >( ba.size() ), FALSE ) );
OGRDataSourceH hDS = OGROpen( TO8( randomFileName ), false, nullptr );
if ( !hDS )
{
VSIUnlink( TO8( randomFileName ) );
return fields;
}
OGRLayerH ogrLayer = OGR_DS_GetLayer( hDS, 0 );
if ( !ogrLayer )
{
OGR_DS_Destroy( hDS );
VSIUnlink( TO8( randomFileName ) );
return fields;
}
OGRFeatureH oFeat;
//read in the first feature only
if (( oFeat = OGR_L_GetNextFeature( ogrLayer ) ) )
{
fields = readOgrFields( oFeat, encoding );
OGR_F_Destroy( oFeat );
}
OGR_DS_Destroy( hDS );
VSIUnlink( TO8( randomFileName ) );
return fields;
}
示例5: CompressTIF
//
// Uses GDAL to create a temporary TIF file, using the band create options
// copies the content to the destination buffer then erases the temp TIF
//
CPLErr CompressTIF(buf_mgr &dst, buf_mgr &src, const ILImage &img, char **papszOptions)
{
CPLErr ret;
GDALDriver *poTiffDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
VSIStatBufL statb;
CPLString fname = uniq_memfname("mrf_tif_write");
GDALDataset *poTiff = poTiffDriver->Create(fname, img.pagesize.x, img.pagesize.y,
img.pagesize.c, img.dt, papszOptions );
// Read directly to avoid double caching in GDAL
// Unfortunately not possible for multiple bands
if (img.pagesize.c == 1) {
ret = poTiff->GetRasterBand(1)->WriteBlock(0,0,src.buffer);
} else {
ret = poTiff->RasterIO(GF_Write, 0,0,img.pagesize.x,img.pagesize.y,
src.buffer, img.pagesize.x, img.pagesize.y, img.dt, img.pagesize.c,
NULL, 0,0,0);
}
if (CE_None != ret) return ret;
GDALClose(poTiff);
// Check that we can read the file
if (VSIStatL(fname, &statb))
{
CPLError(CE_Failure,CPLE_AppDefined,
CPLString().Printf("MRF: TIFF, can't stat %s", fname.c_str()));
return CE_Failure;
}
if (statb.st_size > dst.size)
{
CPLError(CE_Failure,CPLE_AppDefined,
CPLString().Printf("MRF: TIFF, Tiff generated is too large"));
return CE_Failure;
}
VSILFILE *pf = VSIFOpenL(fname,"rb");
if (pf == NULL)
{
CPLError(CE_Failure,CPLE_AppDefined,
CPLString().Printf("MRF: TIFF, can't open %s", fname.c_str()));
return CE_Failure;
}
VSIFReadL(dst.buffer, statb.st_size, 1, pf);
dst.size = statb.st_size;
VSIFCloseL(pf);
VSIUnlink(fname);
return CE_None;
}
示例6: QStringLiteral
QgsFields QgsOgrUtils::stringToFields( const QString &string, QTextCodec *encoding )
{
QgsFields fields;
if ( string.isEmpty() )
return fields;
QString randomFileName = QStringLiteral( "/vsimem/%1" ).arg( QUuid::createUuid().toString() );
// create memory file system object from buffer
QByteArray ba = string.toUtf8();
VSIFCloseL( VSIFileFromMemBuffer( randomFileName.toUtf8().constData(), reinterpret_cast< GByte * >( ba.data() ),
static_cast< vsi_l_offset >( ba.size() ), FALSE ) );
gdal::ogr_datasource_unique_ptr hDS( OGROpen( randomFileName.toUtf8().constData(), false, nullptr ) );
if ( !hDS )
{
VSIUnlink( randomFileName.toUtf8().constData() );
return fields;
}
OGRLayerH ogrLayer = OGR_DS_GetLayer( hDS.get(), 0 );
if ( !ogrLayer )
{
hDS.reset();
VSIUnlink( randomFileName.toUtf8().constData() );
return fields;
}
gdal::ogr_feature_unique_ptr oFeat;
//read in the first feature only
if ( oFeat.reset( OGR_L_GetNextFeature( ogrLayer ) ), oFeat )
{
fields = readOgrFields( oFeat.get(), encoding );
}
hDS.reset();
VSIUnlink( randomFileName.toUtf8().constData() );
return fields;
}
示例7: CPLFree
OGRGPSBabelDataSource::~OGRGPSBabelDataSource()
{
CPLFree(pszName);
CPLFree(pszGPSBabelDriverName);
CPLFree(pszFilename);
if (poGPXDS)
OGRDataSource::DestroyDataSource(poGPXDS);
if (osTmpFileName.size() > 0)
VSIUnlink(osTmpFileName.c_str());
}
示例8: CPLError
OGRErr OGRMILayerAttrIndex::DropIndex( int iField )
{
/* -------------------------------------------------------------------- */
/* Do we have this field indexed already? */
/* -------------------------------------------------------------------- */
OGRFieldDefn *poFldDefn=poLayer->GetLayerDefn()->GetFieldDefn(iField);
int i = 0;
for( ; i < nIndexCount; i++ )
{
if( papoIndexList[i]->iField == iField )
break;
}
if( i == nIndexCount )
{
CPLError( CE_Failure, CPLE_AppDefined,
"DROP INDEX on field (%s) that doesn't have an index.",
poFldDefn->GetNameRef() );
return OGRERR_FAILURE;
}
/* -------------------------------------------------------------------- */
/* Remove from the list. */
/* -------------------------------------------------------------------- */
OGRMIAttrIndex *poAI = papoIndexList[i];
memmove( papoIndexList + i, papoIndexList + i + 1,
sizeof(void*) * (nIndexCount - i - 1) );
delete poAI;
nIndexCount--;
/* -------------------------------------------------------------------- */
/* Save the new configuration, or if there is nothing left try */
/* to clean up the index files. */
/* -------------------------------------------------------------------- */
if( nIndexCount > 0 )
return SaveConfigToXML();
else
{
bUnlinkINDFile = TRUE;
VSIUnlink( pszMetadataFilename );
return OGRERR_NONE;
}
}
示例9: VSIFOpenL
int OGRGPSBabelWriteDataSource::Convert()
{
int nRet = -1;
if (osTmpFileName.size() > 0 && pszFilename != NULL && pszGPSBabelDriverName != NULL)
{
if (OGRGPSBabelDataSource::IsSpecialFile(pszFilename))
{
/* Special file : don't try to open it */
const char* const argv[] = { "gpsbabel", "-i", "gpx", "-f", "-",
"-o", pszGPSBabelDriverName, "-F", pszFilename, NULL };
VSILFILE* tmpfp = VSIFOpenL(osTmpFileName.c_str(), "rb");
if (tmpfp)
{
nRet = CPLSpawn(argv, tmpfp, NULL, TRUE);
VSIFCloseL(tmpfp);
tmpfp = NULL;
}
}
else
{
VSILFILE* fp = VSIFOpenL(pszFilename, "wb");
if (fp == NULL)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Cannot open file %s", pszFilename);
}
else
{
const char* const argv[] = { "gpsbabel", "-i", "gpx", "-f", "-",
"-o", pszGPSBabelDriverName, "-F", "-", NULL };
VSILFILE* tmpfp = VSIFOpenL(osTmpFileName.c_str(), "rb");
if (tmpfp)
{
nRet = CPLSpawn(argv, tmpfp, fp, TRUE);
VSIFCloseL(tmpfp);
tmpfp = NULL;
}
VSIFCloseL(fp);
fp = NULL;
}
}
VSIUnlink(osTmpFileName.c_str());
osTmpFileName = "";
}
return nRet == 0;
}
示例10: PAuxDelete
CPLErr PAuxDelete( const char * pszBasename )
{
VSILFILE *fp;
const char *pszLine;
fp = VSIFOpenL( CPLResetExtension( pszBasename, "aux" ), "r" );
if( fp == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s does not appear to be a PAux dataset, there is no .aux file.",
pszBasename );
return CE_Failure;
}
pszLine = CPLReadLineL( fp );
VSIFCloseL( fp );
if( pszLine == NULL || !EQUALN(pszLine,"AuxilaryTarget",14) )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s does not appear to be a PAux dataset,\n"
"the .aux file does not start with AuxilaryTarget",
pszBasename );
return CE_Failure;
}
if( VSIUnlink( pszBasename ) != 0 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"OS unlinking file %s.", pszBasename );
return CE_Failure;
}
VSIUnlink( CPLResetExtension( pszBasename, "aux" ) );
return CE_None;
}
示例11: DTEDPtStreamTrimEdgeOnlyTiles
void DTEDPtStreamTrimEdgeOnlyTiles( void *hStream )
{
DTEDPtStream *psStream = (DTEDPtStream *) hStream;
int iFile;
for( iFile = psStream->nOpenFiles-1; iFile >= 0; iFile-- )
{
DTEDInfo *psInfo = psStream->pasCF[iFile].psInfo;
GInt16 **papanProfiles = psStream->pasCF[iFile].papanProfiles;
int iProfile, iPixel, bGotNonEdgeData = FALSE;
for( iProfile = 1; iProfile < psInfo->nXSize-1; iProfile++ )
{
if( papanProfiles[iProfile] == NULL )
continue;
for( iPixel = 1; iPixel < psInfo->nYSize-1; iPixel++ )
{
if( papanProfiles[iProfile][iPixel] != DTED_NODATA_VALUE )
{
bGotNonEdgeData = TRUE;
break;
}
}
}
if( bGotNonEdgeData )
continue;
/* Remove this tile */
for( iProfile = 0; iProfile < psInfo->nXSize; iProfile++ )
{
if( papanProfiles[iProfile] != NULL )
CPLFree( papanProfiles[iProfile] );
}
CPLFree( papanProfiles );
DTEDClose( psInfo );
VSIUnlink( psStream->pasCF[iFile].pszFilename );
CPLFree( psStream->pasCF[iFile].pszFilename );
memmove( psStream->pasCF + iFile,
psStream->pasCF + iFile + 1,
sizeof(DTEDCachedFile) * (psStream->nOpenFiles-iFile-1) );
psStream->nOpenFiles--;
}
}
示例12: PAuxDelete
static CPLErr PAuxDelete( const char * pszBasename )
{
VSILFILE *fp = VSIFOpenL( CPLResetExtension( pszBasename, "aux" ), "r" );
if( fp == nullptr )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s does not appear to be a PAux dataset: "
"there is no .aux file.",
pszBasename );
return CE_Failure;
}
const char *pszLine = CPLReadLineL( fp );
CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));
if( pszLine == nullptr || !STARTS_WITH_CI(pszLine, "AuxilaryTarget") )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s does not appear to be a PAux dataset:"
"the .aux file does not start with AuxilaryTarget",
pszBasename );
return CE_Failure;
}
if( VSIUnlink( pszBasename ) != 0 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"OS unlinking file %s.", pszBasename );
return CE_Failure;
}
VSIUnlink( CPLResetExtension( pszBasename, "aux" ) );
return CE_None;
}
示例13: VSIUnlink
~GdalTestData()
{
/* SrtmFetch may leave a file */
if( CPLCheckForFile( (char*) pszFilename.c_str(), NULL ) )
{
VSIUnlink( pszFilename.c_str() );
}
if( NULL != fetch )
{
delete fetch;
}
if( NULL != poDS )
{
GDALClose( (GDALDatasetH) poDS );
}
}
示例14: CleanVSIDir
void CleanVSIDir( const char *pszDir )
{
char **papszFiles = CPLReadDir( pszDir );
int i, nFileCount = CSLCount( papszFiles );
for( i = 0; i < nFileCount; i++ ) {
if( strcasecmp(papszFiles[i],".") == 0
|| strcasecmp(papszFiles[i],"..") == 0 )
continue;
VSIUnlink( papszFiles[i] );
}
CSLDestroy( papszFiles );
}
示例15: NomadsFetchVsi
static int NomadsFetchVsi( const char *pszUrl, const char *pszFilename )
{
int rc;
const char *pszVsiUrl;
VSILFILE *fin, *fout;
vsi_l_offset nOffset, nBytesWritten, nVsiBlockSize;
char *pabyBuffer;
nVsiBlockSize = atoi( CPLGetConfigOption( "NOMADS_VSI_BLOCK_SIZE", "512" ) );
if( !EQUALN( pszUrl, "/vsicurl/", 9 ) )
{
pszVsiUrl = CPLSPrintf( "/vsicurl/%s", pszUrl );
}
fin = VSIFOpenL( pszVsiUrl, "rb" );
if( !fin )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Failed to download file." );
return NOMADS_ERR;
}
fout = VSIFOpenL( pszFilename, "wb" );
if( !fout )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Failed to open file for writing." );
VSIFCloseL( fin );
return NOMADS_ERR;
}
nBytesWritten = 0;
pabyBuffer = CPLMalloc( sizeof( char ) * nVsiBlockSize );
rc = 0;
do
{
nOffset = VSIFReadL( pabyBuffer, 1, nVsiBlockSize, fin );
nBytesWritten += nOffset;
VSIFWriteL( pabyBuffer, 1, nOffset, fout );
} while ( nOffset != 0 );
VSIFCloseL( fin );
VSIFCloseL( fout );
if( nBytesWritten == 0 )
{
VSIUnlink( pszFilename );
rc = NOMADS_ERR;
}
CPLFree( (void*)pabyBuffer );
return rc;
}