diff --git a/src/fuse_chmod_policy_all.cpp b/src/fuse_chmod_policy_all.cpp index 7b89371c..a6fc12b7 100644 --- a/src/fuse_chmod_policy_all.cpp +++ b/src/fuse_chmod_policy_all.cpp @@ -22,15 +22,15 @@ #include "fs_lchmod.hpp" -FUSE::CHMOD::POLICY::ALL(const toml::value &toml_) +FUSE::CHMOD::POLICY::ALL::ALL(const toml::value &toml_) : _branches(toml_) { } int -FUSE::CHMOD::POLICYALL::operator()(const gfs::path &fusepath_, - const mode_t mode_) +FUSE::CHMOD::POLICY::ALL::operator()(const gfs::path &fusepath_, + const mode_t mode_) { Err rv; gfs::path fullpath; diff --git a/src/fuse_chown_policy_all.hpp b/src/fuse_chown_policy_all.hpp index 365dc6de..44663291 100644 --- a/src/fuse_chown_policy_all.hpp +++ b/src/fuse_chown_policy_all.hpp @@ -25,10 +25,10 @@ namespace FUSE::CHOWN::POLICY { - class all : public base + class ALL : public Base { public: - all(const toml::value &); + ALL(const toml::value &); public: int operator()(const gfs::path &fusepath, diff --git a/src/fuse_getattr_func.cpp b/src/fuse_getattr_func.cpp deleted file mode 100644 index b1567e66..00000000 --- a/src/fuse_getattr_func.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - ISC License - - Copyright (c) 2022, Antonio SJ Musumeci - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include "fuse_getattr_func.hpp" -#include "fuse_getattr_func_factory.hpp" - -#include "state.hpp" - - -FUSE::GETATTR::Func::Func(const toml::value &toml_) -{ - _getattr = FuncFactory(toml_); -} - -int -FUSE::GETATTR::Func::operator()(const gfs::path &fusepath_, - struct stat *st_, - fuse_timeouts_t *timeout_) -{ - return (*_getattr)(fusepath_,st_,timeout_); -} diff --git a/src/fuse_getattr_func.hpp b/src/fuse_getattr_func.hpp deleted file mode 100644 index b5e4d0b1..00000000 --- a/src/fuse_getattr_func.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - ISC License - - Copyright (c) 2022, Antonio SJ Musumeci - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#pragma once - -#include "from_toml.hpp" -#include "fuse_getattr_func_base.hpp" - -#include "fuse_timeouts.h" - -#include - -#include - - -namespace FUSE::GETATTR -{ - class Func - { - public: - Func(const toml::value &); - - public: - int operator()(const gfs::path &fusepath, - struct stat *st, - fuse_timeouts_t *timeout); - - private: - FuncBase::Ptr _getattr; - }; -} diff --git a/src/fuse_getattr_func_base.hpp b/src/fuse_getattr_func_base.hpp deleted file mode 100644 index a6f4c6f4..00000000 --- a/src/fuse_getattr_func_base.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - ISC License - - Copyright (c) 2022, Antonio SJ Musumeci - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#pragma once - -#include "fs_path.hpp" - -#include "fuse_timeouts.h" - -#include - -#include - -namespace FUSE::GETATTR -{ - class FuncBase - { - public: - typedef std::shared_ptr Ptr; - - public: - virtual int operator()(const gfs::path &fusepath, - struct stat *st, - fuse_timeouts_t *timeout) = 0; - }; -} diff --git a/src/fuse_ioctl_policy_all.cpp b/src/fuse_ioctl_policy_all.cpp index 6d51fa23..126d5e62 100644 --- a/src/fuse_ioctl_policy_all.cpp +++ b/src/fuse_ioctl_policy_all.cpp @@ -19,8 +19,12 @@ #include "fuse_ioctl_policy_all.hpp" #include "fuse_ioctl_err.hpp" +#include "fs_path.hpp" + #include "fs_ioctl.hpp" +#include "fh.hpp" + FUSE::IOCTL::POLICY::ALL::ALL(const toml::value &toml_) : _branches(toml_) @@ -39,6 +43,7 @@ FUSE::IOCTL::POLICY::ALL::operator()(const fuse_file_info_t *ffi_, gfs::path fusepath; gfs::path fullpath; + fusepath = reinterpret_cast(ffi_->fh)->fusepath; for(const auto &branch_group : _branches) { for(const auto &branch : branch_group) diff --git a/src/fuse_listxattr_policy.hpp b/src/fuse_listxattr_policy.hpp index 277605d1..73761023 100644 --- a/src/fuse_listxattr_policy.hpp +++ b/src/fuse_listxattr_policy.hpp @@ -38,7 +38,7 @@ namespace FUSE::LISTXATTR char *buf_, size_t count_) { - return (*_listxattr)(fusepath_,list_,size_); + return (*_listxattr)(fusepath_,buf_,count_); } private: diff --git a/src/fuse_mkdir_policy.hpp b/src/fuse_mkdir_policy.hpp index f4da1c0b..a0792a64 100644 --- a/src/fuse_mkdir_policy.hpp +++ b/src/fuse_mkdir_policy.hpp @@ -18,7 +18,8 @@ #pragma once -#include "fuse_mkdir_func_base.hpp" +#include "fuse_mkdir_policy_base.hpp" +#include "fuse_mkdir_policy_factory.hpp" #include "toml.hpp" @@ -42,6 +43,6 @@ namespace FUSE::MKDIR } private: - FuncBase::Ptr _mkdir; + POLICY::Base::Ptr _mkdir; }; } diff --git a/src/fuse_mknod_policy.hpp b/src/fuse_mknod_policy.hpp index cf723ce9..15431239 100644 --- a/src/fuse_mknod_policy.hpp +++ b/src/fuse_mknod_policy.hpp @@ -31,15 +31,15 @@ namespace FUSE::MKNOD public: Policy(const toml::value &toml_) { - _mknod = FuncFactory(toml_); + _mknod = POLICY::factory(toml_); } public: int - operator()(const gfs::path &fusepath, - const mode_t mode, - const mode_t umask, - const dev_t dev) + operator()(const gfs::path &fusepath_, + const mode_t mode_, + const mode_t umask_, + const dev_t dev_) { return (*_mknod)(fusepath_,mode_,umask_,dev_); } diff --git a/src/fuse_mknod_policy_base.hpp b/src/fuse_mknod_policy_base.hpp index ca71255c..2d18b458 100644 --- a/src/fuse_mknod_policy_base.hpp +++ b/src/fuse_mknod_policy_base.hpp @@ -33,7 +33,7 @@ namespace FUSE::MKNOD::POLICY class Base { public: - typedef std::shared_ptr Ptr; + typedef std::shared_ptr Ptr; public: virtual int operator()(const gfs::path &fusepath, diff --git a/src/fuse_readlink_policy.hpp b/src/fuse_readlink_policy.hpp index d44beb55..c010cc39 100644 --- a/src/fuse_readlink_policy.hpp +++ b/src/fuse_readlink_policy.hpp @@ -19,6 +19,7 @@ #pragma once #include "fuse_readlink_policy_base.hpp" +#include "fuse_readlink_policy_factory.hpp" #include "fuse_timeouts.h" diff --git a/src/fuse_readlink_policy_base.hpp b/src/fuse_readlink_policy_base.hpp index 31ffb685..993a2395 100644 --- a/src/fuse_readlink_policy_base.hpp +++ b/src/fuse_readlink_policy_base.hpp @@ -18,6 +18,8 @@ #pragma once +#include "fs_path.hpp" + #include diff --git a/src/fuse_readlink_policy_factory.hpp b/src/fuse_readlink_policy_factory.hpp index a351c1e0..78ccd38a 100644 --- a/src/fuse_readlink_policy_factory.hpp +++ b/src/fuse_readlink_policy_factory.hpp @@ -18,7 +18,7 @@ #pragma once -#include "fuse_readlink_func_base.hpp" +#include "fuse_readlink_policy_base.hpp" #include "toml.hpp" diff --git a/src/fuse_readlink_policy_ff.hpp b/src/fuse_readlink_policy_ff.hpp index b6e774d9..ff0091d4 100644 --- a/src/fuse_readlink_policy_ff.hpp +++ b/src/fuse_readlink_policy_ff.hpp @@ -33,7 +33,7 @@ namespace FUSE::READLINK::POLICY FF(const toml::value &); public: - int operator()(const gfs::path &fusepath,, + int operator()(const gfs::path &fusepath, char *buf, const size_t bufsiz) final; diff --git a/src/fuse_removexattr_policy.hpp b/src/fuse_removexattr_policy.hpp index ec2ef3db..9059330c 100644 --- a/src/fuse_removexattr_policy.hpp +++ b/src/fuse_removexattr_policy.hpp @@ -19,6 +19,7 @@ #pragma once #include "fuse_removexattr_policy_base.hpp" +#include "fuse_removexattr_policy_factory.hpp" #include "toml.hpp" diff --git a/src/fuse_rename_policy.hpp b/src/fuse_rename_policy.hpp index a45f7819..489cec8d 100644 --- a/src/fuse_rename_policy.hpp +++ b/src/fuse_rename_policy.hpp @@ -19,6 +19,7 @@ #pragma once #include "fuse_rename_policy_base.hpp" +#include "fuse_rename_policy_factory.hpp" #include "toml.hpp" diff --git a/src/fuse_rmdir_policy_all.cpp b/src/fuse_rmdir_policy_all.cpp index 940ccff9..eccb6bf7 100644 --- a/src/fuse_rmdir_policy_all.cpp +++ b/src/fuse_rmdir_policy_all.cpp @@ -16,34 +16,29 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "fuse_rmdir_func_all.hpp" +#include "fuse_rmdir_policy_all.hpp" #include "fuse_rmdir_err.hpp" #include "fs_rmdir.hpp" -namespace gfs = ghc::filesystem; - - -FUSE::RMDIR::FuncALL::FuncALL(const toml::value &toml_) +FUSE::RMDIR::POLICY::ALL::ALL(const toml::value &toml_) : _branches(toml_) { } int -FUSE::RMDIR::FuncALL::operator()(const char *fusepath_) +FUSE::RMDIR::POLICY::ALL::operator()(const gfs::path &fusepath_) { Err rv; - gfs::path fusepath; gfs::path fullpath; - fusepath = &fusepath_[1]; for(const auto &branch_group : _branches) { for(const auto &branch : branch_group) { - fullpath = branch.path / fusepath; + fullpath = branch.path / fusepath_; rv = fs::rmdir(fullpath); } diff --git a/src/fuse_rmdir_policy_all.hpp b/src/fuse_rmdir_policy_all.hpp index 133ab9ee..0fe2f79b 100644 --- a/src/fuse_rmdir_policy_all.hpp +++ b/src/fuse_rmdir_policy_all.hpp @@ -18,20 +18,20 @@ #pragma once -#include "fuse_rmdir_func_base.hpp" +#include "fuse_rmdir_policy_base.hpp" #include "branches.hpp" -namespace FUSE::RMDIR +namespace FUSE::RMDIR::POLICY { - class FuncALL : public FuncBase + class ALL : public Base { public: - FuncALL(const toml::value &); + ALL(const toml::value &); public: - int operator()(const char *fusepath) final; + int operator()(const gfs::path &fusepath) final; private: Branches2 _branches; diff --git a/src/fuse_rmdir_policy_base.hpp b/src/fuse_rmdir_policy_base.hpp index b1ab5328..d764ed93 100644 --- a/src/fuse_rmdir_policy_base.hpp +++ b/src/fuse_rmdir_policy_base.hpp @@ -18,18 +18,19 @@ #pragma once +#include "fs_path.hpp" #include -namespace FUSE::RMDIR +namespace FUSE::RMDIR::POLICY { - class FuncBase + class Base { public: - typedef std::shared_ptr Ptr; + typedef std::shared_ptr Ptr; public: - virtual int operator()(const char *fusepath) = 0; + virtual int operator()(const gfs::path &fusepath) = 0; }; } diff --git a/src/fuse_rmdir_policy_factory.cpp b/src/fuse_rmdir_policy_factory.cpp index 51ff6513..e948ba4e 100644 --- a/src/fuse_rmdir_policy_factory.cpp +++ b/src/fuse_rmdir_policy_factory.cpp @@ -16,22 +16,23 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "fuse_rmdir_func_factory.hpp" -#include "fuse_rmdir_func_all.hpp" +#include "fuse_rmdir_policy_factory.hpp" + +#include "fuse_rmdir_policy_all.hpp" #include -namespace FUSE::RMDIR +namespace FUSE::RMDIR::POLICY { - FuncBase::Ptr - FuncFactory(const toml::value &toml_) + Base::Ptr + factory(const toml::value &toml_) { std::string str; str = toml::find_or(toml_,"func","rmdir","policy","all"); if(str == "all") - return std::make_shared(toml_); + return std::make_shared(toml_); throw std::runtime_error(""); } diff --git a/src/fuse_rmdir_policy_factory.hpp b/src/fuse_rmdir_policy_factory.hpp index 2d42a292..a379e7df 100644 --- a/src/fuse_rmdir_policy_factory.hpp +++ b/src/fuse_rmdir_policy_factory.hpp @@ -18,13 +18,13 @@ #pragma once -#include "fuse_rmdir_func_base.hpp" +#include "fuse_rmdir_policy_base.hpp" #include "toml.hpp" -namespace FUSE::RMDIR +namespace FUSE::RMDIR::POLICY { - FuncBase::Ptr - FuncFactory(const toml::value &); + Base::Ptr + factory(const toml::value &); } diff --git a/src/fuse_setxattr_policy.hpp b/src/fuse_setxattr_policy.hpp index 54f6e48f..6f0ff9b1 100644 --- a/src/fuse_setxattr_policy.hpp +++ b/src/fuse_setxattr_policy.hpp @@ -18,26 +18,34 @@ #pragma once -#include "fuse_setxattr_func_base.hpp" +#include "fuse_setxattr_policy_base.hpp" +#include "fuse_setxattr_policy_factory.hpp" #include "toml.hpp" namespace FUSE::SETXATTR { - class Func + class Policy { public: - Func(const toml::value &); + Policy(const toml::value &toml_) + { + _setxattr = POLICY::factory(toml_); + } public: - int operator()(const char *fusepath, - const char *attrname, - const char *attrval, - const size_t attrvalsize, - const int flags); + int + operator()(const gfs::path &fusepath_, + const char *attrname_, + const char *attrval_, + const size_t attrvalsize_, + const int flags_) + { + return (*_setxattr)(fusepath_,attrname_,attrval_,attrvalsize_,flags_); + } private: - FuncBase::Ptr _setxattr; + POLICY::Base::Ptr _setxattr; }; } diff --git a/src/fuse_setxattr_policy_base.hpp b/src/fuse_setxattr_policy_base.hpp index 70a2b9bc..d122ac30 100644 --- a/src/fuse_setxattr_policy_base.hpp +++ b/src/fuse_setxattr_policy_base.hpp @@ -18,21 +18,23 @@ #pragma once +#include "fs_path.hpp" + #include -namespace FUSE::SETXATTR +namespace FUSE::SETXATTR::POLICY { - class FuncBase + class Base { public: - typedef std::shared_ptr Ptr; + typedef std::shared_ptr Ptr; public: - virtual int operator()(const char *fusepath, - const char *attrname, - const char *attrval, - const size_t attrvalsize, - const int flags) = 0; + virtual int operator()(const gfs::path &fusepath, + const char *attrname, + const char *attrval, + const size_t attrvalsize, + const int flags) = 0; }; } diff --git a/src/fuse_setxattr_policy_factory.hpp b/src/fuse_setxattr_policy_factory.hpp index a5317836..fa05a683 100644 --- a/src/fuse_setxattr_policy_factory.hpp +++ b/src/fuse_setxattr_policy_factory.hpp @@ -18,13 +18,13 @@ #pragma once -#include "fuse_setxattr_func_base.hpp" +#include "fuse_setxattr_policy_base.hpp" #include "toml.hpp" -namespace FUSE::SETXATTR +namespace FUSE::SETXATTR::POLICY { - FuncBase::Ptr - FuncFactory(const toml::value &); + Base::Ptr + factory(const toml::value &); } diff --git a/src/fuse_symlink_policy.hpp b/src/fuse_symlink_policy.hpp index 68766d26..c92c2aec 100644 --- a/src/fuse_symlink_policy.hpp +++ b/src/fuse_symlink_policy.hpp @@ -18,23 +18,31 @@ #pragma once -#include "fuse_symlink_func_base.hpp" +#include "fuse_symlink_policy_base.hpp" +#include "fuse_symlink_policy_factory.hpp" #include "toml.hpp" namespace FUSE::SYMLINK { - class Func + class Policy { public: - Func(const toml::value &); + Policy(const toml::value &toml_) + { + _symlink = POLICY::factory(toml_); + } public: - int operator()(const char *target, - const char *linkpath); + int + operator()(const gfs::path &target_, + const char *linkpath_) + { + return (*_symlink)(target_,linkpath_); + } private: - FuncBase::Ptr _symlink; + POLICY::Base::Ptr _symlink; }; } diff --git a/src/fuse_symlink_policy_base.hpp b/src/fuse_symlink_policy_base.hpp index f82ea2d8..77b4292e 100644 --- a/src/fuse_symlink_policy_base.hpp +++ b/src/fuse_symlink_policy_base.hpp @@ -18,20 +18,20 @@ #pragma once -#include "fuse.h" +#include "fs_path.hpp" #include -namespace FUSE::SYMLINK +namespace FUSE::SYMLINK::POLICY { - class FuncBase + class Base { public: - typedef std::shared_ptr Ptr; + typedef std::shared_ptr Ptr; public: - virtual int operator()(const char *target, - const char *linkpath) = 0; + virtual int operator()(const gfs::path &target, + const char *linkpath) = 0; }; } diff --git a/src/fuse_symlink_policy_factory.hpp b/src/fuse_symlink_policy_factory.hpp index 903598e8..991f1829 100644 --- a/src/fuse_symlink_policy_factory.hpp +++ b/src/fuse_symlink_policy_factory.hpp @@ -18,13 +18,13 @@ #pragma once -#include "fuse_symlink_func_base.hpp" +#include "fuse_symlink_policy_base.hpp" #include "toml.hpp" -namespace FUSE::SYMLINK +namespace FUSE::SYMLINK::POLICY { - FuncBase::Ptr - FuncFactory(const toml::value &); + Base::Ptr + factory(const toml::value &); } diff --git a/src/fuse_truncate_policy.hpp b/src/fuse_truncate_policy.hpp index 6410dcb1..7c0d8985 100644 --- a/src/fuse_truncate_policy.hpp +++ b/src/fuse_truncate_policy.hpp @@ -18,23 +18,31 @@ #pragma once -#include "fuse_truncate_func_base.hpp" +#include "fuse_truncate_policy_base.hpp" +#include "fuse_truncate_policy_factory.hpp" #include "toml.hpp" namespace FUSE::TRUNCATE { - class Func + class Policy { public: - Func(const toml::value &); + Policy(const toml::value &toml_) + { + _truncate = POLICY::factory(toml_); + } public: - int operator()(const char *fusepath, - const off_t length); + int + operator()(const gfs::path &fusepath_, + const off_t length_) + { + return (*_truncate)(fusepath_,length_); + } private: - FuncBase::Ptr _truncate; + POLICY::Base::Ptr _truncate; }; } diff --git a/src/fuse_truncate_policy_all.hpp b/src/fuse_truncate_policy_all.hpp index 82ee0814..c2f113b2 100644 --- a/src/fuse_truncate_policy_all.hpp +++ b/src/fuse_truncate_policy_all.hpp @@ -18,21 +18,21 @@ #pragma once -#include "fuse_truncate_func_base.hpp" +#include "fuse_truncate_policy_base.hpp" #include "branches.hpp" -namespace FUSE::TRUNCATE +namespace FUSE::TRUNCATE::POLICY { - class FuncALL : public FuncBase + class ALL : public Base { public: - FuncALL(const toml::value &); + ALL(const toml::value &); public: - int operator()(const char *fusepath, - const off_t length) final; + int operator()(const gfs::path &fusepath, + const off_t length) final; private: Branches2 _branches; diff --git a/src/fuse_truncate_policy_base.hpp b/src/fuse_truncate_policy_base.hpp index 5f140452..e7a83338 100644 --- a/src/fuse_truncate_policy_base.hpp +++ b/src/fuse_truncate_policy_base.hpp @@ -18,21 +18,22 @@ #pragma once +#include "fs_path.hpp" #include #include -namespace FUSE::TRUNCATE +namespace FUSE::TRUNCATE::POLICY { - class FuncBase + class Base { public: - typedef std::shared_ptr Ptr; + typedef std::shared_ptr Ptr; public: - virtual int operator()(const char *fusepath, - const off_t length) = 0; + virtual int operator()(const gfs::path &fusepath, + const off_t length) = 0; }; } diff --git a/src/fuse_truncate_policy_factory.cpp b/src/fuse_truncate_policy_factory.cpp index b5704ae4..42e12a4b 100644 --- a/src/fuse_truncate_policy_factory.cpp +++ b/src/fuse_truncate_policy_factory.cpp @@ -16,22 +16,22 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "fuse_truncate_func_factory.hpp" -#include "fuse_truncate_func_all.hpp" +#include "fuse_truncate_policy_factory.hpp" +#include "fuse_truncate_policy_all.hpp" #include -namespace FUSE::TRUNCATE +namespace FUSE::TRUNCATE::POLICY { - FuncBase::Ptr - FuncFactory(const toml::value &toml_) + Base::Ptr + factory(const toml::value &toml_) { std::string str; str = toml::find_or(toml_,"func","truncate","policy","all"); if(str == "all") - return std::make_shared(toml_); + return std::make_shared(toml_); throw std::runtime_error(""); } diff --git a/src/fuse_truncate_policy_factory.hpp b/src/fuse_truncate_policy_factory.hpp index 056c625d..0572e373 100644 --- a/src/fuse_truncate_policy_factory.hpp +++ b/src/fuse_truncate_policy_factory.hpp @@ -18,13 +18,13 @@ #pragma once -#include "fuse_truncate_func_base.hpp" +#include "fuse_truncate_policy_base.hpp" #include "toml.hpp" -namespace FUSE::TRUNCATE +namespace FUSE::TRUNCATE::POLICY { - FuncBase::Ptr - FuncFactory(const toml::value &); + Base::Ptr + factory(const toml::value &); } diff --git a/src/fuse_unlink_policy.hpp b/src/fuse_unlink_policy.hpp index 7951aba0..f65ebf43 100644 --- a/src/fuse_unlink_policy.hpp +++ b/src/fuse_unlink_policy.hpp @@ -18,22 +18,30 @@ #pragma once -#include "fuse_unlink_func_base.hpp" +#include "fuse_unlink_policy_base.hpp" +#include "fuse_unlink_policy_factory.hpp" #include "toml.hpp" namespace FUSE::UNLINK { - class Func + class Policy { public: - Func(const toml::value &); + Policy(const toml::value &toml_) + { + _unlink = POLICY::factory(toml_); + } public: - int operator()(const char *fusepath); + int + operator()(const gfs::path &fusepath_) + { + return (*_unlink)(fusepath_); + } private: - FuncBase::Ptr _unlink; + POLICY::Base::Ptr _unlink; }; } diff --git a/src/fuse_unlink_policy_base.hpp b/src/fuse_unlink_policy_base.hpp index e8e1bd00..c1682e3b 100644 --- a/src/fuse_unlink_policy_base.hpp +++ b/src/fuse_unlink_policy_base.hpp @@ -18,18 +18,19 @@ #pragma once +#include "fs_path.hpp" #include -namespace FUSE::UNLINK +namespace FUSE::UNLINK::POLICY { - class FuncBase + class Base { public: - typedef std::shared_ptr Ptr; + typedef std::shared_ptr Ptr; public: - virtual int operator()(const char *fusepath) = 0; + virtual int operator()(const gfs::path &fusepath) = 0; }; } diff --git a/src/fuse_unlink_policy_factory.hpp b/src/fuse_unlink_policy_factory.hpp index 9f744b27..37d4e47e 100644 --- a/src/fuse_unlink_policy_factory.hpp +++ b/src/fuse_unlink_policy_factory.hpp @@ -18,13 +18,13 @@ #pragma once -#include "fuse_unlink_func_base.hpp" +#include "fuse_unlink_policy_base.hpp" #include "toml.hpp" -namespace FUSE::UNLINK +namespace FUSE::UNLINK::POLICY { - FuncBase::Ptr - FuncFactory(const toml::value &); + Base::Ptr + factory(const toml::value &); }