added implementation of mountpoint

pull/2/head
Falk Werner 4 years ago
parent 16705acf81
commit e727a9a54d

@ -26,6 +26,7 @@ add_executable(alltests
test/adapter/test_credentials.cc
test/adapter/test_authenticator.cc
test/adapter/test_authenticators.cc
test/adapter/test_mountpoint.cc
test/adapter/test_fuse_req.cc
test/adapter/jsonrpc/test_util.cc
test/adapter/jsonrpc/test_is_request.cc

@ -15,6 +15,7 @@ add_library(webfuse-adapter-static STATIC
lib/webfuse/adapter/impl/authenticators.c
lib/webfuse/adapter/impl/credentials.c
lib/webfuse/adapter/impl/operations.c
lib/webfuse/adapter/impl/mountpoint.c
lib/webfuse/adapter/impl/time/timepoint.c
lib/webfuse/adapter/impl/time/timer.c
lib/webfuse/adapter/impl/time/timeout_manager.c

@ -13,7 +13,7 @@ wf_mountpoint_create(
char const * path);
extern void
wf_mountpoint_release(
wf_mountpoint_dispose(
struct wf_mountpoint * mountpoint);
extern char const *

@ -9,5 +9,6 @@
#include <webfuse/adapter/server_protocol.h>
#include <webfuse/adapter/authenticate.h>
#include <webfuse/adapter/credentials.h>
#include <webfuse/adapter/mountpoint.h>
#endif

@ -4,6 +4,7 @@
#include "webfuse/adapter/impl/server_protocol.h"
#include "webfuse/adapter/impl/server_config.h"
#include "webfuse/adapter/impl/credentials.h"
#include "webfuse/adapter/impl/mountpoint.h"
// server
@ -134,3 +135,26 @@ char const * wf_credentials_get(
{
return wf_impl_credentials_get(credentials, key);
}
// mountpoint
struct wf_mountpoint *
wf_mountpoint_create(
char const * path)
{
return wf_impl_mountpoint_create(path);
}
void
wf_mountpoint_dispose(
struct wf_mountpoint * mountpoint)
{
wf_impl_mountpoint_dispose(mountpoint);
}
char const *
wf_mountpoint_get_path(
struct wf_mountpoint const * mountpoint)
{
return wf_impl_mountpoint_get_path(mountpoint);
}

@ -0,0 +1,34 @@
#include "webfuse/adapter/impl/mountpoint.h"
#include <stdlib.h>
#include <string.h>
struct wf_mountpoint
{
char * path;
};
struct wf_mountpoint *
wf_impl_mountpoint_create(
char const * path)
{
struct wf_mountpoint * mountpoint = malloc(sizeof(struct wf_mountpoint));
mountpoint->path = strdup(path);
return mountpoint;
}
void
wf_impl_mountpoint_dispose(
struct wf_mountpoint * mountpoint)
{
free(mountpoint->path);
free(mountpoint);
}
char const *
wf_impl_mountpoint_get_path(
struct wf_mountpoint const * mountpoint)
{
return mountpoint->path;
}

@ -0,0 +1,26 @@
#ifndef WF_IMPL_MOUNTPOINT_H
#define WF_IMPL_MOUNTPOINT_H
#ifdef __cplusplus
extern "C"
{
#endif
extern struct wf_mountpoint *
wf_impl_mountpoint_create(
char const * path);
extern void
wf_impl_mountpoint_dispose(
struct wf_mountpoint * mountpoint);
extern char const *
wf_impl_mountpoint_get_path(
struct wf_mountpoint const * mountpoint);
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,12 @@
#include <gtest/gtest.h>
#include "webfuse/adapter/mountpoint.h"
TEST(mountpoint, get_path)
{
wf_mountpoint * mountpoint = wf_mountpoint_create("/some/path");
ASSERT_NE(nullptr, mountpoint);
ASSERT_STREQ("/some/path", wf_mountpoint_get_path(mountpoint));
wf_mountpoint_dispose(mountpoint);
}
Loading…
Cancel
Save