Permalink
Browse files

Add support for shapefiles with uppercase extension on Linux (#4712)

  • Loading branch information...
rouault committed Jul 17, 2013
1 parent 22e2178 commit 4e92968e905f00620e1c9aa4c041c21ced983032
Showing with 30 additions and 6 deletions.
  1. +15 −2 mapshape.c
  2. +4 −0 maptree.c
  3. +11 −4 mapxbase.c
View
@@ -252,6 +252,10 @@ SHPHandle msSHPOpen( const char * pszLayer, const char * pszAccess )
pszFullname = (char *) msSmallMalloc(strlen(pszBasename) + 5);
sprintf( pszFullname, "%s.shp", pszBasename );
psSHP->fpSHP = fopen(pszFullname, pszAccess );
if( psSHP->fpSHP == NULL ) {
sprintf( pszFullname, "%s.SHP", pszBasename );
psSHP->fpSHP = fopen(pszFullname, pszAccess );
}
if( psSHP->fpSHP == NULL ) {
msFree(pszBasename);
msFree(pszFullname);
@@ -261,6 +265,10 @@ SHPHandle msSHPOpen( const char * pszLayer, const char * pszAccess )
sprintf( pszFullname, "%s.shx", pszBasename );
psSHP->fpSHX = fopen(pszFullname, pszAccess );
if( psSHP->fpSHX == NULL ) {
sprintf( pszFullname, "%s.SHX", pszBasename );
psSHP->fpSHX = fopen(pszFullname, pszAccess );
}
if( psSHP->fpSHX == NULL ) {
msFree(pszBasename);
msFree(pszFullname);
@@ -1756,9 +1764,14 @@ int msShapefileWhichShapes(shapefileObj *shpfile, rectObj rect, int debug)
/* deal with case where sourcename is of the form 'file.shp' */
sourcename = msStrdup(shpfile->source);
/* TODO: need to add case-insensitive handling! */
s = strstr(sourcename, ".shp");
if( s ) *s = '\0';
if( s )
*s = '\0';
else {
s = strstr(sourcename, ".SHP");
if( s )
*s = '\0';
}
filename = (char *)malloc(strlen(sourcename)+strlen(MS_INDEX_EXTENSION)+1);
MS_CHECK_ALLOC(filename, strlen(sourcename)+strlen(MS_INDEX_EXTENSION)+1, MS_FAILURE);
View
@@ -126,6 +126,10 @@ SHPTreeHandle msSHPDiskTreeOpen(const char * pszTree, int debug)
pszFullname = (char *) msSmallMalloc(strlen(pszBasename) + 5);
sprintf( pszFullname, "%s%s", pszBasename, MS_INDEX_EXTENSION);
psTree->fp = fopen(pszFullname, "rb" );
if( psTree->fp == NULL ) {
sprintf( pszFullname, "%s.QIX", pszBasename);
psTree->fp = fopen(pszFullname, "rb" );
}
msFree(pszBasename); /* don't need these any more */
msFree(pszFullname);
View
@@ -162,11 +162,11 @@ DBFHandle msDBFOpen( const char * pszFilename, const char * pszAccess )
pszDBFFilename = (char *) msSmallMalloc(strlen(pszFilename)+1);
strcpy( pszDBFFilename, pszFilename );
if( strcmp(pszFilename+strlen(pszFilename)-4,".shp")
|| strcmp(pszFilename+strlen(pszFilename)-4,".shx") ) {
if( strcmp(pszFilename+strlen(pszFilename)-4,".shp") == 0
|| strcmp(pszFilename+strlen(pszFilename)-4,".shx") == 0 ) {
strcpy( pszDBFFilename+strlen(pszDBFFilename)-4, ".dbf");
} else if( strcmp(pszFilename+strlen(pszFilename)-4,".SHP")
|| strcmp(pszFilename+strlen(pszFilename)-4,".SHX") ) {
} else if( strcmp(pszFilename+strlen(pszFilename)-4,".SHP") == 0
|| strcmp(pszFilename+strlen(pszFilename)-4,".SHX") == 0 ) {
strcpy( pszDBFFilename+strlen(pszDBFFilename)-4, ".DBF");
}
@@ -176,6 +176,13 @@ DBFHandle msDBFOpen( const char * pszFilename, const char * pszAccess )
psDBF = (DBFHandle) calloc( 1, sizeof(DBFInfo) );
MS_CHECK_ALLOC(psDBF, sizeof(DBFInfo), NULL);
psDBF->fp = fopen( pszDBFFilename, pszAccess );
if( psDBF->fp == NULL )
{
if( strcmp(pszDBFFilename+strlen(pszDBFFilename)-4,".dbf") == 0 ) {
strcpy( pszDBFFilename+strlen(pszDBFFilename)-4, ".DBF");
psDBF->fp = fopen( pszDBFFilename, pszAccess );
}
}
if( psDBF->fp == NULL )
return( NULL );

0 comments on commit 4e92968

Please sign in to comment.