[gdal-dev] VSIFGetc and VSIFReadL

Even Rouault even.rouault at spatialys.com
Sat Dec 31 03:54:14 PST 2022


Andrew,

Le 31/12/2022 à 12:39, Andrew C Aitchison a écrit :
>
> My plugin driver uses both VSIFGetc and VSIFReadL/VSIFWriteL
> on the same stream*.
Aouch ! Surprising you didn't get crashes ! A VSILFILE* is a very 
different object from a FILE*, and invoking VSIFGetc() on a VSILFILE* 
cannot work.
>
> Since https://github.com/OSGeo/gdal/pull/6883 made VSILFILE* and
> FILE* different, I cannot figure out which I am supposed to use.
> Possibly we need a VSIFGetcL to match VSIFReadL/VSIFWriteL
> just as we have the non-large-file versions VSIFGetc/VSIFRead/VSIFWrite.
>
> Though it may be easier just to change my code to use VSIFReadL
> throughout instead of VSIFGetc ...
Yes using VSIFReadL(&ch, 1, 1, fp) should do the job. You could also 
indeed add a VSIFGetcL() if that makes things easier.
>
> Thanks,
>
> ---------
> * "man fgetc" on Ubuntu says:
>     Calls to the functions described here can be mixed with each
>     other and with calls to other input functions from the stdio library
>     for the same input stream.
> and the stdio library includes fread/fwrite, so I think it is OK to 
> use both.
>
-- 
http://www.spatialys.com
My software is free, but my time generally not.



More information about the gdal-dev mailing list