From 9dd9cd1b73eb983c2eb791cdcc34d4c0c3a2542a Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Mon, 30 Jan 2012 02:47:34 +0000 Subject: [PATCH] (#393) shp2pgsql returns "fseek(-xxx) failed on DBF file." for large (>2GB) DBF files git-svn-id: http://svn.osgeo.org/postgis/trunk@8967 b70326c6-7e19-0410-871a-916f4a2858ee --- loader/pgsql2shp-core.c | 12 ------------ loader/pgsql2shp-core.h | 2 ++ loader/safileio.c | 20 ++++++++++++++++++++ loader/shapefil.h | 12 ++++++++++-- loader/shp2pgsql-core.h | 1 - 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/loader/pgsql2shp-core.c b/loader/pgsql2shp-core.c index d2abacf55..a438dfbdf 100644 --- a/loader/pgsql2shp-core.c +++ b/loader/pgsql2shp-core.c @@ -23,17 +23,9 @@ #include "pgsql2shp-core.h" -#include -#include -#include -#include -#include -#include -#include /* Solaris9 does not provide stdint.h */ /* #include */ #include -#include /* for getpid() */ #ifdef HAVE_UNISTD_H /* for getpid() and getopt */ #include @@ -43,10 +35,6 @@ #include #endif -#include "libpq-fe.h" -#include "shapefil.h" -#include "getopt.h" - #include "../liblwgeom/liblwgeom.h" /* for LWGEOM struct and funx */ #include "../liblwgeom/lwgeom_log.h" /* for LWDEBUG macros */ diff --git a/loader/pgsql2shp-core.h b/loader/pgsql2shp-core.h index 8f5dfe757..bd4f7cef1 100644 --- a/loader/pgsql2shp-core.h +++ b/loader/pgsql2shp-core.h @@ -18,10 +18,12 @@ #include #include #include +#include #include #include #include +#include "../postgis_config.h" #include "libpq-fe.h" #include "shapefil.h" #include "shpcommon.h" diff --git a/loader/safileio.c b/loader/safileio.c index f3affe2ea..a7d843207 100644 --- a/loader/safileio.c +++ b/loader/safileio.c @@ -76,6 +76,18 @@ SHP_CVSID("$Id: safileio.c,v 1.4 2008-01-16 20:05:14 bram Exp $"); # endif #endif +/* Local prototypes */ +SAFile SADFOpen( const char *pszFilename, const char *pszAccess ); +SAOffset SADFRead( void *p, SAOffset size, SAOffset nmemb, SAFile file ); +SAOffset SADFWrite( void *p, SAOffset size, SAOffset nmemb, SAFile file ); +SAOffset SADFSeek( SAFile file, SAOffset offset, int whence ); +SAOffset SADFTell( SAFile file ); +int SADFFlush( SAFile file ); +int SADFClose( SAFile file ); +int SADRemove( const char *filename ); +void SADError( const char *message ); + + /************************************************************************/ /* SADFOpen() */ /************************************************************************/ @@ -115,7 +127,11 @@ SAOffset SADFWrite( void *p, SAOffset size, SAOffset nmemb, SAFile file ) SAOffset SADFSeek( SAFile file, SAOffset offset, int whence ) { +#ifdef HAVE_FSEEKO + return (SAOffset) fseeko( (FILE *) file, (off_t) offset, whence ); +#else return (SAOffset) fseek( (FILE *) file, (long) offset, whence ); +#endif } /************************************************************************/ @@ -125,7 +141,11 @@ SAOffset SADFSeek( SAFile file, SAOffset offset, int whence ) SAOffset SADFTell( SAFile file ) { +#ifdef HAVE_FSEEKO + return (SAOffset) ftello( (FILE *) file ); +#else return (SAOffset) ftell( (FILE *) file ); +#endif } /************************************************************************/ diff --git a/loader/shapefil.h b/loader/shapefil.h index b6ca718ed..80854989b 100644 --- a/loader/shapefil.h +++ b/loader/shapefil.h @@ -137,7 +137,9 @@ * try to improve SHPAPI_CALL docs */ +#define _FILE_OFFSET_BITS 64 #include +#include #ifdef USE_DBMALLOC #include @@ -240,8 +242,14 @@ static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); } /* -------------------------------------------------------------------- */ typedef int *SAFile; -#ifndef SAOffset -typedef unsigned long SAOffset; +#ifdef HAVE_SEEKO +# ifndef SAOffset + typedef off_t SAOffset; +# endif +#else +# ifndef SAOffset + typedef unsigned long SAOffset; +# endif #endif typedef struct { diff --git a/loader/shp2pgsql-core.h b/loader/shp2pgsql-core.h index 6efc072e4..8e7dce50a 100644 --- a/loader/shp2pgsql-core.h +++ b/loader/shp2pgsql-core.h @@ -27,7 +27,6 @@ #include "shpcommon.h" #include "getopt.h" - #include "../liblwgeom/stringbuffer.h" #define RCSID "$Id$" -- 2.40.0