[mapserver-commits] r10462 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Thu Aug 19 00:42:44 EDT 2010
Author: warmerdam
Date: 2010-08-19 04:42:44 +0000 (Thu, 19 Aug 2010)
New Revision: 10462
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapxbase.c
Log:
preliminary code to support dbf files in the 2-4GB size range (#3514)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2010-08-19 04:38:34 UTC (rev 10461)
+++ trunk/mapserver/HISTORY.TXT 2010-08-19 04:42:44 UTC (rev 10462)
@@ -13,6 +13,8 @@
Current Version (SVN trunk):
----------------------------
+- Support reading .dbf files between 2GB and 4GB (#3514)
+
- Avoid warnings about ms_cvsid being unused with gcc.
- Ensure the class is not marked BeforeFieldInit causing memory corruption with C#/CLR4 (#3438)
Modified: trunk/mapserver/mapxbase.c
===================================================================
--- trunk/mapserver/mapxbase.c 2010-08-19 04:38:34 UTC (rev 10461)
+++ trunk/mapserver/mapxbase.c 2010-08-19 04:42:44 UTC (rev 10462)
@@ -1,5 +1,5 @@
/******************************************************************************
- * $Id:$
+ * $Id$
*
* Project: MapServer
* Purpose: .dbf access API. Derived from shapelib, and relicensed with
@@ -28,12 +28,23 @@
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
+#define _FILE_OFFSET_BITS 64
+
#include "mapserver.h"
#include <stdlib.h> /* for atof() and atoi() */
#include <math.h>
MS_CVSID("$Id$")
+/* try to use a large file version of fseek for files up to 4GB (#3514) */
+#ifdef _MSC_VER
+# define safe_fseek _fseeki64
+#elif defined(fseeko)
+# define safe_fseek fseeko
+#else
+# define safe_fseek fseek
+#endif
+
/************************************************************************/
/* SfRealloc() */
/* */
@@ -112,7 +123,7 @@
static void flushRecord( DBFHandle psDBF )
{
- int nRecordOffset;
+ unsigned int nRecordOffset;
if( psDBF->bCurrentRecordModified && psDBF->nCurrentRecord > -1 )
{
@@ -121,7 +132,7 @@
nRecordOffset = psDBF->nRecordLength * psDBF->nCurrentRecord
+ psDBF->nHeaderLength;
- fseek( psDBF->fp, nRecordOffset, 0 );
+ safe_fseek( psDBF->fp, nRecordOffset, 0 );
fwrite( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
}
}
@@ -487,10 +498,11 @@
static char *msDBFReadAttribute(DBFHandle psDBF, int hEntity, int iField )
{
- int nRecordOffset, i;
+ int i;
+ unsigned int nRecordOffset;
uchar *pabyRec;
char *pReturnField = NULL;
-
+
/* -------------------------------------------------------------------- */
/* Is the request valid? */
/* -------------------------------------------------------------------- */
@@ -515,7 +527,7 @@
nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
- fseek( psDBF->fp, nRecordOffset, 0 );
+ safe_fseek( psDBF->fp, nRecordOffset, 0 );
fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
psDBF->nCurrentRecord = hEntity;
@@ -672,7 +684,8 @@
/************************************************************************/
static int msDBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField, void * pValue )
{
- int nRecordOffset, i, j;
+ unsigned int nRecordOffset;
+ int i, j;
uchar *pabyRec;
char szSField[40], szFormat[12];
@@ -709,7 +722,7 @@
nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
- fseek( psDBF->fp, nRecordOffset, 0 );
+ safe_fseek( psDBF->fp, nRecordOffset, 0 );
fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
psDBF->nCurrentRecord = hEntity;
More information about the mapserver-commits
mailing list