1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2026-03-02 04:09:18 +00:00

added ondispose to mountpoint to allow custom cleanup

This commit is contained in:
Falk Werner
2020-02-15 15:50:32 +01:00
parent e727a9a54d
commit 6a94cea6f9
5 changed files with 76 additions and 1 deletions

View File

@@ -158,3 +158,11 @@ wf_mountpoint_get_path(
{
return wf_impl_mountpoint_get_path(mountpoint);
}
void
wf_mountpoint_set_ondispose(
struct wf_mountpoint * mountpoint,
wf_mountpoint_ondispose_fn * ondispose)
{
wf_impl_mountpoint_set_ondispose(mountpoint, ondispose);
}

View File

@@ -6,14 +6,23 @@
struct wf_mountpoint
{
char * path;
wf_mountpoint_ondispose_fn * ondispose;
};
static void wf_impl_mountpoint_default_ondispose(
struct wf_mountpoint * mountpoint)
{
(void) mountpoint;
// empty
}
struct wf_mountpoint *
wf_impl_mountpoint_create(
char const * path)
{
struct wf_mountpoint * mountpoint = malloc(sizeof(struct wf_mountpoint));
mountpoint->path = strdup(path);
mountpoint->ondispose = &wf_impl_mountpoint_default_ondispose;
return mountpoint;
}
@@ -22,6 +31,8 @@ void
wf_impl_mountpoint_dispose(
struct wf_mountpoint * mountpoint)
{
mountpoint->ondispose(mountpoint);
free(mountpoint->path);
free(mountpoint);
}
@@ -32,3 +43,11 @@ wf_impl_mountpoint_get_path(
{
return mountpoint->path;
}
void
wf_impl_mountpoint_set_ondispose(
struct wf_mountpoint * mountpoint,
wf_mountpoint_ondispose_fn * ondispose)
{
mountpoint->ondispose = ondispose;
}

View File

@@ -1,6 +1,8 @@
#ifndef WF_IMPL_MOUNTPOINT_H
#define WF_IMPL_MOUNTPOINT_H
#include "webfuse/adapter/mountpoint.h"
#ifdef __cplusplus
extern "C"
{
@@ -18,6 +20,10 @@ extern char const *
wf_impl_mountpoint_get_path(
struct wf_mountpoint const * mountpoint);
extern void
wf_impl_mountpoint_set_ondispose(
struct wf_mountpoint * mointpoint,
wf_mountpoint_ondispose_fn * ondispose);
#ifdef __cplusplus
}