Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable removal of virtual filesystems #8772

Merged
merged 4 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions port/cpl_vsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,13 @@ void CPL_DLL VSIFreeFilesystemPluginCallbacksStruct(
int CPL_DLL VSIInstallPluginHandler(
const char *pszPrefix, const VSIFilesystemPluginCallbacksStruct *poCb);

/**
* Unregister a handler previously installed with VSIInstallPluginHandler() on
* the given prefix.
* @since GDAL 3.9
Maxxen marked this conversation as resolved.
Show resolved Hide resolved
*/
int CPL_DLL VSIRemovePluginHandler(const char *pszPrefix);

/* ==================================================================== */
/* Time querying. */
/* ==================================================================== */
Expand Down
3 changes: 1 addition & 2 deletions port/cpl_vsi_virtual.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ class CPL_DLL VSIFileManager
static VSIFilesystemHandler *GetHandler(const char *);
static void InstallHandler(const std::string &osPrefix,
VSIFilesystemHandler *);
/* RemoveHandler is never defined. */
/* static void RemoveHandler( const std::string& osPrefix ); */
static void RemoveHandler(const std::string &osPrefix);

static char **GetPrefixes();
};
Expand Down
12 changes: 12 additions & 0 deletions port/cpl_vsil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3253,6 +3253,18 @@ void VSIFileManager::InstallHandler(const std::string &osPrefix,
Get()->oHandlers[osPrefix] = poHandler;
}

/************************************************************************/
/* RemoveHandler() */
/************************************************************************/

void VSIFileManager::RemoveHandler(const std::string &osPrefix)
{
if (osPrefix == "")
Get()->poDefaultHandler = nullptr;
else
Get()->oHandlers.erase(osPrefix);
}

/************************************************************************/
/* VSICleanupFileManager() */
/************************************************************************/
Expand Down
6 changes: 6 additions & 0 deletions port/cpl_vsil_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@ int VSIInstallPluginHandler(const char *pszPrefix,
return 0;
}

int VSIRemovePluginHandler(const char *pszPrefix)
{
VSIFileManager::RemoveHandler(pszPrefix);
return 0;
}

VSIFilesystemPluginCallbacksStruct *
VSIAllocFilesystemPluginCallbacksStruct(void)
{
Expand Down
Loading