<div dir="ltr">Hello,<div>I'm implementing a gdal raster driver for an internal file format and am getting results I do not understand. The output is a binary raster of 32-bit floating point data, but the resulting file contains single bytes of value 0x0D at seemingly random intervals throughout the data. </div><div><br></div><div>Within my implementation of IWriteBlock, I see that the buffer pointed to by pImage <b>does not</b> contain these 0x0D's, however after calling <span style="color:black;font-family:Consolas">VSIFWrite </span>the output file does indeed have these individual bytes scattered throughout. In all cases, I am creating a new output file (not overwriting an existing file). Sometimes the 0D's occur in the middle of a 4-byte float, others are between two 4-byte float sequences. I cannot figure how/when/why these random 0D's are occurring in my output.</div><div><br></div><div>Thank you for any help provided. Here is my implementation of IWriteBlock</div><div><pre style="font-family:Consolas;color:black;background-image:initial;background-repeat:initial">CPLErr RLYRRasterBand::IWriteBlock(<span style="color:blue">int</span> nBlockXOff, <span style="color:blue">int</span> nBlockYOff, <span style="color:blue">void</span> *pImage)
{
RLYRDataset *poGDS = (RLYRDataset *)poDS;
<span style="color:blue">if</span> (poGDS->fp == 0) {
CPLError(CE_Failure, CPLE_FileIO, <span style="color:rgb(163,21,21)">"IWriteBlock: fp is NULL"</span>);
<span style="color:blue">return</span> CE_Failure;
}
nBlockYOff = poDS->GetRasterYSize() - nBlockYOff - 1;
size_t cdtSize = GDALGetDataTypeSize(GetRasterDataType()) / 8;
size_t nSeek = RLYRMeta::offset_data +
cdtSize * (nBlockXOff * nBlockYSize + nBlockYOff * nBlockXSize);
<span style="color:blue">int</span> zeeksez = VSIFSeek(poGDS->fp, nSeek, SEEK_SET);
<span style="color:blue">if</span> (zeeksez != 0) {
CPLError(CE_Warning, CPLE_FileIO, <span style="color:rgb(163,21,21)">"VSIFSeek returns %d"</span>, zeeksez);
<span style="color:blue">return</span> CE_Failure;
}
size_t nBlockLen = nBlockXSize * nBlockYSize;
size_t nWrit = VSIFWrite(pImage, cdtSize, nBlockLen, poGDS->fp);
<span style="color:blue">if</span> (nWrit != nBlockLen) {
CPLError(CE_Warning, CPLE_FileIO, <span style="color:rgb(163,21,21)">"VSIFWrite returns %d"</span>, nWrit);
<span style="color:blue">return</span> CE_Failure;
}
<span style="color:green">// test code - 'foo' does not exhibit bad data but the output file does</span>
<span style="color:green">//if (nBlockYOff == 1130) {</span>
<span style="color:green">// FILE *tfp = VSIFOpen("h:\\rasters\\o\\foo", "wb");</span>
<span style="color:green">// size_t nWrit2 = fwrite(pImage, cdtSize, nBlockLen, tfp);</span>
<span style="color:green">// VSIFClose(tfp);</span>
<span style="color:green">//}</span>
<span style="color:blue">return</span> CE_None;
}
</pre></div></div>