Skip to content

Commit

Permalink
HasVSIHandler also tests externally registered handlers (fix ubuntu 2…
Browse files Browse the repository at this point in the history
…0.04) (#135)
  • Loading branch information
vincentvaroquauxads authored Sep 12, 2024
1 parent 40a5ad8 commit fbf96e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions godal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1770,20 +1770,20 @@ namespace cpl

} // namespace cpl

bool VSIHasGoHandler(const char *pszPrefix)
int godalVSIHasGoHandler(const char *pszPrefix)
{
CSLConstList papszPrefix = VSIFileManager::GetPrefixes();
for( size_t i = 0; papszPrefix && papszPrefix[i]; ++i ) {
if(strcmp(papszPrefix[i],pszPrefix)==0) {
return true;
return TRUE;
}
}
return false;
return FALSE;
}

void VSIInstallGoHandler(cctx *ctx, const char *pszPrefix, size_t bufferSize, size_t cacheSize)
void godalVSIInstallGoHandler(cctx *ctx, const char *pszPrefix, size_t bufferSize, size_t cacheSize)
{
bool alreadyExists = VSIHasGoHandler(pszPrefix);
bool alreadyExists = godalVSIHasGoHandler(pszPrefix) != 0;
godalWrap(ctx);
if (alreadyExists) {
CPLError(CE_Failure, CPLE_AppDefined, "handler already registered on prefix");
Expand Down Expand Up @@ -1986,4 +1986,4 @@ void godalGCPListToGeoTransform(cctx *ctx, goGCPList GCPList, int numGCPs, doubl
CPLFree(GDALGCPList);

godalUnwrap();
}
}
4 changes: 2 additions & 2 deletions godal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3886,7 +3886,7 @@ func RegisterVSIHandler(prefix string, handler KeySizerReaderAt, opts ...VSIHand
return fmt.Errorf("handler already registered on prefix")
}
cgc := createCGOContext(nil, opt.errorHandler)
C.VSIInstallGoHandler(cgc.cPointer(), C.CString(prefix), C.size_t(opt.bufferSize), C.size_t(opt.cacheSize))
C.godalVSIInstallGoHandler(cgc.cPointer(), C.CString(prefix), C.size_t(opt.bufferSize), C.size_t(opt.cacheSize))
if err := cgc.close(); err != nil {
return err
}
Expand All @@ -3900,7 +3900,7 @@ func RegisterVSIHandler(prefix string, handler KeySizerReaderAt, opts ...VSIHand

// HasVSIHandler returns true if a VSIHandler is registered for this prefix
func HasVSIHandler(prefix string) bool {
return bool(C.VSIHasGoHandler(C.CString(prefix)))
return C.godalVSIHasGoHandler(C.CString(prefix)) != 0
}

// BuildVRT runs the GDALBuildVRT function and creates a VRT dataset from a list of datasets
Expand Down
4 changes: 2 additions & 2 deletions godal.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ extern "C" {
void godalStartTransaction(cctx *ctx, GDALDatasetH ds, int bForce);
void godalDatasetRollbackTransaction(cctx *ctx, GDALDatasetH ds);
void godalCommitTransaction(cctx *ctx, GDALDatasetH ds);
bool VSIHasGoHandler(const char *pszPrefix);
void VSIInstallGoHandler(cctx *ctx, const char *pszPrefix, size_t bufferSize, size_t cacheSize);
int godalVSIHasGoHandler(const char *pszPrefix);
void godalVSIInstallGoHandler(cctx *ctx, const char *pszPrefix, size_t bufferSize, size_t cacheSize);

void godalGetColorTable(GDALRasterBandH bnd, GDALPaletteInterp *interp, int *nEntries, short **entries);
void godalSetColorTable(cctx *ctx, GDALRasterBandH bnd, GDALPaletteInterp interp, int nEntries, short *entries);
Expand Down

0 comments on commit fbf96e7

Please sign in to comment.