refactor
This commit is contained in:
parent
5ac2a24611
commit
eec3653c6b
@ -42,12 +42,12 @@
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
using action = std::function<exit_code(
|
||||
int, char **, const std::string &, const provider_type &,
|
||||
std::vector<const char *>, const std::string &, const provider_type &,
|
||||
const std::string &, std::string, std::string)>;
|
||||
|
||||
struct option_hasher {
|
||||
auto operator()(const utils::cli::option &opt) const -> std::size_t {
|
||||
return std::hash<std::string>()(opt[0u] + '|' + opt[1u]);
|
||||
return std::hash<std::string>()(opt[0U] + '|' + opt[1U]);
|
||||
}
|
||||
};
|
||||
|
||||
@ -75,14 +75,14 @@ static const std::unordered_map<utils::cli::option, action, option_hasher>
|
||||
};
|
||||
|
||||
[[nodiscard]] inline auto
|
||||
perform_action(const utils::cli::option &opt, int argc, char *argv[],
|
||||
const std::string &data_directory, const provider_type &pt,
|
||||
perform_action(const utils::cli::option &opt, std::vector<const char *> args,
|
||||
const std::string &data_directory, const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
if (utils::cli::has_option(argc, argv, opt)) {
|
||||
if (utils::cli::has_option(args, opt)) {
|
||||
if (option_actions.find(opt) != option_actions.end()) {
|
||||
return option_actions.at(opt)(argc, argv, data_directory, pt, unique_id,
|
||||
user, password);
|
||||
return option_actions.at(opt)(args, data_directory, prov, unique_id, user,
|
||||
password);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,10 @@
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
check_version(int, char *[], const std::string & /* data_directory */,
|
||||
const provider_type & /* pt */, const std::string &, std::string,
|
||||
std::string) -> exit_code {
|
||||
check_version(std::vector<const char *> /* args */,
|
||||
const std::string & /* data_directory */,
|
||||
const provider_type & /* pt */, const std::string & /*unique_id*/,
|
||||
std::string /*user*/, std::string /*password*/) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
|
||||
// TODO need to updated way to check version
|
||||
|
@ -30,20 +30,22 @@
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
display_config(int, char *[], const std::string &data_directory,
|
||||
const provider_type &pt, const std::string &unique_id,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
lock_data lock(pt, unique_id);
|
||||
const auto res = lock.grab_lock(1u);
|
||||
[[nodiscard]] inline auto display_config(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id,
|
||||
std::string user, std::string password)
|
||||
-> exit_code {
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::success) {
|
||||
app_config config(pt, data_directory);
|
||||
app_config config(prov, data_directory);
|
||||
const auto cfg = config.get_json();
|
||||
std::cout << 0 << std::endl;
|
||||
std::cout << cfg.dump(2) << std::endl;
|
||||
} else if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_config();
|
||||
|
@ -31,24 +31,25 @@
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
drive_information(int, char *[], const std::string &data_directory,
|
||||
const provider_type &pt, const std::string &unique_id,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
drive_information(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory, const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
|
||||
lock_data lock(pt, unique_id);
|
||||
const auto res = lock.grab_lock(1u);
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_drive_information();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << app_config::get_provider_display_name(pt) << " is not mounted."
|
||||
<< std::endl;
|
||||
std::cerr << app_config::get_provider_display_name(prov)
|
||||
<< " is not mounted." << std::endl;
|
||||
ret = exit_code::not_mounted;
|
||||
}
|
||||
|
||||
|
@ -30,19 +30,19 @@
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto get(int argc, char *argv[],
|
||||
[[nodiscard]] inline auto get(std::vector<const char *> args,
|
||||
const std::string &data_directory,
|
||||
const provider_type &pt,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
argc, argv, repertory::utils::cli::options::get_option, data);
|
||||
args, repertory::utils::cli::options::get_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
lock_data lock(pt, unique_id);
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1);
|
||||
if (res == lock_result::success) {
|
||||
app_config config(pt, data_directory);
|
||||
app_config config(prov, data_directory);
|
||||
const auto value = config.get_value_by_name(data);
|
||||
std::cout << (value.empty()
|
||||
? static_cast<int>(
|
||||
@ -51,8 +51,8 @@ namespace repertory::cli::actions {
|
||||
<< std::endl;
|
||||
std::cout << json({{"value", value}}).dump(2) << std::endl;
|
||||
} else if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response = client({"localhost", password, port, user})
|
||||
.get_config_value_by_name(data);
|
||||
|
@ -29,17 +29,16 @@
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
get_directory_items(int argc, char *argv[], const std::string &data_directory,
|
||||
const provider_type &pt, const std::string &,
|
||||
[[nodiscard]] inline auto get_directory_items(
|
||||
std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /* unique_id */,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
argc, argv, repertory::utils::cli::options::get_directory_items_option,
|
||||
data);
|
||||
args, repertory::utils::cli::options::get_directory_items_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_directory_items(data);
|
||||
|
@ -29,13 +29,15 @@
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
get_pinned_files(int, char *[], const std::string &data_directory,
|
||||
const provider_type &pt, const std::string &, std::string user,
|
||||
[[nodiscard]] inline auto get_pinned_files(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory,
|
||||
const provider_type &prov,
|
||||
const std::string & /* unique_id */,
|
||||
std::string user,
|
||||
std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_pinned_files();
|
||||
|
@ -23,8 +23,8 @@
|
||||
#define INCLUDE_CLI_HELP_HPP_
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
template <typename drive> inline void help(int argc, char *argv[]) {
|
||||
drive::display_options(argc, argv);
|
||||
template <typename drive> inline void help(std::vector<const char *> args) {
|
||||
drive::display_options(args);
|
||||
std::cout << "Repertory options:" << std::endl;
|
||||
std::cout << " -cv,--check_version Check daemon version "
|
||||
"compatibility"
|
||||
|
@ -54,30 +54,30 @@ using remote_instance = repertory::remote_fuse::i_remote_instance;
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
mount(int argc, char *argv[], std::string data_directory, int &mount_result,
|
||||
provider_type pt, const std::string &remote_host,
|
||||
mount(std::vector<const char *> args, std::string data_directory,
|
||||
int &mount_result, provider_type prov, const std::string &remote_host,
|
||||
std::uint16_t remote_port, const std::string &unique_id) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
|
||||
lock_data lock(pt, unique_id);
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock();
|
||||
if (res == lock_result::locked) {
|
||||
ret = exit_code::mount_active;
|
||||
std::cerr << app_config::get_provider_display_name(pt)
|
||||
std::cerr << app_config::get_provider_display_name(prov)
|
||||
<< " mount is already active" << std::endl;
|
||||
} else if (res == lock_result::success) {
|
||||
const auto generate_config = utils::cli::has_option(
|
||||
argc, argv, utils::cli::options::generate_config_option);
|
||||
args, utils::cli::options::generate_config_option);
|
||||
if (generate_config) {
|
||||
app_config config(pt, data_directory);
|
||||
if (pt == provider_type::remote) {
|
||||
app_config config(prov, data_directory);
|
||||
if (prov == provider_type::remote) {
|
||||
config.set_enable_remote_mount(false);
|
||||
config.set_is_remote_mount(true);
|
||||
config.set_remote_host_name_or_ip(remote_host);
|
||||
config.set_remote_port(remote_port);
|
||||
config.save();
|
||||
}
|
||||
std::cout << "Generated " << app_config::get_provider_display_name(pt)
|
||||
std::cout << "Generated " << app_config::get_provider_display_name(prov)
|
||||
<< " Configuration" << std::endl;
|
||||
std::cout << config.get_config_file_path() << std::endl;
|
||||
ret = utils::file::is_file(config.get_config_file_path())
|
||||
@ -85,14 +85,13 @@ mount(int argc, char *argv[], std::string data_directory, int &mount_result,
|
||||
: exit_code::file_creation_failed;
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
if (utils::cli::has_option(argc, argv,
|
||||
utils::cli::options::hidden_option)) {
|
||||
if (utils::cli::has_option(args, utils::cli::options::hidden_option)) {
|
||||
::ShowWindow(::GetConsoleWindow(), SW_HIDE);
|
||||
}
|
||||
#endif
|
||||
const auto drive_args =
|
||||
utils::cli::parse_drive_options(argc, argv, pt, data_directory);
|
||||
app_config config(pt, data_directory);
|
||||
utils::cli::parse_drive_options(args, prov, data_directory);
|
||||
app_config config(prov, data_directory);
|
||||
#ifdef _WIN32
|
||||
if (config.get_enable_mount_manager() &&
|
||||
not utils::is_process_elevated()) {
|
||||
@ -102,8 +101,8 @@ mount(int argc, char *argv[], std::string data_directory, int &mount_result,
|
||||
}
|
||||
lock.release();
|
||||
|
||||
mount_result = utils::run_process_elevated(argc, argv);
|
||||
lock_data lock2(pt, unique_id);
|
||||
mount_result = utils::run_process_elevated(args);
|
||||
lock_data lock2(prov, unique_id);
|
||||
if (lock2.grab_lock() == lock_result::success) {
|
||||
if (not lock2.set_mount_state(false, "", -1)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
@ -114,15 +113,16 @@ mount(int argc, char *argv[], std::string data_directory, int &mount_result,
|
||||
return exit_code::mount_result;
|
||||
}
|
||||
#endif
|
||||
std::cout << "Initializing " << app_config::get_provider_display_name(pt)
|
||||
std::cout << "Initializing "
|
||||
<< app_config::get_provider_display_name(prov)
|
||||
<< (unique_id.empty() ? ""
|
||||
: (pt == provider_type::s3)
|
||||
: (prov == provider_type::s3)
|
||||
? " [" + unique_id + ']'
|
||||
: " [" + remote_host + ':' +
|
||||
std::to_string(remote_port) + ']')
|
||||
<< " Drive" << std::endl;
|
||||
if (pt == provider_type::remote) {
|
||||
std::uint16_t port = 0u;
|
||||
if (prov == provider_type::remote) {
|
||||
std::uint16_t port{0U};
|
||||
if (utils::get_next_available_port(config.get_api_port(), port)) {
|
||||
config.set_remote_host_name_or_ip(remote_host);
|
||||
config.set_remote_port(remote_port);
|
||||
@ -155,7 +155,7 @@ mount(int argc, char *argv[], std::string data_directory, int &mount_result,
|
||||
config.set_is_remote_mount(false);
|
||||
|
||||
try {
|
||||
auto provider = create_provider(pt, config);
|
||||
auto provider = create_provider(prov, config);
|
||||
repertory_drive drive(config, lock, *provider);
|
||||
if (not lock.set_mount_state(true, "", -1)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
|
@ -31,23 +31,24 @@
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto
|
||||
open_files(int, char *[], const std::string &data_directory,
|
||||
const provider_type &pt, const std::string &unique_id,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
open_files(std::vector<const char *> /* args */,
|
||||
const std::string &data_directory, const provider_type &prov,
|
||||
const std::string &unique_id, std::string user, std::string password)
|
||||
-> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
lock_data lock(pt, unique_id);
|
||||
const auto res = lock.grab_lock(1u);
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).get_open_files();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
} else {
|
||||
std::cerr << app_config::get_provider_display_name(pt) << " is not mounted."
|
||||
<< std::endl;
|
||||
std::cerr << app_config::get_provider_display_name(prov)
|
||||
<< " is not mounted." << std::endl;
|
||||
ret = exit_code::not_mounted;
|
||||
}
|
||||
|
||||
|
@ -29,17 +29,16 @@
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto pin_file(int argc, char *argv[],
|
||||
const std::string &data_directory,
|
||||
const provider_type &pt, const std::string &,
|
||||
std::string user, std::string password)
|
||||
-> exit_code {
|
||||
[[nodiscard]] inline auto
|
||||
pin_file(std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /* unique_id */,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
argc, argv, repertory::utils::cli::options::pin_file_option, data);
|
||||
args, repertory::utils::cli::options::pin_file_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).pin_file(data);
|
||||
|
@ -29,17 +29,16 @@
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto pinned_status(int argc, char *argv[],
|
||||
const std::string &data_directory,
|
||||
const provider_type &pt,
|
||||
const std::string &, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
[[nodiscard]] inline auto
|
||||
pinned_status(std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /*unique_id*/,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
argc, argv, repertory::utils::cli::options::pinned_status_option, data);
|
||||
args, repertory::utils::cli::options::pinned_status_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).pinned_status(data);
|
||||
|
@ -30,27 +30,27 @@
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto set(int argc, char *argv[],
|
||||
[[nodiscard]] inline auto set(std::vector<const char *> args,
|
||||
const std::string &data_directory,
|
||||
const provider_type &pt,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
auto data = utils::cli::parse_option(argc, argv, "-set", 2u);
|
||||
auto data = utils::cli::parse_option(args, "-set", 2U);
|
||||
if (data.empty()) {
|
||||
data = utils::cli::parse_option(argc, argv, "--set", 2u);
|
||||
data = utils::cli::parse_option(args, "--set", 2U);
|
||||
if (data.empty()) {
|
||||
ret = exit_code::invalid_syntax;
|
||||
std::cerr << "Invalid syntax for '-set'" << std::endl;
|
||||
}
|
||||
}
|
||||
if (ret == exit_code::success) {
|
||||
lock_data lock(pt, unique_id);
|
||||
const auto res = lock.grab_lock(1u);
|
||||
lock_data lock(prov, unique_id);
|
||||
const auto res = lock.grab_lock(1U);
|
||||
if (res == lock_result::success) {
|
||||
app_config config(pt, data_directory);
|
||||
const auto value = config.set_value_by_name(data[0u], data[1u]);
|
||||
const auto notFound = value.empty() && not data[1u].empty();
|
||||
app_config config(prov, data_directory);
|
||||
const auto value = config.set_value_by_name(data[0U], data[1U]);
|
||||
const auto notFound = value.empty() && not data[1U].empty();
|
||||
ret = notFound ? exit_code::set_option_not_found : exit_code::success;
|
||||
std::cout << (notFound ? static_cast<int>(
|
||||
rpc_response_type::config_value_not_found)
|
||||
@ -58,11 +58,11 @@ namespace repertory::cli::actions {
|
||||
<< std::endl;
|
||||
std::cout << json({{"value", value}}).dump(2) << std::endl;
|
||||
} else if (res == lock_result::locked) {
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response = client({"localhost", password, port, user})
|
||||
.set_config_value_by_name(data[0u], data[1u]);
|
||||
.set_config_value_by_name(data[0U], data[1U]);
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
std::cout << response.data.dump(2) << std::endl;
|
||||
ret = response.response_type == rpc_response_type::config_value_not_found
|
||||
|
@ -26,13 +26,15 @@
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto status(int, char *[], const std::string &,
|
||||
const provider_type &pt,
|
||||
const std::string &unique_id, std::string,
|
||||
std::string) -> exit_code {
|
||||
[[nodiscard]] inline auto status(std::vector<const char *> /* args */,
|
||||
const std::string & /*data_directory*/,
|
||||
const provider_type &prov,
|
||||
const std::string &unique_id,
|
||||
std::string /* user */,
|
||||
std::string /* password */) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
lock_data lock(pt, unique_id);
|
||||
[[maybe_unused]] auto status = lock.grab_lock(10u);
|
||||
lock_data lock(prov, unique_id);
|
||||
[[maybe_unused]] auto status = lock.grab_lock(10U);
|
||||
json mount_state;
|
||||
if (lock.get_mount_state(mount_state)) {
|
||||
std::cout << mount_state.dump(2) << std::endl;
|
||||
|
@ -29,14 +29,13 @@
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto unmount(int, char *[],
|
||||
const std::string &data_directory,
|
||||
const provider_type &pt, const std::string &,
|
||||
std::string user, std::string password)
|
||||
-> exit_code {
|
||||
[[nodiscard]] inline auto
|
||||
unmount(std::vector<const char *> /* args */, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /*unique_id*/,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response = client({"localhost", password, port, user}).unmount();
|
||||
std::cout << static_cast<int>(response.response_type) << std::endl;
|
||||
|
@ -29,17 +29,16 @@
|
||||
#include "utils/cli_utils.hpp"
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
[[nodiscard]] inline auto unpin_file(int argc, char *argv[],
|
||||
const std::string &data_directory,
|
||||
const provider_type &pt,
|
||||
const std::string &, std::string user,
|
||||
std::string password) -> exit_code {
|
||||
[[nodiscard]] inline auto
|
||||
unpin_file(std::vector<const char *> args, const std::string &data_directory,
|
||||
const provider_type &prov, const std::string & /*unique_id*/,
|
||||
std::string user, std::string password) -> exit_code {
|
||||
std::string data;
|
||||
auto ret = utils::cli::parse_string_option(
|
||||
argc, argv, repertory::utils::cli::options::unpin_file_option, data);
|
||||
args, repertory::utils::cli::options::unpin_file_option, data);
|
||||
if (ret == exit_code::success) {
|
||||
auto port = app_config::default_api_port(pt);
|
||||
utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
auto port = app_config::default_api_port(prov);
|
||||
utils::cli::get_api_authentication_data(user, password, port, prov,
|
||||
data_directory);
|
||||
const auto response =
|
||||
client({"localhost", password, port, user}).unpin_file(data);
|
||||
|
@ -23,12 +23,12 @@
|
||||
#define INCLUDE_CLI_VERSION_HPP_
|
||||
|
||||
namespace repertory::cli::actions {
|
||||
template <typename drive> inline void version(int argc, char *argv[]) {
|
||||
template <typename drive> inline void version(std::vector<const char *> args) {
|
||||
std::cout << "Repertory core version: " << get_repertory_version()
|
||||
<< std::endl;
|
||||
std::cout << "Repertory Git revision: " << get_repertory_git_revision()
|
||||
<< std::endl;
|
||||
drive::display_version_information(argc, argv);
|
||||
drive::display_version_information(args);
|
||||
}
|
||||
} // namespace repertory::cli::actions
|
||||
|
||||
|
@ -38,6 +38,12 @@ public:
|
||||
|
||||
virtual ~fuse_base();
|
||||
|
||||
public:
|
||||
fuse_base(const fuse_base &) = delete;
|
||||
fuse_base(fuse_base &&) = delete;
|
||||
auto operator=(const fuse_base &) -> fuse_base & = delete;
|
||||
auto operator=(fuse_base &&) -> fuse_base & = delete;
|
||||
|
||||
protected:
|
||||
app_config &config_;
|
||||
|
||||
@ -593,9 +599,9 @@ protected:
|
||||
virtual void shutdown();
|
||||
|
||||
public:
|
||||
static void display_options(int argc, char *argv[]);
|
||||
static void display_options(std::vector<const char *> args);
|
||||
|
||||
static void display_version_information(int argc, char *argv[]);
|
||||
static void display_version_information(std::vector<const char *> args);
|
||||
|
||||
static auto unmount(const std::string &mount_location) -> int;
|
||||
|
||||
|
@ -36,6 +36,12 @@ public:
|
||||
|
||||
~fuse_drive_base() override = default;
|
||||
|
||||
public:
|
||||
fuse_drive_base(const fuse_drive_base &) = delete;
|
||||
fuse_drive_base(fuse_drive_base &&) = delete;
|
||||
auto operator=(const fuse_drive_base &) -> fuse_drive_base & = delete;
|
||||
auto operator=(fuse_drive_base &&) -> fuse_drive_base & = delete;
|
||||
|
||||
protected:
|
||||
[[nodiscard]] auto access_impl(std::string api_path, int mask)
|
||||
-> api_error override;
|
||||
|
@ -193,9 +193,9 @@ public:
|
||||
|
||||
void shutdown();
|
||||
|
||||
static void display_options(int argc, char *argv[]) {}
|
||||
static void display_options(std::vector<const char *> args) {}
|
||||
|
||||
static void display_version_information(int argc, char *argv[]) {}
|
||||
static void display_version_information(std::vector<const char *> args) {}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
|
@ -28,7 +28,8 @@ namespace repertory {
|
||||
class app_config;
|
||||
class i_provider;
|
||||
|
||||
[[nodiscard]] auto create_provider(const provider_type &pt, app_config &config)
|
||||
[[nodiscard]] auto create_provider(const provider_type &prov,
|
||||
app_config &config)
|
||||
-> std::unique_ptr<i_provider>;
|
||||
} // namespace repertory
|
||||
|
||||
|
@ -88,26 +88,28 @@ static const std::vector<option> option_list = {
|
||||
|
||||
// Prototypes
|
||||
void get_api_authentication_data(std::string &user, std::string &password,
|
||||
std::uint16_t &port, const provider_type &pt,
|
||||
std::uint16_t &port, const provider_type &prov,
|
||||
const std::string &data_directory);
|
||||
|
||||
[[nodiscard]] auto get_provider_type_from_args(int argc, char *argv[])
|
||||
[[nodiscard]] auto get_provider_type_from_args(std::vector<const char *> args)
|
||||
-> provider_type;
|
||||
|
||||
[[nodiscard]] auto has_option(int argc, char *argv[],
|
||||
[[nodiscard]] auto has_option(std::vector<const char *> args,
|
||||
const std::string &option_name) -> bool;
|
||||
|
||||
[[nodiscard]] auto has_option(int argc, char *argv[], const option &opt)
|
||||
[[nodiscard]] auto has_option(std::vector<const char *> args, const option &opt)
|
||||
-> bool;
|
||||
|
||||
[[nodiscard]] auto parse_option(int argc, char *argv[],
|
||||
[[nodiscard]] auto parse_option(std::vector<const char *> args,
|
||||
const std::string &option_name,
|
||||
std::uint8_t count) -> std::vector<std::string>;
|
||||
|
||||
[[nodiscard]] auto parse_string_option(int argc, char **argv, const option &opt,
|
||||
std::string &value) -> exit_code;
|
||||
[[nodiscard]] auto parse_string_option(std::vector<const char *> args,
|
||||
const option &opt, std::string &value)
|
||||
-> exit_code;
|
||||
|
||||
[[nodiscard]] auto parse_drive_options(int argc, char **argv, provider_type &pt,
|
||||
[[nodiscard]] auto parse_drive_options(std::vector<const char *> args,
|
||||
provider_type &prov,
|
||||
std::string &data_directory)
|
||||
-> std::vector<std::string>;
|
||||
} // namespace repertory::utils::cli
|
||||
|
@ -50,7 +50,7 @@ namespace repertory::utils {
|
||||
|
||||
[[nodiscard]] auto is_process_elevated() -> bool;
|
||||
|
||||
[[nodiscard]] auto run_process_elevated(int argc, char *argv[]) -> int;
|
||||
[[nodiscard]] auto run_process_elevated(std::vector<const char *> args) -> int;
|
||||
|
||||
void set_last_error_code(DWORD errorCode);
|
||||
|
||||
|
@ -160,21 +160,25 @@ void fuse_base::destroy_(void *ptr) {
|
||||
execute_void_callback(__FUNCTION__, [&]() { instance().destroy_impl(ptr); });
|
||||
}
|
||||
|
||||
void fuse_base::display_options([[maybe_unused]] int argc,
|
||||
[[maybe_unused]] char *argv[]) {
|
||||
void fuse_base::display_options(
|
||||
[[maybe_unused]] std::vector<const char *> args) {
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
fuse_cmdline_help();
|
||||
#else
|
||||
struct fuse_operations fuse_ops {};
|
||||
fuse_main(argc, argv, &fuse_ops, nullptr);
|
||||
fuse_main(args.size(),
|
||||
reinterpret_cast<char **>(const_cast<char **>(args.data())),
|
||||
&fuse_ops, nullptr);
|
||||
#endif
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void fuse_base::display_version_information(int argc, char *argv[]) {
|
||||
void fuse_base::display_version_information(std::vector<const char *> args) {
|
||||
struct fuse_operations fuse_ops {};
|
||||
fuse_main(argc, argv, &fuse_ops, nullptr);
|
||||
fuse_main(args.size(),
|
||||
reinterpret_cast<char **>(const_cast<char **>(args.data())),
|
||||
&fuse_ops, nullptr);
|
||||
}
|
||||
|
||||
auto fuse_base::execute_callback(
|
||||
|
40
src/main.cpp
40
src/main.cpp
@ -39,12 +39,13 @@ std::size_t PROVIDER_INDEX{0U};
|
||||
auto main(int argc, char **argv) -> int {
|
||||
repertory_init();
|
||||
|
||||
std::vector<const char *> args(argv, argv + argc);
|
||||
#ifdef REPERTORY_TESTING
|
||||
#ifdef _WIN32
|
||||
if (utils::cli::has_option(argc, argv, "--provider_index")) {
|
||||
if (utils::cli::has_option(args, "--provider_index")) {
|
||||
PROVIDER_INDEX = static_cast<std::size_t>(
|
||||
utils::string::to_uint64(
|
||||
utils::cli::parse_option(argc, argv, "--provider_index", 1U)[0U]) +
|
||||
utils::cli::parse_option(args, "--provider_index", 1U)[0U]) +
|
||||
1U);
|
||||
}
|
||||
#endif // _WIN32
|
||||
@ -54,28 +55,25 @@ auto main(int argc, char **argv) -> int {
|
||||
delete_generated_files();
|
||||
#else
|
||||
if (argc == 1) {
|
||||
argc++;
|
||||
static std::string cmd(argv[0U]);
|
||||
static std::vector<const char *> v({cmd.data(), "-h"});
|
||||
argv = (char **)v.data();
|
||||
args.push_back("-h");
|
||||
}
|
||||
|
||||
auto prov = utils::cli::get_provider_type_from_args(argc, argv);
|
||||
auto prov = utils::cli::get_provider_type_from_args(args);
|
||||
|
||||
std::string data_directory;
|
||||
auto res = utils::cli::parse_string_option(
|
||||
argc, argv, utils::cli::options::data_directory_option, data_directory);
|
||||
args, utils::cli::options::data_directory_option, data_directory);
|
||||
|
||||
std::string password;
|
||||
res = (res == exit_code::success)
|
||||
? utils::cli::parse_string_option(
|
||||
argc, argv, utils::cli::options::password_option, password)
|
||||
args, utils::cli::options::password_option, password)
|
||||
: res;
|
||||
|
||||
std::string user;
|
||||
res = (res == exit_code::success)
|
||||
? utils::cli::parse_string_option(
|
||||
argc, argv, utils::cli::options::user_option, user)
|
||||
args, utils::cli::options::user_option, user)
|
||||
: res;
|
||||
|
||||
std::string remote_host;
|
||||
@ -84,7 +82,7 @@ auto main(int argc, char **argv) -> int {
|
||||
if ((res == exit_code::success) && (prov == provider_type::remote)) {
|
||||
std::string data;
|
||||
if ((res = utils::cli::parse_string_option(
|
||||
argc, argv, utils::cli::options::remote_mount_option, data)) ==
|
||||
args, utils::cli::options::remote_mount_option, data)) ==
|
||||
exit_code::success) {
|
||||
const auto parts = utils::string::split(data, ':');
|
||||
if (parts.size() != 2) {
|
||||
@ -102,7 +100,7 @@ auto main(int argc, char **argv) -> int {
|
||||
: data_directory,
|
||||
{utils::string::replace_copy(unique_id, ':', '_')});
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << (e.what() ? e.what() : "Unable to parse port")
|
||||
std::cerr << (e.what() == nullptr ? "Unable to parse port" : e.what())
|
||||
<< std::endl;
|
||||
res = exit_code::invalid_syntax;
|
||||
}
|
||||
@ -113,7 +111,7 @@ auto main(int argc, char **argv) -> int {
|
||||
#ifdef REPERTORY_ENABLE_S3
|
||||
if ((res == exit_code::success) && (prov == provider_type::s3)) {
|
||||
std::string data;
|
||||
if ((res = utils::cli::parse_string_option(argc, argv,
|
||||
if ((res = utils::cli::parse_string_option(args,
|
||||
utils::cli::options::name_option,
|
||||
data)) == exit_code::success) {
|
||||
unique_id = utils::string::trim(data);
|
||||
@ -133,11 +131,11 @@ auto main(int argc, char **argv) -> int {
|
||||
|
||||
int mount_result{};
|
||||
if (res == exit_code::success) {
|
||||
if (utils::cli::has_option(argc, argv, utils::cli::options::help_option)) {
|
||||
cli::actions::help<repertory_drive>(argc, argv);
|
||||
} else if (utils::cli::has_option(argc, argv,
|
||||
if (utils::cli::has_option(args, utils::cli::options::help_option)) {
|
||||
cli::actions::help<repertory_drive>(args);
|
||||
} else if (utils::cli::has_option(args,
|
||||
utils::cli::options::version_option)) {
|
||||
cli::actions::version<repertory_drive>(argc, argv);
|
||||
cli::actions::version<repertory_drive>(args);
|
||||
} else {
|
||||
res = exit_code::option_not_found;
|
||||
for (std::size_t idx = 0U;
|
||||
@ -145,12 +143,12 @@ auto main(int argc, char **argv) -> int {
|
||||
(idx < utils::cli::options::option_list.size());
|
||||
idx++) {
|
||||
res = cli::actions::perform_action(
|
||||
utils::cli::options::option_list[idx], argc, argv, data_directory,
|
||||
prov, unique_id, user, password);
|
||||
utils::cli::options::option_list[idx], args, data_directory, prov,
|
||||
unique_id, user, password);
|
||||
}
|
||||
if (res == exit_code::option_not_found) {
|
||||
res = cli::actions::mount(argc, argv, data_directory, mount_result,
|
||||
prov, remote_host, remote_port, unique_id);
|
||||
res = cli::actions::mount(args, data_directory, mount_result, prov,
|
||||
remote_host, remote_port, unique_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,36 +43,33 @@ inline void create_comm(std::unique_ptr<intf_t> &comm, const config_t &config) {
|
||||
} // namespace
|
||||
|
||||
namespace repertory {
|
||||
auto create_provider(const provider_type &pt, app_config &config)
|
||||
auto create_provider(const provider_type &prov, app_config &config)
|
||||
-> std::unique_ptr<i_provider> {
|
||||
static std::mutex mutex;
|
||||
mutex_lock lock(mutex);
|
||||
|
||||
static std::unique_ptr<i_http_comm> comm;
|
||||
|
||||
switch (pt) {
|
||||
switch (prov) {
|
||||
case provider_type::sia: {
|
||||
create_comm<i_http_comm, curl_comm, host_config>(comm,
|
||||
config.get_host_config());
|
||||
return std::unique_ptr<i_provider>(
|
||||
dynamic_cast<i_provider *>(new sia_provider(config, *comm)));
|
||||
return std::make_unique<sia_provider>(config, *comm);
|
||||
}
|
||||
#if defined(REPERTORY_ENABLE_S3)
|
||||
case provider_type::s3: {
|
||||
create_comm<i_http_comm, curl_comm, s3_config>(comm,
|
||||
config.get_s3_config());
|
||||
return std::unique_ptr<i_provider>(
|
||||
dynamic_cast<i_provider *>(new s3_provider(config, *comm)));
|
||||
return std::make_unique<s3_provider>(config, *comm);
|
||||
}
|
||||
#endif // defined(REPERTORY_ENABLE_S3)
|
||||
case provider_type::encrypt: {
|
||||
return std::unique_ptr<i_provider>(
|
||||
dynamic_cast<i_provider *>(new encrypt_provider(config)));
|
||||
return std::make_unique<encrypt_provider>(config);
|
||||
}
|
||||
case provider_type::unknown:
|
||||
default:
|
||||
throw startup_exception("provider not supported: " +
|
||||
app_config::get_provider_display_name(pt));
|
||||
app_config::get_provider_display_name(prov));
|
||||
}
|
||||
}
|
||||
} // namespace repertory
|
||||
|
@ -29,10 +29,10 @@
|
||||
|
||||
namespace repertory::utils::cli {
|
||||
void get_api_authentication_data(std::string &user, std::string &password,
|
||||
std::uint16_t &port, const provider_type &pt,
|
||||
std::uint16_t &port, const provider_type &prov,
|
||||
const std::string &data_directory) {
|
||||
const auto cfg_file_path = utils::path::combine(
|
||||
data_directory.empty() ? app_config::default_data_directory(pt)
|
||||
data_directory.empty() ? app_config::default_data_directory(prov)
|
||||
: data_directory,
|
||||
{"config.json"});
|
||||
|
||||
@ -50,44 +50,45 @@ void get_api_authentication_data(std::string &user, std::string &password,
|
||||
}
|
||||
}
|
||||
|
||||
auto get_provider_type_from_args(int argc, char *argv[]) -> provider_type {
|
||||
[[nodiscard]] auto get_provider_type_from_args(std::vector<const char *> args)
|
||||
-> provider_type {
|
||||
#if defined(REPERTORY_ENABLE_S3)
|
||||
if (has_option(argc, argv, options::s3_option)) {
|
||||
if (has_option(args, options::s3_option)) {
|
||||
return provider_type::s3;
|
||||
}
|
||||
#endif // defined(REPERTORY_ENABLE_S3)
|
||||
if (has_option(argc, argv, options::remote_mount_option)) {
|
||||
if (has_option(args, options::remote_mount_option)) {
|
||||
return provider_type::remote;
|
||||
}
|
||||
if (has_option(argc, argv, options::encrypt_option)) {
|
||||
if (has_option(args, options::encrypt_option)) {
|
||||
return provider_type::encrypt;
|
||||
}
|
||||
|
||||
return provider_type::sia;
|
||||
}
|
||||
|
||||
auto has_option(int argc, char *argv[], const std::string &option_name)
|
||||
auto has_option(std::vector<const char *> args, const std::string &option_name)
|
||||
-> bool {
|
||||
auto ret = false;
|
||||
for (int i = 0; not ret && (i < argc); i++) {
|
||||
ret = (option_name == argv[i]);
|
||||
}
|
||||
return ret;
|
||||
return std::find_if(args.begin(), args.end(),
|
||||
[&option_name](const auto &value) -> bool {
|
||||
return option_name == value;
|
||||
}) != args.end();
|
||||
}
|
||||
|
||||
auto has_option(int argc, char *argv[], const option &opt) -> bool {
|
||||
return has_option(argc, argv, opt[0u]) || has_option(argc, argv, opt[1u]);
|
||||
auto has_option(std::vector<const char *> args, const option &opt) -> bool {
|
||||
return has_option(args, opt[0U]) || has_option(args, opt[1U]);
|
||||
}
|
||||
|
||||
auto parse_option(int argc, char *argv[], const std::string &option_name,
|
||||
std::uint8_t count) -> std::vector<std::string> {
|
||||
auto parse_option(std::vector<const char *> args,
|
||||
const std::string &option_name, std::uint8_t count)
|
||||
-> std::vector<std::string> {
|
||||
std::vector<std::string> ret;
|
||||
auto found = false;
|
||||
for (auto i = 0; not found && (i < argc); i++) {
|
||||
if ((found = (option_name == argv[i]))) {
|
||||
if ((++i + count) <= argc) {
|
||||
while (count--) {
|
||||
ret.emplace_back(argv[i++]);
|
||||
auto found{false};
|
||||
for (std::size_t i = 0U; not found && (i < args.size()); i++) {
|
||||
if ((found = (option_name == args.at(i)))) {
|
||||
if ((++i + count) <= args.size()) {
|
||||
while ((count--) != 0U) {
|
||||
ret.emplace_back(args.at(i++));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,90 +97,94 @@ auto parse_option(int argc, char *argv[], const std::string &option_name,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto parse_string_option(int argc, char **argv, const option &opt,
|
||||
auto parse_string_option(std::vector<const char *> args, const option &opt,
|
||||
std::string &value) -> exit_code {
|
||||
auto ret = exit_code::success;
|
||||
if (has_option(argc, argv, opt[0u]) || has_option(argc, argv, opt[1u])) {
|
||||
auto data = parse_option(argc, argv, opt[0u], 1u);
|
||||
exit_code ret{exit_code::success};
|
||||
if (has_option(args, opt.at(0U)) || has_option(args, opt.at(1U))) {
|
||||
auto data = parse_option(args, opt.at(0U), 1U);
|
||||
if (data.empty()) {
|
||||
data = parse_option(argc, argv, opt[1u], 1u);
|
||||
data = parse_option(args, opt.at(1U), 1U);
|
||||
if (data.empty()) {
|
||||
std::cerr << "Invalid syntax for '" << opt[0u] << "," << opt[1u] << '\''
|
||||
<< std::endl;
|
||||
std::cerr << "Invalid syntax for '" << opt.at(0U) << "," << opt.at(1U)
|
||||
<< '\'' << std::endl;
|
||||
ret = exit_code::invalid_syntax;
|
||||
}
|
||||
}
|
||||
|
||||
if (not data.empty()) {
|
||||
value = data[0u];
|
||||
value = data.at(0U);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto parse_drive_options(int argc, char **argv,
|
||||
[[maybe_unused]] provider_type &pt,
|
||||
auto parse_drive_options(std::vector<const char *> args,
|
||||
[[maybe_unused]] provider_type &prov,
|
||||
[[maybe_unused]] std::string &data_directory)
|
||||
-> std::vector<std::string> {
|
||||
// Strip out options from command line
|
||||
const auto &option_list = options::option_list;
|
||||
std::vector<std::string> drive_args;
|
||||
for (int i = 0; i < argc; i++) {
|
||||
const auto &a = argv[i];
|
||||
for (std::size_t i = 0U; i < args.size(); i++) {
|
||||
const auto &arg = args.at(i);
|
||||
if (std::find_if(option_list.begin(), option_list.end(),
|
||||
[&a](const auto &pair) -> bool {
|
||||
return ((pair[0] == a) || (pair[1] == a));
|
||||
[&arg](const auto &pair) -> bool {
|
||||
return ((pair[0] == arg) || (pair[1] == arg));
|
||||
}) == option_list.end()) {
|
||||
drive_args.emplace_back(argv[i]);
|
||||
} else if ((std::string(argv[i]) == options::remote_mount_option[0]) ||
|
||||
(std::string(argv[i]) == options::remote_mount_option[1])) {
|
||||
i++;
|
||||
} else if ((std::string(argv[i]) == options::data_directory_option[0]) ||
|
||||
(std::string(argv[i]) == options::data_directory_option[1])) {
|
||||
i++;
|
||||
drive_args.emplace_back(args.at(i));
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((std::string(args.at(i)) == options::remote_mount_option[0U]) ||
|
||||
(std::string(args.at(i)) == options::remote_mount_option[1U]) ||
|
||||
(std::string(args.at(i)) == options::data_directory_option[0U]) ||
|
||||
(std::string(args.at(i)) == options::data_directory_option[1U])
|
||||
#ifdef REPERTORY_ENABLE_S3
|
||||
else if ((std::string(argv[i]) == options::name_option[0]) ||
|
||||
(std::string(argv[i]) == options::name_option[1])) {
|
||||
i++;
|
||||
}
|
||||
|| (std::string(args.at(i)) == options::name_option[0U]) ||
|
||||
(std::string(args.at(i)) == options::name_option[1U])
|
||||
#endif // REPERTORY_ENABLE_S3
|
||||
) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
std::vector<std::string> fuse_flags_list;
|
||||
for (std::size_t i = 1; i < drive_args.size(); i++) {
|
||||
if (drive_args[i].find("-o") == 0) {
|
||||
std::string options = "";
|
||||
if (drive_args.at(i).find("-o") == 0) {
|
||||
std::string options;
|
||||
if (drive_args[i].size() == 2) {
|
||||
if ((i + 1) < drive_args.size()) {
|
||||
options = drive_args[++i];
|
||||
options = drive_args.at(++i);
|
||||
}
|
||||
} else {
|
||||
options = drive_args[i].substr(2);
|
||||
options = drive_args.at(i).substr(2);
|
||||
}
|
||||
|
||||
const auto fuse_option_list = utils::string::split(options, ',');
|
||||
for (const auto &fuse_option : fuse_option_list) {
|
||||
#if defined(REPERTORY_ENABLE_S3)
|
||||
if (fuse_option.find("s3") == 0) {
|
||||
pt = provider_type::s3;
|
||||
prov = provider_type::s3;
|
||||
continue;
|
||||
}
|
||||
#endif // defined(REPERTORY_ENABLE_S3)
|
||||
if ((fuse_option.find("dd") == 0) ||
|
||||
(fuse_option.find("data_directory") == 0)) {
|
||||
const auto data = utils::string::split(fuse_option, '=');
|
||||
if (data.size() == 2) {
|
||||
data_directory = data[1];
|
||||
if (data.size() == 2U) {
|
||||
data_directory = data.at(1);
|
||||
} else {
|
||||
std::cerr << "Invalid syntax for '-dd,--data_directory'"
|
||||
<< std::endl;
|
||||
exit(3);
|
||||
}
|
||||
} else {
|
||||
fuse_flags_list.push_back(fuse_option);
|
||||
continue;
|
||||
}
|
||||
|
||||
fuse_flags_list.push_back(fuse_option);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,10 +199,12 @@ auto parse_drive_options(int argc, char **argv,
|
||||
utils::remove_element_from(new_drive_args, new_drive_args[i]);
|
||||
i--;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
utils::remove_element_from(new_drive_args, new_drive_args[i]);
|
||||
i--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,11 +144,12 @@ auto is_process_elevated() -> bool {
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto run_process_elevated(int argc, char *argv[]) -> int {
|
||||
auto run_process_elevated(std::vector<const char *> args) -> int {
|
||||
std::cout << "Elevating Process" << std::endl;
|
||||
std::string parameters = "-hidden";
|
||||
for (int i = 1; i < argc; i++) {
|
||||
parameters += (parameters.empty() ? argv[i] : " " + std::string(argv[i]));
|
||||
for (std::size_t i = 1U; i < args.size(); i++) {
|
||||
parameters +=
|
||||
(parameters.empty() ? args.at(i) : " " + std::string(args.at(i)));
|
||||
}
|
||||
|
||||
char full_path[MAX_PATH] = {0};
|
||||
|
Loading…
x
Reference in New Issue
Block a user