[GRASS-windows] Large file support?

Glynn Clements glynn at gclements.plus.com
Tue Jul 29 15:35:52 EDT 2008


Marco Pasetti wrote:

> > Also, if the GDAL header files are installed, you can see whether LFS
> > was configured from the defines at the bottom of cpl_config.h.
> 
> I attached the mentioned header
> There's no reference to the LFS in that file, neither in the configure 
> options
> what I see in the header is only a reference to LFS for 64bit platforms...

The defines in question are these, which suggests that it has LFS
enabled:

	/* Define to name of 64bit fopen function */
	#define VSI_FOPEN64 fopen64
	
	/* Define to name of 64bit fseek func */
	#define VSI_FSEEK64 fseeko64
	
	/* Define to name of 64bit ftell func */
	#define VSI_FTELL64 ftello64
	
	/* Define to 1, if you have 64 bit STDIO API */
	#define VSI_LARGE_API_SUPPORTED 1
	
	/* Define to 1, if you have LARGEFILE64_SOURCE */
	/* #undef VSI_NEED_LARGEFILE64_SOURCE */
	
	/* Define to name of 64bit stat function */
	#define VSI_STAT64 stat
	
	/* Define to name of 64bit stat structure */
	#define VSI_STAT64_T stat

The "64" refers to the fact that it uses a 64-bit value for the
offset, which is necessary to handle files larger than 2GiB (offsets
are signed, hence the limit is at 2GiB rather than 4GiB).

However, the definition of VSI_STAT64 as "stat" may be problematic. 

MSVCRT has a _stat64() function and a separate "struct __stat64" type
which uses __int64 (rather than off_t) for the st_size field. MinGW
doesn't understand _FILE_OFFSET_BITS, so there's no way to make stat()
and alias for _stat64().

If code is obtaining the file size using stat(), it isn't going to
work on files >2GiB. You could try manually changing the last two
defines to:

	/* Define to name of 64bit stat function */
	#define VSI_STAT64 _stat64
	
	/* Define to name of 64bit stat structure */
	#define VSI_STAT64_T __stat64

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-windows mailing list