Skip to content

Commit

Permalink
Merge pull request #130 from rouault/fix_129
Browse files Browse the repository at this point in the history
SHPOpenLL(): avoid GDAL specific error message when .shx is missing
  • Loading branch information
rouault authored May 29, 2024
2 parents 44a608d + 04850a8 commit 011083c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions shpopen.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
#endif
#endif

/* Allows customization of the message in vendored builds (such as GDAL) */
#ifndef SHP_RESTORE_SHX_HINT_MESSAGE
#define SHP_RESTORE_SHX_HINT_MESSAGE \
" Use SHPRestoreSHX() to restore or create it."
#endif

/************************************************************************/
/* SHPWriteHeader() */
/* */
Expand Down Expand Up @@ -324,14 +330,14 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess,

if (psSHP->fpSHX == SHPLIB_NULLPTR)
{
const size_t nMessageLen = strlen(pszFullname) * 2 + 256;
const size_t nMessageLen =
64 + strlen(pszFullname) * 2 + strlen(SHP_RESTORE_SHX_HINT_MESSAGE);
char *pszMessage = STATIC_CAST(char *, malloc(nMessageLen));
pszFullname[nLenWithoutExtension] = 0;
snprintf(pszMessage, nMessageLen,
"Unable to open %s.shx or %s.SHX. "
"Set SHAPE_RESTORE_SHX config option to YES to restore or "
"create it.",
pszFullname, pszFullname);
snprintf(
pszMessage, nMessageLen,
"Unable to open %s.shx or %s.SHX." SHP_RESTORE_SHX_HINT_MESSAGE,
pszFullname, pszFullname);
psHooks->Error(pszMessage);
free(pszMessage);

Expand Down

0 comments on commit 011083c

Please sign in to comment.