diff options
author | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2020-04-01 10:16:12 +0100 |
---|---|---|
committer | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2020-04-01 10:16:12 +0100 |
commit | 45ff0b506dfa95f097cfaee37ec09cda8e3d3ec0 (patch) | |
tree | b67e0d9f2219ba8d76c5ea1d59e13ab68e71292b /netfs/fuse | |
parent | Pull definitions of OpenFile and Dir into their own header (diff) | |
download | netfs-45ff0b506dfa95f097cfaee37ec09cda8e3d3ec0.tar.bz2 netfs-45ff0b506dfa95f097cfaee37ec09cda8e3d3ec0.tar.xz netfs-45ff0b506dfa95f097cfaee37ec09cda8e3d3ec0.zip |
Configure settings from URI params
Diffstat (limited to 'netfs/fuse')
-rw-r--r-- | netfs/fuse/fuseApp.cpp | 13 | ||||
-rw-r--r-- | netfs/fuse/fuseApp.h | 5 |
2 files changed, 12 insertions, 6 deletions
diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp index fd26516..29820b8 100644 --- a/netfs/fuse/fuseApp.cpp +++ b/netfs/fuse/fuseApp.cpp @@ -10,6 +10,7 @@ #include <compileTimeFormatter.h> #include "fuseDirs.h" #include "fuseFiles.h" +#include <boost/lexical_cast.hpp> namespace AdHoc { template class Cache<struct stat, std::string>; @@ -87,7 +88,7 @@ NetFS::FuseApp::init(struct fuse_conn_info *, struct fuse_config *) } NetFS::Client::ResourcePtr -NetFS::FuseApp::configureFromFile(const std::filesystem::path & path, const std::string & resourceName) const +NetFS::FuseApp::configureFromFile(const std::filesystem::path & path, const std::string & resourceName) { auto s = Slicer::FileDeserializerFactory::createNew(path.extension().string(), path); auto c = Slicer::DeserializeAnyWith<NetFS::Client::ConfigurationPtr>(s); @@ -96,9 +97,9 @@ NetFS::FuseApp::configureFromFile(const std::filesystem::path & path, const std: AdHocFormatter(IceEndpointFmt, "%? -h %? -p %?"); NetFS::Client::ResourcePtr -NetFS::FuseApp::configureFromUri(const std::string & uriString) const +NetFS::FuseApp::configureFromUri(const std::string & uriString) { - AdHoc::Uri uri(uriString); + const AdHoc::Uri uri(uriString); auto r = std::make_shared<NetFS::Client::Resource>(); r->ExportName = uri.path->string(); @@ -106,6 +107,12 @@ NetFS::FuseApp::configureFromUri(const std::string & uriString) const if (uri.password) { r->AuthToken = *uri.password; } + auto set = [&uri](const auto & param, auto & setting) { + if (auto p = uri.query.find(param); p != uri.query.end()) { + setting = boost::lexical_cast<std::remove_reference_t<decltype(setting)>>(p->second); + } + }; + set("async", r->Async); return r; } diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h index bef757b..6869c01 100644 --- a/netfs/fuse/fuseApp.h +++ b/netfs/fuse/fuseApp.h @@ -79,9 +79,8 @@ namespace NetFS { virtual struct fuse_context * fuse_get_context() = 0; - protected: - NetFS::Client::ResourcePtr configureFromFile(const std::filesystem::path &, const std::string &) const; - NetFS::Client::ResourcePtr configureFromUri(const std::string &) const; + static NetFS::Client::ResourcePtr configureFromFile(const std::filesystem::path &, const std::string &); + static NetFS::Client::ResourcePtr configureFromUri(const std::string &); protected: template<typename Handle, typename ... Params> |