mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
Modified fstat call in fgrow2 to use filelengthi64 on Windows, where available.
This commit is contained in:
parent
fbdea5c4a0
commit
a81f150e88
@ -192,19 +192,31 @@ static int
|
||||
fgrow2(const int fd, const off_t len)
|
||||
{
|
||||
|
||||
#ifdef _WIN64
|
||||
struct _stat64 sb;
|
||||
if (_fstat64(fd, &sb) < 0)
|
||||
#else
|
||||
struct stat sb;
|
||||
if (fstat(fd, &sb) < 0)
|
||||
#endif
|
||||
{
|
||||
printf("Error %d: %s\n", errno, strerror(errno));
|
||||
|
||||
/* There is a problem with fstat on Windows based systems
|
||||
which manifests (so far) when Config RELEASE is built.
|
||||
Use _filelengthi64 isntead.
|
||||
|
||||
See https://github.com/Unidata/netcdf-c/issues/188
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_FILE_LENGTH_I64
|
||||
|
||||
__int64 file_len = 0;
|
||||
if (( file_len = _filelengthi64(fd)) < 0) {
|
||||
return errno;
|
||||
}
|
||||
if (len <= file_len)
|
||||
return ENOERR;
|
||||
#else
|
||||
|
||||
struct stat sb;
|
||||
if (fstat(fd, &sb) < 0)
|
||||
return errno;
|
||||
if (len <= sb.st_size)
|
||||
return ENOERR;
|
||||
#endif
|
||||
{
|
||||
const char dumb = 0;
|
||||
/* we don't use ftruncate() due to problem with FAT32 file systems */
|
||||
|
Loading…
Reference in New Issue
Block a user