本文整理汇总了C++中VSIStrerror函数的典型用法代码示例。如果您正苦于以下问题:C++ VSIStrerror函数的具体用法?C++ VSIStrerror怎么用?C++ VSIStrerror使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VSIStrerror函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tiffWriteProc
static tsize_t
_tiffWriteProc(thandle_t th, tdata_t buf, tsize_t size)
{
GDALTiffHandle* psGTH = (GDALTiffHandle*) th;
// If we have a write buffer and are at end of file, then accumulate
// the bytes until the buffer is full
if( psGTH->bAtEndOfFile && psGTH->abyWriteBuffer )
{
const GByte* pabyData = (const GByte*) buf;
tsize_t nRemainingBytes = size;
while( TRUE )
{
if( psGTH->nWriteBufferSize + nRemainingBytes <= BUFFER_SIZE )
{
memcpy( psGTH->abyWriteBuffer + psGTH->nWriteBufferSize,
pabyData, nRemainingBytes );
psGTH->nWriteBufferSize += nRemainingBytes;
psGTH->nExpectedPos += size;
return size;
}
int nAppendable = BUFFER_SIZE - psGTH->nWriteBufferSize;
memcpy( psGTH->abyWriteBuffer + psGTH->nWriteBufferSize, pabyData,
nAppendable );
tsize_t nRet = VSIFWriteL( psGTH->abyWriteBuffer, 1, BUFFER_SIZE, psGTH->fpL );
psGTH->nWriteBufferSize = 0;
if( nRet != BUFFER_SIZE )
{
TIFFErrorExt( th, "_tiffWriteProc", "%s", VSIStrerror( errno ) );
return 0;
}
pabyData += nAppendable;
nRemainingBytes -= nAppendable;
}
}
tsize_t nRet = VSIFWriteL( buf, 1, size, psGTH->fpL );
if (nRet < size)
{
TIFFErrorExt( th, "_tiffWriteProc", "%s", VSIStrerror( errno ) );
}
if( psGTH->bAtEndOfFile )
{
psGTH->nExpectedPos += nRet;
}
return nRet;
}
示例2: CPLAssert
CPLErr TerragenRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
void* pImage )
{
//CPLAssert( sizeof(float) == sizeof(GInt32) );
CPLAssert( nBlockXOff == 0 );
CPLAssert( pImage != NULL );
TerragenDataset& ds = *(TerragenDataset *) poDS;
/* -------------------------------------------------------------------- */
/* Seek to scanline.
Terragen is a bottom-top format, so we have to
invert the row location.
-------------------------------------------------------------------- */
const size_t rowbytes = nBlockXSize * sizeof(GInt16);
if(0 != VSIFSeekL(
ds.m_fp,
ds.m_nDataOffset +
(ds.GetRasterYSize() -1 - nBlockYOff) * rowbytes,
SEEK_SET))
{
CPLError( CE_Failure, CPLE_FileIO,
"Terragen Seek failed:%s", VSIStrerror( errno ) );
return CE_Failure;
}
/* -------------------------------------------------------------------- */
/* Read the scanline into the line buffer. */
/* -------------------------------------------------------------------- */
if( VSIFReadL( pImage, rowbytes, 1, ds.m_fp ) != 1 )
{
CPLError( CE_Failure, CPLE_FileIO,
"Terragen read failed:%s", VSIStrerror( errno ) );
return CE_Failure;
}
/* -------------------------------------------------------------------- */
/* Swap on MSB platforms. */
/* -------------------------------------------------------------------- */
#ifdef CPL_MSB
GDALSwapWords( pImage, sizeof(GInt16), nRasterXSize, sizeof(GInt16) );
#endif
return CE_None;
}
示例3: CPLError
OGRErr OGRShapeLayer::DropSpatialIndex()
{
if( !CheckForQIX() )
{
CPLError( CE_Warning, CPLE_AppDefined,
"Layer %s has no spatial index, DROP SPATIAL INDEX failed.",
poFeatureDefn->GetName() );
return OGRERR_FAILURE;
}
VSIFClose( fpQIX );
fpQIX = NULL;
bCheckedForQIX = FALSE;
const char *pszQIXFilename;
pszQIXFilename = CPLResetExtension( pszFullName, "qix" );
CPLDebug( "SHAPE", "Unlinking index file %s", pszQIXFilename );
if( VSIUnlink( pszQIXFilename ) != 0 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Failed to delete file %s.\n%s",
pszQIXFilename, VSIStrerror( errno ) );
return OGRERR_FAILURE;
}
else
return OGRERR_NONE;
}
示例4: CPLAssert
CPLErr LAN4BitRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff,
int nBlockYOff,
void * pImage )
{
LANDataset *poLAN_DS = reinterpret_cast<LANDataset *>( poDS );
CPLAssert( nBlockXOff == 0 );
/* -------------------------------------------------------------------- */
/* Seek to profile. */
/* -------------------------------------------------------------------- */
const vsi_l_offset nOffset =
ERD_HEADER_SIZE
+ (static_cast<vsi_l_offset>(nBlockYOff) * nRasterXSize * poLAN_DS->GetRasterCount()) / 2
+ (static_cast<vsi_l_offset>(nBand - 1) * nRasterXSize) / 2;
if( VSIFSeekL( poLAN_DS->fpImage, nOffset, SEEK_SET ) != 0 )
{
CPLError( CE_Failure, CPLE_FileIO,
"LAN Seek failed:%s", VSIStrerror( errno ) );
return CE_Failure;
}
/* -------------------------------------------------------------------- */
/* Read the profile. */
/* -------------------------------------------------------------------- */
if( VSIFReadL( pImage, 1, nRasterXSize/2, poLAN_DS->fpImage ) !=
(size_t) nRasterXSize / 2 )
{
CPLError( CE_Failure, CPLE_FileIO,
"LAN Read failed:%s", VSIStrerror( errno ) );
return CE_Failure;
}
/* -------------------------------------------------------------------- */
/* Convert 4bit to 8bit. */
/* -------------------------------------------------------------------- */
for( int i = nRasterXSize-1; i >= 0; i-- )
{
if( (i & 0x01) != 0 )
reinterpret_cast<GByte *>( pImage )[i] = ((GByte *) pImage)[i/2] & 0x0f;
else
reinterpret_cast<GByte *>( pImage )[i] = (((GByte *) pImage)[i/2] & 0xf0)/16;
}
return CE_None;
}
示例5: VSIFOpen
int OGRCSVDataSource::OpenTable( const char * pszFilename )
{
/* -------------------------------------------------------------------- */
/* Open the file. */
/* -------------------------------------------------------------------- */
FILE * fp;
if( bUpdate )
fp = VSIFOpen( pszFilename, "rb+" );
else
fp = VSIFOpen( pszFilename, "rb" );
if( fp == NULL )
{
CPLError( CE_Warning, CPLE_OpenFailed,
"Failed to open %s, %s.",
pszFilename, VSIStrerror( errno ) );
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Read and parse a line. Did we get multiple fields? */
/* -------------------------------------------------------------------- */
const char* pszLine = CPLReadLine( fp );
if (pszLine == NULL)
{
VSIFClose( fp );
return FALSE;
}
char chDelimiter = CSVDetectSeperator(pszLine);
VSIRewind( fp );
char **papszFields = CSVReadParseLine2( fp, chDelimiter );
if( CSLCount(papszFields) < 2 )
{
VSIFClose( fp );
CSLDestroy( papszFields );
return FALSE;
}
VSIRewind( fp );
CSLDestroy( papszFields );
/* -------------------------------------------------------------------- */
/* Create a layer. */
/* -------------------------------------------------------------------- */
nLayers++;
papoLayers = (OGRCSVLayer **) CPLRealloc(papoLayers,
sizeof(void*) * nLayers);
papoLayers[nLayers-1] =
new OGRCSVLayer( CPLGetBasename(pszFilename), fp, pszFilename, FALSE, bUpdate, chDelimiter );
return TRUE;
}
示例6: _tiffWriteProc
static tsize_t
_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
{
tsize_t nRet = VSIFWriteL( buf, 1, size, (VSILFILE *) fd );
if (nRet < size)
{
TIFFErrorExt( fd, "_tiffWriteProc", "%s", VSIStrerror( errno ) );
}
return nRet;
}
示例7: _tiffSeekProc
static toff_t
_tiffSeekProc(thandle_t fd, toff_t off, int whence)
{
if( VSIFSeekL( (VSILFILE *) fd, off, whence ) == 0 )
return (toff_t) VSIFTellL( (VSILFILE *) fd );
else
{
TIFFErrorExt( fd, "_tiffSeekProc", "%s", VSIStrerror( errno ) );
return (toff_t) -1;
}
}
示例8: _tiffSeekProc
static toff_t
_tiffSeekProc( thandle_t th, toff_t off, int whence )
{
VSILFILE* fp = (VSILFILE*)th;
if( VSIFSeekL( fp, off, whence ) != 0 )
{
TIFFErrorExt( th, "_tiffSeekProc", "%s", VSIStrerror( errno ) );
return (toff_t)( -1 );
}
return VSIFTellL( fp );
}
示例9: CSLTokenizeString2
int OGRILI1DataSource::Create( const char *pszFilename,
char **papszOptions )
{
std::string osBasename, osModelFilename;
char **filenames = CSLTokenizeString2( pszFilename, ",", 0 );
osBasename = filenames[0];
if( CSLCount(filenames) > 1 )
osModelFilename = filenames[1];
CSLDestroy( filenames );
/* -------------------------------------------------------------------- */
/* Create the empty file. */
/* -------------------------------------------------------------------- */
fpTransfer = VSIFOpen( osBasename.c_str(), "w+b" );
if( fpTransfer == NULL )
{
CPLError( CE_Failure, CPLE_OpenFailed,
"Failed to create %s:\n%s",
osBasename.c_str(), VSIStrerror( errno ) );
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Parse model */
/* -------------------------------------------------------------------- */
if( osModelFilename.length() == 0 )
{
CPLError(CE_Warning, CPLE_AppDefined,
"Creating Interlis transfer file without model definition." );
} else {
poImdReader->ReadModel(osModelFilename.c_str());
}
pszTopic = CPLStrdup(poImdReader->mainTopicName.c_str());
/* -------------------------------------------------------------------- */
/* Write headers */
/* -------------------------------------------------------------------- */
VSIFPrintf( fpTransfer, "SCNT\n" );
VSIFPrintf( fpTransfer, "OGR/GDAL %s, INTERLIS Driver\n", GDAL_RELEASE_NAME );
VSIFPrintf( fpTransfer, "////\n" );
VSIFPrintf( fpTransfer, "MTID INTERLIS1\n" );
const char* modelname = poImdReader->mainModelName.c_str();
VSIFPrintf( fpTransfer, "MODL %s\n", modelname );
return TRUE;
}
示例10: pszAccess
int ISIS2Dataset::WriteRaster(CPLString osFilename,
bool includeLabel,
GUIntBig iRecords,
GUIntBig iLabelRecords,
CPL_UNUSED GDALDataType eType,
CPL_UNUSED const char * pszInterleaving)
{
CPLString pszAccess("wb");
if(includeLabel)
pszAccess = "ab";
VSILFILE *fpBin = VSIFOpenL( osFilename, pszAccess.c_str() );
if( fpBin == nullptr ) {
CPLError( CE_Failure, CPLE_FileIO,
"Failed to create %s:\n%s",
osFilename.c_str(), VSIStrerror( errno ) );
return FALSE;
}
GUIntBig nSize = iRecords * RECORD_SIZE;
CPLDebug("ISIS2","nSize = %i", static_cast<int>(nSize));
if(includeLabel)
nSize = iLabelRecords * RECORD_SIZE + nSize;
// write last byte
const GByte byZero(0);
if(VSIFSeekL( fpBin, nSize-1, SEEK_SET ) != 0 ||
VSIFWriteL( &byZero, 1, 1, fpBin ) != 1) {
CPLError( CE_Failure, CPLE_FileIO,
"Failed to write %s:\n%s",
osFilename.c_str(), VSIStrerror( errno ) );
VSIFCloseL( fpBin );
return FALSE;
}
VSIFCloseL( fpBin );
return TRUE;
}
示例11: VSIFReadL
HFAEntry* HFAEntry::New( HFAInfo_t * psHFAIn, GUInt32 nPos,
HFAEntry * poParentIn, HFAEntry * poPrevIn )
{
HFAEntry* poEntry = new HFAEntry;
poEntry->psHFA = psHFAIn;
poEntry->nFilePos = nPos;
poEntry->poParent = poParentIn;
poEntry->poPrev = poPrevIn;
/* -------------------------------------------------------------------- */
/* Read the entry information from the file. */
/* -------------------------------------------------------------------- */
GInt32 anEntryNums[6] = {};
if( VSIFSeekL( poEntry->psHFA->fp, poEntry->nFilePos, SEEK_SET ) == -1
|| VSIFReadL( anEntryNums, sizeof(GInt32), 6, poEntry->psHFA->fp ) < 1 )
{
CPLError( CE_Failure, CPLE_FileIO,
"VSIFReadL(%p,6*4) @ %d failed in HFAEntry().\n%s",
poEntry->psHFA->fp, poEntry->nFilePos, VSIStrerror( errno ) );
delete poEntry;
return NULL;
}
for( int i = 0; i < 6; i++ )
HFAStandard( 4, anEntryNums + i );
poEntry->nNextPos = anEntryNums[0];
poEntry->nChildPos = anEntryNums[3];
poEntry->nDataPos = anEntryNums[4];
poEntry->nDataSize = anEntryNums[5];
/* -------------------------------------------------------------------- */
/* Read the name, and type. */
/* -------------------------------------------------------------------- */
if( VSIFReadL( poEntry->szName, 1, 64, poEntry->psHFA->fp ) < 1
|| VSIFReadL( poEntry->szType, 1, 32, poEntry->psHFA->fp ) < 1 )
{
poEntry->szName[sizeof(poEntry->szName)-1] = '\0';
poEntry->szType[sizeof(poEntry->szType)-1] = '\0';
CPLError( CE_Failure, CPLE_FileIO,
"VSIFReadL() failed in HFAEntry()." );
delete poEntry;
return NULL;
}
poEntry->szName[sizeof(poEntry->szName)-1] = '\0';
poEntry->szType[sizeof(poEntry->szType)-1] = '\0';
return poEntry;
}
示例12: VSI_FSEEK64
size_t VSIUnixStdioHandle::Read( void * pBuffer, size_t nSize, size_t nCount )
{
/* -------------------------------------------------------------------- */
/* If a fwrite() is followed by an fread(), the POSIX rules are */
/* that some of the write may still be buffered and lost. We */
/* are required to do a seek between to force flushing. So we */
/* keep careful track of what happened last to know if we */
/* skipped a flushing seek that we may need to do now. */
/* -------------------------------------------------------------------- */
if( bLastOpWrite )
VSI_FSEEK64( fp, nOffset, SEEK_SET );
/* -------------------------------------------------------------------- */
/* Perform the read. */
/* -------------------------------------------------------------------- */
size_t nResult = fread( pBuffer, nSize, nCount, fp );
int nError = errno;
VSIDebug4( "VSIUnixStdioHandle::Read(%p,%ld,%ld) = %ld",
fp, (long)nSize, (long)nCount, (long)nResult );
errno = nError;
/* -------------------------------------------------------------------- */
/* Update current offset. */
/* -------------------------------------------------------------------- */
#ifdef VSI_COUNT_BYTES_READ
nTotalBytesRead += nSize * nResult;
#endif
nOffset += nSize * nResult;
bLastOpWrite = FALSE;
bLastOpRead = TRUE;
if (nResult != nCount)
{
errno = 0;
vsi_l_offset nNewOffset = VSI_FTELL64( fp );
if( errno == 0 ) /* ftell() can fail if we are end of file with a pipe */
nOffset = nNewOffset;
else
CPLDebug("VSI", "%s", VSIStrerror(errno));
bAtEOF = feof(fp);
}
return nResult;
}
示例13: _tiffSeekProc
static toff_t
_tiffSeekProc(thandle_t th, toff_t off, int whence)
{
GDALTiffHandle* psGTH = (GDALTiffHandle*) th;
/* Optimization: if we are already at end, then no need to */
/* issue a VSIFSeekL() */
if( whence == SEEK_END )
{
if( psGTH->bAtEndOfFile )
{
return (toff_t) psGTH->nExpectedPos;
}
if( VSIFSeekL( psGTH->fpL, off, whence ) != 0 )
{
TIFFErrorExt( th, "_tiffSeekProc", "%s", VSIStrerror( errno ) );
return (toff_t) -1;
}
psGTH->bAtEndOfFile = TRUE;
psGTH->nExpectedPos = VSIFTellL( psGTH->fpL );
return (toff_t) (psGTH->nExpectedPos);
}
GTHFlushBuffer(th);
psGTH->bAtEndOfFile = FALSE;
psGTH->nExpectedPos = 0;
if( VSIFSeekL( psGTH->fpL, off, whence ) == 0 )
return (toff_t) VSIFTellL( psGTH->fpL );
else
{
TIFFErrorExt( th, "_tiffSeekProc", "%s", VSIStrerror( errno ) );
return (toff_t) -1;
}
}
示例14: TIFFOpen
/*
* Open a TIFF file for read/writing.
*/
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
int i, a_out;
char szAccess[32];
VSILFILE *fp;
TIFF *tif;
char *pszAccess = szAccess;
a_out = 0;
pszAccess[0] = '\0';
for( i = 0; mode[i] != '\0'; i++ )
{
if( mode[i] == 'r'
|| mode[i] == 'w'
|| mode[i] == '+'
|| mode[i] == 'a' )
{
szAccess[a_out++] = mode[i];
szAccess[a_out] = '\0';
}
}
strcat( szAccess, "b" );
fp = VSIFOpenL( name, szAccess );
if (fp == NULL) {
if( errno >= 0 )
TIFFError(module,"%s: %s", name, VSIStrerror( errno ) );
else
TIFFError(module, "%s: Cannot open", name);
return ((TIFF *)0);
}
tif = TIFFClientOpen(name, mode,
(thandle_t) fp,
_tiffReadProc, _tiffWriteProc,
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
_tiffMapProc, _tiffUnmapProc);
if( tif != NULL )
tif->tif_fd = 0;
else
CPL_IGNORE_RET_VAL_INT(VSIFCloseL( fp ));
return tif;
}
示例15: GTHFlushBuffer
static int GTHFlushBuffer(thandle_t th)
{
GDALTiffHandle* psGTH = (GDALTiffHandle*) th;
int bRet = TRUE;
if( psGTH->abyWriteBuffer && psGTH->nWriteBufferSize )
{
tsize_t nRet = VSIFWriteL( psGTH->abyWriteBuffer, 1, psGTH->nWriteBufferSize, psGTH->fpL );
bRet = (nRet == psGTH->nWriteBufferSize);
if( !bRet )
{
TIFFErrorExt( th, "_tiffWriteProc", "%s", VSIStrerror( errno ) );
}
psGTH->nWriteBufferSize = 0;
}
return bRet;
}