]> granicus.if.org Git - postgis/commitdiff
Add EOF marker, per GBT#105
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 19 Feb 2009 20:59:31 +0000 (20:59 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 19 Feb 2009 20:59:31 +0000 (20:59 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@3749 b70326c6-7e19-0410-871a-916f4a2858ee

loader/dbfopen.c

index a1fb46568430d705fcc01c5f937a7b0e503e2dd4..03195968d9ccbdaead67c375629b68f15013f615 100644 (file)
@@ -508,6 +508,18 @@ DBFClose(DBFHandle psDBF)
     if( psDBF->bUpdated )
         DBFUpdateHeader( psDBF );
 
+/* -------------------------------------------------------------------- */
+/*  Add the DBF end-of-file marker after the last record.               */
+/* -------------------------------------------------------------------- */
+
+    fseek(psDBF->fp, -1, SEEK_END);
+    fread(&eof_test, 1, 1, psDBF->fp);
+    if( eof_test != 0x1a ) /* no EOF exists, so write one */
+    {
+        fseek(psDBF->fp, 0, SEEK_END);
+        fwrite(&eof, 1, 1, psDBF->fp);
+    }
+
 /* -------------------------------------------------------------------- */
 /*      Close, and free resources.                                      */
 /* -------------------------------------------------------------------- */