From f46bafac28550d6b0c1ef61d8e3c15d26b40b298 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 15 Feb 2015 16:13:47 +0000 Subject: Refactor to make more testable --- libfusepp/fuseAppBase.cpp | 214 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 libfusepp/fuseAppBase.cpp (limited to 'libfusepp/fuseAppBase.cpp') diff --git a/libfusepp/fuseAppBase.cpp b/libfusepp/fuseAppBase.cpp new file mode 100644 index 0000000..4d9ca97 --- /dev/null +++ b/libfusepp/fuseAppBase.cpp @@ -0,0 +1,214 @@ +#include "fuseAppBase.h" +#include +#include +#include +#include +#include +#include + +FuseAppBase * FuseAppBase::fuseApp; + +FuseAppBase::FuseAppBase() +{ +} +FuseAppBase::~FuseAppBase() +{ +} +void * FuseAppBase::init(fuse_conn_info*) +{ + return NULL; +} +int FuseAppBase::opt_parse(void*, const char *, int, fuse_args*) +{ + return 1; +} +int FuseAppBase::access(const char *, int) +{ + return -ENOSYS; +} +int FuseAppBase::chmod(const char *, mode_t) +{ + return -ENOSYS; +} +int FuseAppBase::chown(const char *, uid_t, gid_t) +{ + return -ENOSYS; +} +int FuseAppBase::create(const char *, mode_t, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::fgetattr(const char *, struct stat *, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::flush(const char *, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::fsync(const char *, int, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::fsyncdir(const char *, int, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::ftruncate(const char *, off_t, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::getattr(const char *, struct stat *) +{ + return -ENOSYS; +} +int FuseAppBase::getxattr(const char *, const char *, char *, size_t) +{ + return -ENOSYS; +} +int FuseAppBase::link(const char *, const char *) +{ + return -ENOSYS; +} +int FuseAppBase::listxattr(const char *, char *, size_t) +{ + return -ENOSYS; +} +int FuseAppBase::mkdir(const char *, mode_t) +{ + return -ENOSYS; +} +int FuseAppBase::mknod(const char *, mode_t, dev_t) +{ + return -ENOSYS; +} +int FuseAppBase::open(const char *, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::opendir(const char *, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::read(const char *, char *, size_t, off_t, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::readdir(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::readlink(const char *, char *, size_t) +{ + return -ENOSYS; +} +int FuseAppBase::release(const char *, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::releasedir(const char *, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::removexattr(const char *, const char *) +{ + return -ENOSYS; +} +int FuseAppBase::rename(const char *, const char *) +{ + return -ENOSYS; +} +int FuseAppBase::rmdir(const char *) +{ + return -ENOSYS; +} +int FuseAppBase::setxattr(const char *, const char *, const char *, size_t, int) +{ + return -ENOSYS; +} +int FuseAppBase::statfs(const char *, struct statvfs *) +{ + return -ENOSYS; +} +int FuseAppBase::symlink(const char *, const char *) +{ + return -ENOSYS; +} +int FuseAppBase::truncate(const char *, off_t) +{ + return -ENOSYS; +} +int FuseAppBase::unlink(const char *) +{ + return -ENOSYS; +} +int FuseAppBase::write(const char *, const char *, size_t, off_t, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::lock(const char *, struct fuse_file_info *, int, struct flock *) +{ + return -ENOSYS; +} +int FuseAppBase::utimens(const char *, const struct timespec[2]) +{ + return -ENOSYS; +} +int FuseAppBase::bmap(const char *, size_t, uint64_t *) +{ + return -ENOSYS; +} +int FuseAppBase::ioctl(const char *, int, void *, struct fuse_file_info *, unsigned int, void *) +{ + return -ENOSYS; +} +int FuseAppBase::poll(const char *, struct fuse_file_info *, struct fuse_pollhandle *, unsigned *) +{ + return -ENOSYS; +} +int FuseAppBase::write_buf(const char *, struct fuse_bufvec *, off_t, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::read_buf(const char *, struct fuse_bufvec **, size_t, off_t, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::flock(const char *, struct fuse_file_info *, int) +{ + return -ENOSYS; +} +int FuseAppBase::fallocate(const char *, int, off_t, off_t, struct fuse_file_info *) +{ + return -ENOSYS; +} +int FuseAppBase::onError(const std::exception & e) throw() +{ + fprintf(stderr, "Unknown exception calling (what: %s)\n", e.what()); + return -ENOSYS; +} + +void * FuseAppBase::fuseInit (struct fuse_conn_info *conn) +{ + return fuseApp->init(conn); +} +void FuseAppBase::fuseDestroy(void *) +{ + delete fuseApp; +} + +struct fuse_args +FuseAppBase::runint(int & argc, char** & argv, FuseAppBase * fa) +{ + struct fuse_opt fuse_opts[] = { + { NULL, 0, 0 } + }; + fuseApp = fa; + struct fuse_args args = FUSE_ARGS_INIT(argc, argv); + if (fuse_opt_parse(&args, fuseApp, fuse_opts, + fuseCall::helper<&FuseAppBase::opt_parse>) == -1) { + exit(1); + } + return args; +} + -- cgit v1.2.3 From 01ab3c40b2cae1a195ab2cd3bfcf8af9d783fac0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 16 Feb 2015 17:10:48 +0000 Subject: runint doesn't need a pointer to itself passing in --- libfusepp/fuseAppBase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libfusepp/fuseAppBase.cpp') diff --git a/libfusepp/fuseAppBase.cpp b/libfusepp/fuseAppBase.cpp index 4d9ca97..4e34192 100644 --- a/libfusepp/fuseAppBase.cpp +++ b/libfusepp/fuseAppBase.cpp @@ -198,12 +198,12 @@ void FuseAppBase::fuseDestroy(void *) } struct fuse_args -FuseAppBase::runint(int & argc, char** & argv, FuseAppBase * fa) +FuseAppBase::runint(int & argc, char** & argv) { struct fuse_opt fuse_opts[] = { { NULL, 0, 0 } }; - fuseApp = fa; + fuseApp = this; struct fuse_args args = FUSE_ARGS_INIT(argc, argv); if (fuse_opt_parse(&args, fuseApp, fuse_opts, fuseCall::helper<&FuseAppBase::opt_parse>) == -1) { -- cgit v1.2.3 From 3242322e92c841cab905f0352a65b695a318ecd3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 19 Feb 2015 00:38:13 +0000 Subject: Fix error message --- libfusepp/fuseAppBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libfusepp/fuseAppBase.cpp') diff --git a/libfusepp/fuseAppBase.cpp b/libfusepp/fuseAppBase.cpp index 4e34192..a1ea491 100644 --- a/libfusepp/fuseAppBase.cpp +++ b/libfusepp/fuseAppBase.cpp @@ -184,7 +184,7 @@ int FuseAppBase::fallocate(const char *, int, off_t, off_t, struct fuse_file_inf } int FuseAppBase::onError(const std::exception & e) throw() { - fprintf(stderr, "Unknown exception calling (what: %s)\n", e.what()); + fprintf(stderr, "Unknown exception (what: %s)\n", e.what()); return -ENOSYS; } -- cgit v1.2.3