Compare commits
21 Commits
39d644e115
...
cd538566d3
Author | SHA1 | Date | |
---|---|---|---|
cd538566d3 | |||
f0fe0a1962 | |||
68e3f6fc00 | |||
a23adf6db6 | |||
da5752e971 | |||
40682e37c0 | |||
cbd36efd91 | |||
96c712ae9c | |||
28065c2c8e | |||
9677ebb44e | |||
172ea8bc00 | |||
d2ec6f1f10 | |||
bc7a74e432 | |||
8561278539 | |||
f932799efa | |||
67dedc3fb5 | |||
7120856407 | |||
a1b138ccd1 | |||
d192904f8c | |||
0bd7070ec5 | |||
63ca3089da |
@ -1,15 +1,15 @@
|
||||
set(BINUTILS_VERSION 2.41)
|
||||
set(BOOST2_MAJOR_VERSION 1)
|
||||
set(BOOST2_MINOR_VERSION 76)
|
||||
set(BOOST2_PATCH_VERSION 0)
|
||||
set(BOOST_MAJOR_VERSION 1)
|
||||
set(BOOST_MINOR_VERSION 85)
|
||||
set(BOOST_PATCH_VERSION 0)
|
||||
set(BOOST2_MAJOR_VERSION 1)
|
||||
set(BOOST2_MINOR_VERSION 76)
|
||||
set(BOOST2_PATCH_VERSION 0)
|
||||
set(CPP_HTTPLIB_VERSION 0.16.3)
|
||||
set(CURL2_VERSION 8_9_1)
|
||||
set(CURL_VERSION 8.9.1)
|
||||
set(EXPAT2_VERSION 2_6_2)
|
||||
set(CURL2_VERSION 8_9_1)
|
||||
set(EXPAT_VERSION 2.6.2)
|
||||
set(EXPAT2_VERSION 2_6_2)
|
||||
set(GCC_VERSION 14.2.0)
|
||||
set(GTEST_VERSION 1.15.2)
|
||||
set(ICU_VERSION 75-1)
|
||||
@ -21,7 +21,7 @@ set(OPENSSL_VERSION 3.3.1)
|
||||
set(PKG_CONFIG_VERSION 0.29.2)
|
||||
set(PUGIXML_VERSION 1.14)
|
||||
set(SPDLOG_VERSION 1.14.1)
|
||||
set(SQLITE2_VERSION 3.46.1)
|
||||
set(SQLITE_VERSION 3460100)
|
||||
set(SQLITE2_VERSION 3.46.1)
|
||||
set(STDUUID_VERSION 1.2.3)
|
||||
set(ZLIB_VERSION 1.3.1)
|
||||
|
@ -572,8 +572,8 @@ RUN if [ -f "/3rd_party/flac-${MY_FLAC_VERSION}.tar.gz" ]; then \
|
||||
&& cd build \
|
||||
&& cmake .. \
|
||||
-DBUILD_DOCS=OFF \
|
||||
-DBUILD_EXAMPLES=ON \
|
||||
-DBUILD_PROGRAMS=ON \
|
||||
-DBUILD_EXAMPLES=OFF \
|
||||
-DBUILD_PROGRAMS=OFF \
|
||||
-DBUILD_SHARED_LIBS=ON \
|
||||
-DBUILD_STATIC_LIBS=ON \
|
||||
-DBUILD_TESTING=OFF \
|
||||
|
@ -30,26 +30,26 @@
|
||||
namespace repertory {
|
||||
class app_config final {
|
||||
public:
|
||||
[[nodiscard]] static auto
|
||||
default_agent_name(const provider_type &prov) -> std::string;
|
||||
[[nodiscard]] static auto default_agent_name(const provider_type &prov)
|
||||
-> std::string;
|
||||
|
||||
[[nodiscard]] static auto
|
||||
default_api_port(const provider_type &prov) -> std::uint16_t;
|
||||
[[nodiscard]] static auto default_api_port(const provider_type &prov)
|
||||
-> std::uint16_t;
|
||||
|
||||
[[nodiscard]] static auto
|
||||
default_data_directory(const provider_type &prov) -> std::string;
|
||||
[[nodiscard]] static auto default_data_directory(const provider_type &prov)
|
||||
-> std::string;
|
||||
|
||||
[[nodiscard]] static auto
|
||||
default_remote_port(const provider_type &prov) -> std::uint16_t;
|
||||
[[nodiscard]] static auto default_remote_port(const provider_type &prov)
|
||||
-> std::uint16_t;
|
||||
|
||||
[[nodiscard]] static auto
|
||||
default_rpc_port(const provider_type &prov) -> std::uint16_t;
|
||||
[[nodiscard]] static auto default_rpc_port(const provider_type &prov)
|
||||
-> std::uint16_t;
|
||||
|
||||
[[nodiscard]] static auto
|
||||
get_provider_display_name(const provider_type &prov) -> std::string;
|
||||
[[nodiscard]] static auto get_provider_display_name(const provider_type &prov)
|
||||
-> std::string;
|
||||
|
||||
[[nodiscard]] static auto
|
||||
get_provider_name(const provider_type &prov) -> std::string;
|
||||
[[nodiscard]] static auto get_provider_name(const provider_type &prov)
|
||||
-> std::string;
|
||||
|
||||
public:
|
||||
app_config(const provider_type &prov, std::string_view data_directory = "");
|
||||
@ -70,7 +70,7 @@ private:
|
||||
bool enable_max_cache_size_;
|
||||
#if defined(_WIN32)
|
||||
bool enable_mount_manager_;
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
bool enable_remote_mount_;
|
||||
encrypt_config encrypt_config_;
|
||||
event_level event_level_;
|
||||
@ -98,7 +98,7 @@ private:
|
||||
std::string cache_directory_;
|
||||
host_config hc_;
|
||||
s3_config s3_config_;
|
||||
sia_config sia_config_{"default"};
|
||||
sia_config sia_config_{};
|
||||
std::uint64_t version_{REPERTORY_CONFIG_VERSION};
|
||||
std::string log_directory_;
|
||||
mutable std::recursive_mutex read_write_mutex_;
|
||||
@ -110,10 +110,9 @@ private:
|
||||
template <typename dest>
|
||||
auto get_value(const json &json_document, const std::string &name, dest &dst,
|
||||
bool &success_flag) -> bool {
|
||||
constexpr const auto *function_name =
|
||||
static_cast<const char *>(__FUNCTION__);
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto ret = false;
|
||||
auto ret{false};
|
||||
try {
|
||||
if (json_document.find(name) != json_document.end()) {
|
||||
dst = json_document[name].get<dest>();
|
||||
@ -132,7 +131,7 @@ private:
|
||||
|
||||
template <typename dest, typename source>
|
||||
auto set_value(dest &dst, const source &src) -> bool {
|
||||
auto ret = false;
|
||||
auto ret{false};
|
||||
recur_mutex_lock lock(read_write_mutex_);
|
||||
if (dst != src) {
|
||||
dst = src;
|
||||
|
@ -357,9 +357,7 @@ auto app_config::get_provider_name(const provider_type &prov) -> std::string {
|
||||
}
|
||||
|
||||
auto app_config::get_value_by_name(const std::string &name) -> std::string {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (name == "ApiAuth") {
|
||||
@ -516,9 +514,7 @@ auto app_config::get_value_by_name(const std::string &name) -> std::string {
|
||||
}
|
||||
|
||||
auto app_config::load() -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto ret{false};
|
||||
|
||||
@ -684,9 +680,7 @@ auto app_config::load() -> bool {
|
||||
}
|
||||
|
||||
void app_config::save() {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = get_config_file_path();
|
||||
recur_mutex_lock lock(read_write_mutex_);
|
||||
@ -733,9 +727,7 @@ void app_config::set_is_remote_mount(bool is_remote_mount) {
|
||||
|
||||
auto app_config::set_value_by_name(const std::string &name,
|
||||
const std::string &value) -> std::string {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (name == "ApiAuth") {
|
||||
@ -773,7 +765,7 @@ auto app_config::set_value_by_name(const std::string &name,
|
||||
}
|
||||
if (name == "EnableMountManager") {
|
||||
set_enable_mount_manager(utils::string::to_bool(value));
|
||||
return std::to_string(get_enable_mount_manager());
|
||||
return utils::string::from_bool(get_enable_mount_manager());
|
||||
#endif
|
||||
}
|
||||
if (name == "EncryptConfig.EncryptionToken") {
|
||||
|
@ -41,9 +41,7 @@ void client_pool::pool::execute(
|
||||
}
|
||||
|
||||
client_pool::pool::pool(std::uint8_t pool_size) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
event_system::instance().raise<service_started>("client_pool");
|
||||
|
||||
|
@ -219,9 +219,7 @@ auto packet::decode(remote::file_info &val) -> packet::error_type {
|
||||
}
|
||||
|
||||
auto packet::decode_json(packet &response, json &json_data) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string data;
|
||||
auto ret = response.decode(data);
|
||||
@ -239,9 +237,7 @@ auto packet::decode_json(packet &response, json &json_data) -> int {
|
||||
}
|
||||
|
||||
auto packet::decrypt(std::string_view token) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto ret = utils::from_api_error(api_error::success);
|
||||
try {
|
||||
@ -523,9 +519,7 @@ void packet::encode_top(remote::file_info val) {
|
||||
}
|
||||
|
||||
void packet::encrypt(std::string_view token) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
data_buffer result;
|
||||
|
@ -76,9 +76,7 @@ void packet_client::close_all() {
|
||||
}
|
||||
|
||||
void packet_client::connect(client &cli) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
resolve();
|
||||
@ -122,8 +120,8 @@ void packet_client::put_client(std::shared_ptr<client> &cli) {
|
||||
}
|
||||
}
|
||||
|
||||
auto packet_client::read_packet(client &cli,
|
||||
packet &response) -> packet::error_type {
|
||||
auto packet_client::read_packet(client &cli, packet &response)
|
||||
-> packet::error_type {
|
||||
data_buffer buffer(sizeof(std::uint32_t));
|
||||
const auto read_buffer = [&]() {
|
||||
std::uint32_t offset{};
|
||||
@ -161,8 +159,8 @@ void packet_client::resolve() {
|
||||
}
|
||||
}
|
||||
|
||||
auto packet_client::send(std::string_view method,
|
||||
std::uint32_t &service_flags) -> packet::error_type {
|
||||
auto packet_client::send(std::string_view method, std::uint32_t &service_flags)
|
||||
-> packet::error_type {
|
||||
packet request;
|
||||
return send(method, request, service_flags);
|
||||
}
|
||||
@ -174,11 +172,9 @@ auto packet_client::send(std::string_view method, packet &request,
|
||||
}
|
||||
|
||||
auto packet_client::send(std::string_view method, packet &request,
|
||||
packet &response,
|
||||
std::uint32_t &service_flags) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
packet &response, std::uint32_t &service_flags)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto success = false;
|
||||
packet::error_type ret = utils::from_api_error(api_error::error);
|
||||
|
@ -66,9 +66,7 @@ void packet_server::add_client(connection &conn, const std::string &client_id) {
|
||||
}
|
||||
|
||||
void packet_server::initialize(const uint16_t &port, uint8_t pool_size) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
pool_size = std::max(uint8_t(1U), pool_size);
|
||||
server_thread_ = std::make_unique<std::thread>([this, port, pool_size]() {
|
||||
@ -105,9 +103,7 @@ void packet_server::listen_for_connection(tcp::acceptor &acceptor) {
|
||||
|
||||
void packet_server::on_accept(std::shared_ptr<connection> conn,
|
||||
boost::system::error_code err) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
listen_for_connection(conn->acceptor);
|
||||
if (err) {
|
||||
@ -125,9 +121,7 @@ void packet_server::on_accept(std::shared_ptr<connection> conn,
|
||||
}
|
||||
|
||||
void packet_server::read_header(std::shared_ptr<connection> conn) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
conn->buffer.resize(sizeof(std::uint32_t));
|
||||
boost::asio::async_read(
|
||||
@ -148,9 +142,7 @@ void packet_server::read_header(std::shared_ptr<connection> conn) {
|
||||
|
||||
void packet_server::read_packet(std::shared_ptr<connection> conn,
|
||||
std::uint32_t data_size) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
const auto read_buffer = [&]() {
|
||||
@ -246,9 +238,7 @@ void packet_server::remove_client(connection &conn) {
|
||||
void packet_server::send_response(std::shared_ptr<connection> conn,
|
||||
const packet::error_type &result,
|
||||
packet &response) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
response.encode_top(result);
|
||||
response.encode_top(PACKET_SERVICE_FLAGS);
|
||||
|
@ -26,17 +26,17 @@
|
||||
|
||||
namespace repertory {
|
||||
#if !defined(_WIN32)
|
||||
auto directory_iterator::fill_buffer(
|
||||
const remote::file_offset &offset, fuse_fill_dir_t filler_function,
|
||||
void *buffer, populate_stat_callback populate_stat) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto directory_iterator::fill_buffer(const remote::file_offset &offset,
|
||||
fuse_fill_dir_t filler_function,
|
||||
void *buffer,
|
||||
populate_stat_callback populate_stat)
|
||||
-> int {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (offset < items_.size()) {
|
||||
try {
|
||||
std::string item_name;
|
||||
struct stat st {};
|
||||
struct stat st{};
|
||||
struct stat *pst = nullptr;
|
||||
switch (offset) {
|
||||
case 0: {
|
||||
|
@ -34,9 +34,7 @@
|
||||
namespace repertory {
|
||||
auto eviction::check_minimum_requirements(const std::string &file_path)
|
||||
-> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto opt_size = utils::file::file{file_path}.size();
|
||||
if (not opt_size.has_value()) {
|
||||
@ -77,9 +75,7 @@ auto eviction::get_filtered_cached_files() -> std::deque<std::string> {
|
||||
}
|
||||
|
||||
void eviction::service_function() {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto should_evict = true;
|
||||
|
||||
|
@ -101,9 +101,7 @@ fuse_base::fuse_base(app_config &config) : config_(config) {
|
||||
fuse_base::~fuse_base() { E_CONSUMER_RELEASE(); }
|
||||
|
||||
auto fuse_base::access_(const char *path, int mask) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -113,9 +111,7 @@ auto fuse_base::access_(const char *path, int mask) -> int {
|
||||
|
||||
#if defined(__APPLE__)
|
||||
auto fuse_base::chflags_(const char *path, uint32_t flags) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -125,11 +121,9 @@ auto fuse_base::chflags_(const char *path, uint32_t flags) -> int {
|
||||
#endif // __APPLE__
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto fuse_base::chmod_(const char *path, mode_t mode,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto fuse_base::chmod_(const char *path, mode_t mode, struct fuse_file_info *fi)
|
||||
-> int {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -138,9 +132,7 @@ auto fuse_base::chmod_(const char *path, mode_t mode,
|
||||
}
|
||||
#else
|
||||
auto fuse_base::chmod_(const char *path, mode_t mode) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -152,9 +144,7 @@ auto fuse_base::chmod_(const char *path, mode_t mode) -> int {
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto fuse_base::chown_(const char *path, uid_t uid, gid_t gid,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -163,9 +153,7 @@ auto fuse_base::chown_(const char *path, uid_t uid, gid_t gid,
|
||||
}
|
||||
#else
|
||||
auto fuse_base::chown_(const char *path, uid_t uid, gid_t gid) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -176,9 +164,7 @@ auto fuse_base::chown_(const char *path, uid_t uid, gid_t gid) -> int {
|
||||
|
||||
auto fuse_base::create_(const char *path, mode_t mode,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -187,9 +173,7 @@ auto fuse_base::create_(const char *path, mode_t mode,
|
||||
}
|
||||
|
||||
void fuse_base::destroy_(void *ptr) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
execute_void_callback(function_name, [&]() { instance().destroy_impl(ptr); });
|
||||
}
|
||||
@ -205,7 +189,7 @@ void fuse_base::display_options(
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
fuse_cmdline_help();
|
||||
#else
|
||||
struct fuse_operations fuse_ops {};
|
||||
struct fuse_operations fuse_ops{};
|
||||
fuse_main(args.size(),
|
||||
reinterpret_cast<char **>(const_cast<char **>(args.data())),
|
||||
&fuse_ops, nullptr);
|
||||
@ -215,7 +199,7 @@ void fuse_base::display_options(
|
||||
}
|
||||
|
||||
void fuse_base::display_version_information(std::vector<const char *> args) {
|
||||
struct fuse_operations fuse_ops {};
|
||||
struct fuse_operations fuse_ops{};
|
||||
fuse_main(static_cast<int>(args.size()),
|
||||
reinterpret_cast<char **>(const_cast<char **>(args.data())),
|
||||
&fuse_ops, nullptr);
|
||||
@ -264,9 +248,7 @@ auto fuse_base::execute_void_pointer_callback(std::string_view function_name,
|
||||
|
||||
auto fuse_base::fallocate_(const char *path, int mode, off_t offset,
|
||||
off_t length, struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -278,9 +260,7 @@ auto fuse_base::fallocate_(const char *path, int mode, off_t offset,
|
||||
#if FUSE_USE_VERSION < 30
|
||||
auto fuse_base::fgetattr_(const char *path, struct stat *st,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -292,9 +272,7 @@ auto fuse_base::fgetattr_(const char *path, struct stat *st,
|
||||
#if defined(__APPLE__)
|
||||
auto fuse_base::fsetattr_x_(const char *path, struct setattr_x *attr,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -305,9 +283,7 @@ auto fuse_base::fsetattr_x_(const char *path, struct setattr_x *attr,
|
||||
|
||||
auto fuse_base::fsync_(const char *path, int datasync,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -318,9 +294,7 @@ auto fuse_base::fsync_(const char *path, int datasync,
|
||||
#if FUSE_USE_VERSION < 30
|
||||
auto fuse_base::ftruncate_(const char *path, off_t size,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -332,9 +306,7 @@ auto fuse_base::ftruncate_(const char *path, off_t size,
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto fuse_base::getattr_(const char *path, struct stat *st,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -343,9 +315,7 @@ auto fuse_base::getattr_(const char *path, struct stat *st,
|
||||
}
|
||||
#else
|
||||
auto fuse_base::getattr_(const char *path, struct stat *st) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -357,9 +327,7 @@ auto fuse_base::getattr_(const char *path, struct stat *st) -> int {
|
||||
#if defined(__APPLE__)
|
||||
auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime,
|
||||
struct timespec *crtime) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -369,11 +337,9 @@ auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime,
|
||||
#endif // __APPLE__
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto fuse_base::init_(struct fuse_conn_info *conn,
|
||||
struct fuse_config *cfg) -> void * {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto fuse_base::init_(struct fuse_conn_info *conn, struct fuse_config *cfg)
|
||||
-> void * {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return execute_void_pointer_callback(function_name, [&]() -> void * {
|
||||
return instance().init_impl(conn, cfg);
|
||||
@ -381,9 +347,7 @@ auto fuse_base::init_(struct fuse_conn_info *conn,
|
||||
}
|
||||
#else
|
||||
auto fuse_base::init_(struct fuse_conn_info *conn) -> void * {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return execute_void_pointer_callback(
|
||||
function_name, [&]() -> void * { return instance().init_impl(conn); });
|
||||
@ -396,9 +360,7 @@ auto fuse_base::init_impl([[maybe_unused]] struct fuse_conn_info *conn,
|
||||
#else // FUSE_USE_VERSION < 30
|
||||
auto fuse_base::init_impl(struct fuse_conn_info *conn) -> void * {
|
||||
#endif // FUSE_USE_VERSION >= 30
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
#if defined(__APPLE__)
|
||||
conn->want |= FUSE_CAP_VOL_RENAME;
|
||||
@ -426,9 +388,7 @@ auto fuse_base::init_impl(struct fuse_conn_info *conn) -> void * {
|
||||
}
|
||||
|
||||
auto fuse_base::mkdir_(const char *path, mode_t mode) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -451,7 +411,7 @@ auto fuse_base::mount(std::vector<std::string> args) -> int {
|
||||
|
||||
char *mount_location{nullptr};
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
struct fuse_cmdline_opts opts {};
|
||||
struct fuse_cmdline_opts opts{};
|
||||
fuse_parse_cmdline(&fa, &opts);
|
||||
mount_location = opts.mountpoint;
|
||||
#else
|
||||
@ -485,9 +445,7 @@ auto fuse_base::mount(std::vector<std::string> args) -> int {
|
||||
}
|
||||
|
||||
auto fuse_base::open_(const char *path, struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -496,9 +454,7 @@ auto fuse_base::open_(const char *path, struct fuse_file_info *fi) -> int {
|
||||
}
|
||||
|
||||
auto fuse_base::opendir_(const char *path, struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -508,9 +464,7 @@ auto fuse_base::opendir_(const char *path, struct fuse_file_info *fi) -> int {
|
||||
|
||||
auto fuse_base::read_(const char *path, char *buffer, size_t read_size,
|
||||
off_t read_offset, struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::size_t bytes_read{};
|
||||
const auto res = instance().execute_callback(
|
||||
@ -526,11 +480,9 @@ auto fuse_base::read_(const char *path, char *buffer, size_t read_size,
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto fuse_base::readdir_(const char *path, void *buf,
|
||||
fuse_fill_dir_t fuse_fill_dir, off_t offset,
|
||||
struct fuse_file_info *fi,
|
||||
fuse_readdir_flags flags) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
struct fuse_file_info *fi, fuse_readdir_flags flags)
|
||||
-> int {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -542,9 +494,7 @@ auto fuse_base::readdir_(const char *path, void *buf,
|
||||
auto fuse_base::readdir_(const char *path, void *buf,
|
||||
fuse_fill_dir_t fuse_fill_dir, off_t offset,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -555,9 +505,7 @@ auto fuse_base::readdir_(const char *path, void *buf,
|
||||
#endif
|
||||
|
||||
auto fuse_base::release_(const char *path, struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -565,11 +513,9 @@ auto fuse_base::release_(const char *path, struct fuse_file_info *fi) -> int {
|
||||
});
|
||||
}
|
||||
|
||||
auto fuse_base::releasedir_(const char *path,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto fuse_base::releasedir_(const char *path, struct fuse_file_info *fi)
|
||||
-> int {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -578,11 +524,9 @@ auto fuse_base::releasedir_(const char *path,
|
||||
}
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto fuse_base::rename_(const char *from, const char *to,
|
||||
unsigned int flags) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto fuse_base::rename_(const char *from, const char *to, unsigned int flags)
|
||||
-> int {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, from, to,
|
||||
@ -593,9 +537,7 @@ auto fuse_base::rename_(const char *from, const char *to,
|
||||
}
|
||||
#else
|
||||
auto fuse_base::rename_(const char *from, const char *to) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, from, to,
|
||||
@ -607,9 +549,7 @@ auto fuse_base::rename_(const char *from, const char *to) -> int {
|
||||
#endif
|
||||
|
||||
auto fuse_base::rmdir_(const char *path) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -621,9 +561,7 @@ auto fuse_base::rmdir_(const char *path) -> int {
|
||||
#if defined(__APPLE__)
|
||||
auto fuse_base::getxattr_(const char *path, const char *name, char *value,
|
||||
size_t size, uint32_t position) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
int attribute_size = 0;
|
||||
const auto res = instance().execute_callback(
|
||||
@ -637,9 +575,7 @@ auto fuse_base::getxattr_(const char *path, const char *name, char *value,
|
||||
#else // __APPLE__
|
||||
auto fuse_base::getxattr_(const char *path, const char *name, char *value,
|
||||
size_t size) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
int attribute_size = 0;
|
||||
const auto res = instance().execute_callback(
|
||||
@ -653,9 +589,7 @@ auto fuse_base::getxattr_(const char *path, const char *name, char *value,
|
||||
#endif // __APPLE__
|
||||
|
||||
auto fuse_base::listxattr_(const char *path, char *buffer, size_t size) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
int required_size = 0;
|
||||
bool return_size = false;
|
||||
@ -775,9 +709,7 @@ void fuse_base::raise_fuse_event(std::string_view function_name,
|
||||
}
|
||||
|
||||
auto fuse_base::removexattr_(const char *path, const char *name) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -788,9 +720,7 @@ auto fuse_base::removexattr_(const char *path, const char *name) -> int {
|
||||
#if defined(__APPLE__)
|
||||
auto fuse_base::setxattr_(const char *path, const char *name, const char *value,
|
||||
size_t size, int flags, uint32_t position) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto res = instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -806,9 +736,7 @@ auto fuse_base::setxattr_(const char *path, const char *name, const char *value,
|
||||
#else // __APPLE__
|
||||
auto fuse_base::setxattr_(const char *path, const char *name, const char *value,
|
||||
size_t size, int flags) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto res = instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -832,9 +760,7 @@ void fuse_base::shutdown() {
|
||||
|
||||
#if defined(__APPLE__)
|
||||
auto fuse_base::setattr_x_(const char *path, struct setattr_x *attr) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -842,11 +768,9 @@ auto fuse_base::setattr_x_(const char *path, struct setattr_x *attr) -> int {
|
||||
});
|
||||
}
|
||||
|
||||
auto fuse_base::setbkuptime_(const char *path,
|
||||
const struct timespec *bkuptime) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto fuse_base::setbkuptime_(const char *path, const struct timespec *bkuptime)
|
||||
-> int {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -854,11 +778,9 @@ auto fuse_base::setbkuptime_(const char *path,
|
||||
});
|
||||
}
|
||||
|
||||
auto fuse_base::setchgtime_(const char *path,
|
||||
const struct timespec *chgtime) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto fuse_base::setchgtime_(const char *path, const struct timespec *chgtime)
|
||||
-> int {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -866,11 +788,9 @@ auto fuse_base::setchgtime_(const char *path,
|
||||
});
|
||||
}
|
||||
|
||||
auto fuse_base::setcrtime_(const char *path,
|
||||
const struct timespec *crtime) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto fuse_base::setcrtime_(const char *path, const struct timespec *crtime)
|
||||
-> int {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -879,9 +799,7 @@ auto fuse_base::setcrtime_(const char *path,
|
||||
}
|
||||
|
||||
auto fuse_base::setvolname_(const char *volname) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, volname, [&](std::string api_path) -> api_error {
|
||||
@ -890,9 +808,7 @@ auto fuse_base::setvolname_(const char *volname) -> int {
|
||||
}
|
||||
|
||||
auto fuse_base::statfs_x_(const char *path, struct statfs *stbuf) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -901,9 +817,7 @@ auto fuse_base::statfs_x_(const char *path, struct statfs *stbuf) -> int {
|
||||
}
|
||||
#else // __APPLE__
|
||||
auto fuse_base::statfs_(const char *path, struct statvfs *stbuf) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -915,9 +829,7 @@ auto fuse_base::statfs_(const char *path, struct statvfs *stbuf) -> int {
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto fuse_base::truncate_(const char *path, off_t size,
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -926,9 +838,7 @@ auto fuse_base::truncate_(const char *path, off_t size,
|
||||
}
|
||||
#else
|
||||
auto fuse_base::truncate_(const char *path, off_t size) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -938,9 +848,7 @@ auto fuse_base::truncate_(const char *path, off_t size) -> int {
|
||||
#endif
|
||||
|
||||
auto fuse_base::unlink_(const char *path) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -965,9 +873,7 @@ auto fuse_base::unmount(const std::string &mount_location) -> int {
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto fuse_base::utimens_(const char *path, const struct timespec tv[2],
|
||||
struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -976,9 +882,7 @@ auto fuse_base::utimens_(const char *path, const struct timespec tv[2],
|
||||
}
|
||||
#else
|
||||
auto fuse_base::utimens_(const char *path, const struct timespec tv[2]) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
@ -989,9 +893,7 @@ auto fuse_base::utimens_(const char *path, const struct timespec tv[2]) -> int {
|
||||
|
||||
auto fuse_base::write_(const char *path, const char *buffer, size_t write_size,
|
||||
off_t write_offset, struct fuse_file_info *fi) -> int {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::size_t bytes_written{};
|
||||
|
||||
|
@ -76,8 +76,8 @@ auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid,
|
||||
struct fuse_file_info * /*file_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto fuse_drive::chown_impl(std::string api_path, uid_t uid,
|
||||
gid_t gid) -> api_error {
|
||||
auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid)
|
||||
-> api_error {
|
||||
#endif
|
||||
return check_and_perform(api_path, X_OK,
|
||||
[&](api_meta_map &meta) -> api_error {
|
||||
@ -206,9 +206,7 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode,
|
||||
}
|
||||
|
||||
void fuse_drive::destroy_impl(void *ptr) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
event_system::instance().raise<drive_unmount_pending>(get_mount_location());
|
||||
|
||||
@ -394,9 +392,7 @@ auto fuse_drive::get_directory_item_count(const std::string &api_path) const
|
||||
|
||||
auto fuse_drive::get_directory_items(const std::string &api_path) const
|
||||
-> directory_item_list {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
directory_item_list list{};
|
||||
auto res = provider_.get_directory_items(api_path, list);
|
||||
@ -410,9 +406,7 @@ auto fuse_drive::get_directory_items(const std::string &api_path) const
|
||||
|
||||
auto fuse_drive::get_file_size(const std::string &api_path) const
|
||||
-> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::uint64_t file_size{};
|
||||
auto res = provider_.get_file_size(api_path, file_size);
|
||||
@ -446,8 +440,8 @@ auto fuse_drive::getattr_impl(std::string api_path, struct stat *st,
|
||||
struct fuse_file_info * /*file_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto fuse_drive::getattr_impl(std::string api_path,
|
||||
struct stat *st) -> api_error {
|
||||
auto fuse_drive::getattr_impl(std::string api_path, struct stat *st)
|
||||
-> api_error {
|
||||
#endif
|
||||
const auto parent = utils::path::get_parent_api_path(api_path);
|
||||
|
||||
@ -529,14 +523,12 @@ auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime,
|
||||
#endif // __APPLE__
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto fuse_drive::init_impl(struct fuse_conn_info *conn,
|
||||
struct fuse_config *cfg) -> void * {
|
||||
auto fuse_drive::init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg)
|
||||
-> void * {
|
||||
#else
|
||||
void *fuse_drive::init_impl(struct fuse_conn_info *conn) {
|
||||
#endif
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto *ret = fuse_drive_base::init_impl(conn, cfg);
|
||||
@ -605,9 +597,7 @@ auto fuse_drive::is_processing(const std::string &api_path) const -> bool {
|
||||
}
|
||||
|
||||
auto fuse_drive::mkdir_impl(std::string api_path, mode_t mode) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto res = check_parent_access(api_path, W_OK | X_OK);
|
||||
if (res != api_error::success) {
|
||||
@ -759,8 +749,9 @@ auto fuse_drive::release_impl(std::string /*api_path*/,
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto fuse_drive::releasedir_impl(
|
||||
std::string /*api_path*/, struct fuse_file_info *file_info) -> api_error {
|
||||
auto fuse_drive::releasedir_impl(std::string /*api_path*/,
|
||||
struct fuse_file_info *file_info)
|
||||
-> api_error {
|
||||
auto iter = directory_cache_->get_directory(file_info->fh);
|
||||
if (iter == nullptr) {
|
||||
return api_error::invalid_handle;
|
||||
@ -778,8 +769,8 @@ auto fuse_drive::rename_directory(const std::string &from_api_path,
|
||||
}
|
||||
|
||||
auto fuse_drive::rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path,
|
||||
bool overwrite) -> int {
|
||||
const std::string &to_api_path, bool overwrite)
|
||||
-> int {
|
||||
const auto res = fm_->rename_file(from_api_path, to_api_path, overwrite);
|
||||
errno = std::abs(utils::from_api_error(res));
|
||||
return (res == api_error::success) ? 0 : -1;
|
||||
@ -789,8 +780,8 @@ auto fuse_drive::rename_file(const std::string &from_api_path,
|
||||
auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path,
|
||||
unsigned int /*flags*/) -> api_error {
|
||||
#else
|
||||
auto fuse_drive::rename_impl(std::string from_api_path,
|
||||
std::string to_api_path) -> api_error {
|
||||
auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path)
|
||||
-> api_error {
|
||||
#endif
|
||||
auto res = check_parent_access(to_api_path, W_OK | X_OK);
|
||||
if (res != api_error::success) {
|
||||
@ -897,15 +888,15 @@ auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
|
||||
}
|
||||
#else // __APPLE__
|
||||
auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
|
||||
char *value, size_t size,
|
||||
int &attribute_size) -> api_error {
|
||||
char *value, size_t size, int &attribute_size)
|
||||
-> api_error {
|
||||
return getxattr_common(api_path, name, value, size, attribute_size, nullptr);
|
||||
}
|
||||
#endif // __APPLE__
|
||||
|
||||
auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
|
||||
int &required_size,
|
||||
bool &return_size) -> api_error {
|
||||
int &required_size, bool &return_size)
|
||||
-> api_error {
|
||||
const auto check_size = (size == 0);
|
||||
|
||||
auto res = check_parent_access(api_path, X_OK);
|
||||
@ -944,8 +935,8 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
|
||||
return res;
|
||||
}
|
||||
|
||||
auto fuse_drive::removexattr_impl(std::string api_path,
|
||||
const char *name) -> api_error {
|
||||
auto fuse_drive::removexattr_impl(std::string api_path, const char *name)
|
||||
-> api_error {
|
||||
std::string attribute_name;
|
||||
#if defined(__APPLE__)
|
||||
auto res = parse_xattr_parameters(name, 0, attribute_name, api_path);
|
||||
@ -973,8 +964,8 @@ auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
|
||||
uint32_t position) -> api_error {
|
||||
#else // __APPLE__
|
||||
auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
|
||||
const char *value, size_t size,
|
||||
int flags) -> api_error {
|
||||
const char *value, size_t size, int flags)
|
||||
-> api_error {
|
||||
#endif
|
||||
std::string attribute_name;
|
||||
#if defined(__APPLE__)
|
||||
@ -1039,9 +1030,7 @@ auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
|
||||
void fuse_drive::set_item_meta(const std::string &api_path,
|
||||
const std::string &key,
|
||||
const std::string &value) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto res = provider_.set_item_meta(api_path, key, value);
|
||||
if (res != api_error::success) {
|
||||
@ -1051,8 +1040,8 @@ void fuse_drive::set_item_meta(const std::string &api_path,
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
auto fuse_drive::setattr_x_impl(std::string api_path,
|
||||
struct setattr_x *attr) -> api_error {
|
||||
auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr)
|
||||
-> api_error {
|
||||
bool exists{};
|
||||
auto res = provider_.is_file(api_path, exists);
|
||||
if (res != api_error::success) {
|
||||
@ -1106,7 +1095,7 @@ auto fuse_drive::setattr_x_impl(std::string api_path,
|
||||
ts[0].tv_sec = attr->acctime.tv_sec;
|
||||
ts[0].tv_nsec = attr->acctime.tv_nsec;
|
||||
} else {
|
||||
struct timeval tv {};
|
||||
struct timeval tv{};
|
||||
gettimeofday(&tv, NULL);
|
||||
ts[0].tv_sec = tv.tv_sec;
|
||||
ts[0].tv_nsec = tv.tv_usec * 1000;
|
||||
@ -1151,8 +1140,9 @@ auto fuse_drive::setattr_x_impl(std::string api_path,
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto fuse_drive::setbkuptime_impl(
|
||||
std::string api_path, const struct timespec *bkuptime) -> api_error {
|
||||
auto fuse_drive::setbkuptime_impl(std::string api_path,
|
||||
const struct timespec *bkuptime)
|
||||
-> api_error {
|
||||
return check_and_perform(
|
||||
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
||||
const auto nanos = bkuptime->tv_nsec +
|
||||
@ -1188,8 +1178,8 @@ auto fuse_drive::setvolname_impl(const char * /*volname*/) -> api_error {
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto fuse_drive::statfs_x_impl(std::string /*api_path*/,
|
||||
struct statfs *stbuf) -> api_error {
|
||||
auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf)
|
||||
-> api_error {
|
||||
if (statfs(&config_.get_cache_directory()[0], stbuf) != 0) {
|
||||
return api_error::os_error;
|
||||
}
|
||||
@ -1214,8 +1204,8 @@ auto fuse_drive::statfs_x_impl(std::string /*api_path*/,
|
||||
return api_error::success;
|
||||
}
|
||||
#else // __APPLE__
|
||||
auto fuse_drive::statfs_impl(std::string /*api_path*/,
|
||||
struct statvfs *stbuf) -> api_error {
|
||||
auto fuse_drive::statfs_impl(std::string /*api_path*/, struct statvfs *stbuf)
|
||||
-> api_error {
|
||||
if (statvfs(config_.get_cache_directory().data(), stbuf) != 0) {
|
||||
return api_error::os_error;
|
||||
}
|
||||
@ -1296,8 +1286,8 @@ auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2],
|
||||
struct fuse_file_info * /*file_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto fuse_drive::utimens_impl(std::string api_path,
|
||||
const struct timespec tv[2]) -> api_error {
|
||||
auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2])
|
||||
-> api_error {
|
||||
#endif
|
||||
api_meta_map meta;
|
||||
auto res = provider_.get_item_meta(api_path, meta);
|
||||
@ -1368,9 +1358,7 @@ auto fuse_drive::write_impl(std::string /*api_path*/
|
||||
}
|
||||
|
||||
void fuse_drive::update_accessed_time(const std::string &api_path) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (atime_enabled_) {
|
||||
auto res = provider_.set_item_meta(
|
||||
|
@ -36,9 +36,7 @@ remote_client::remote_client(const app_config &config)
|
||||
|
||||
auto remote_client::fuse_access(const char *path, const std::int32_t &mask)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -48,11 +46,9 @@ auto remote_client::fuse_access(const char *path, const std::int32_t &mask)
|
||||
return packet_client_.send(function_name, request, service_flags);
|
||||
}
|
||||
|
||||
auto remote_client::fuse_chflags(const char *path,
|
||||
std::uint32_t flags) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_chflags(const char *path, std::uint32_t flags)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -64,9 +60,7 @@ auto remote_client::fuse_chflags(const char *path,
|
||||
|
||||
auto remote_client::fuse_chmod(const char *path, const remote::file_mode &mode)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -79,9 +73,7 @@ auto remote_client::fuse_chmod(const char *path, const remote::file_mode &mode)
|
||||
auto remote_client::fuse_chown(const char *path, const remote::user_id &uid,
|
||||
const remote::group_id &gid)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -93,9 +85,7 @@ auto remote_client::fuse_chown(const char *path, const remote::user_id &uid,
|
||||
}
|
||||
|
||||
auto remote_client::fuse_destroy() -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::uint32_t service_flags{};
|
||||
return packet_client_.send(function_name, service_flags);
|
||||
@ -114,12 +104,11 @@ std::int32_t &mode, const remote::file_offset &offset, const remote::file_offset
|
||||
return packetClient_.send(function_name, request, service_flags);
|
||||
}*/
|
||||
|
||||
auto remote_client::fuse_fgetattr(
|
||||
const char *path, remote::stat &st, bool &directory,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_fgetattr(const char *path, remote::stat &st,
|
||||
bool &directory,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -143,12 +132,11 @@ auto remote_client::fuse_fgetattr(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::fuse_fsetattr_x(
|
||||
const char *path, const remote::setattr_x &attr,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_fsetattr_x(const char *path,
|
||||
const remote::setattr_x &attr,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -162,9 +150,7 @@ auto remote_client::fuse_fsetattr_x(
|
||||
auto remote_client::fuse_fsync(const char *path, const std::int32_t &datasync,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -175,12 +161,11 @@ auto remote_client::fuse_fsync(const char *path, const std::int32_t &datasync,
|
||||
return packet_client_.send(function_name, request, service_flags);
|
||||
}
|
||||
|
||||
auto remote_client::fuse_ftruncate(
|
||||
const char *path, const remote::file_offset &size,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_ftruncate(const char *path,
|
||||
const remote::file_offset &size,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -193,9 +178,7 @@ auto remote_client::fuse_ftruncate(
|
||||
|
||||
auto remote_client::fuse_getattr(const char *path, remote::stat &st,
|
||||
bool &directory) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -262,12 +245,11 @@ response.CurrentPointer(), static_cast<std::size_t>(size2));
|
||||
return ret;
|
||||
}*/
|
||||
|
||||
auto remote_client::fuse_getxtimes(
|
||||
const char *path, remote::file_time &bkuptime,
|
||||
remote::file_time &crtime) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_getxtimes(const char *path,
|
||||
remote::file_time &bkuptime,
|
||||
remote::file_time &crtime)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -285,9 +267,7 @@ auto remote_client::fuse_getxtimes(
|
||||
}
|
||||
|
||||
auto remote_client::fuse_init() -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::uint32_t service_flags{};
|
||||
return packet_client_.send(function_name, service_flags);
|
||||
@ -316,9 +296,7 @@ static_cast<std::size_t>(size2));
|
||||
|
||||
auto remote_client::fuse_mkdir(const char *path, const remote::file_mode &mode)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -330,9 +308,7 @@ auto remote_client::fuse_mkdir(const char *path, const remote::file_mode &mode)
|
||||
|
||||
auto remote_client::fuse_opendir(const char *path, remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -352,9 +328,7 @@ auto remote_client::fuse_create(const char *path, const remote::file_mode &mode,
|
||||
const remote::open_flags &flags,
|
||||
remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -375,9 +349,7 @@ auto remote_client::fuse_create(const char *path, const remote::file_mode &mode,
|
||||
auto remote_client::fuse_open(const char *path, const remote::open_flags &flags,
|
||||
remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -394,13 +366,12 @@ auto remote_client::fuse_open(const char *path, const remote::open_flags &flags,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::fuse_read(
|
||||
const char *path, char *buffer, const remote::file_size &read_size,
|
||||
const remote::file_offset &read_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_read(const char *path, char *buffer,
|
||||
const remote::file_size &read_size,
|
||||
const remote::file_offset &read_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -419,11 +390,9 @@ auto remote_client::fuse_read(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::fuse_rename(const char *from,
|
||||
const char *to) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_rename(const char *from, const char *to)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(from);
|
||||
@ -433,13 +402,12 @@ auto remote_client::fuse_rename(const char *from,
|
||||
return packet_client_.send(function_name, request, service_flags);
|
||||
}
|
||||
|
||||
auto remote_client::fuse_write(
|
||||
const char *path, const char *buffer, const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_write(const char *path, const char *buffer,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (write_size > std::numeric_limits<std::size_t>::max()) {
|
||||
return -ERANGE;
|
||||
@ -456,13 +424,12 @@ auto remote_client::fuse_write(
|
||||
return packet_client_.send(function_name, request, service_flags);
|
||||
}
|
||||
|
||||
auto remote_client::fuse_write_base64(
|
||||
const char *path, const char *buffer, const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_write_base64(const char *path, const char *buffer,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (write_size > std::numeric_limits<std::size_t>::max()) {
|
||||
return -ERANGE;
|
||||
@ -483,9 +450,7 @@ auto remote_client::fuse_readdir(const char *path,
|
||||
const remote::file_offset &offset,
|
||||
const remote::file_handle &handle,
|
||||
std::string &item_path) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -503,11 +468,10 @@ auto remote_client::fuse_readdir(const char *path,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::fuse_release(
|
||||
const char *path, const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_release(const char *path,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -517,11 +481,10 @@ auto remote_client::fuse_release(
|
||||
return packet_client_.send(function_name, request, service_flags);
|
||||
}
|
||||
|
||||
auto remote_client::fuse_releasedir(
|
||||
const char *path, const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_releasedir(const char *path,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -540,9 +503,7 @@ request.Encode(name);
|
||||
}*/
|
||||
|
||||
auto remote_client::fuse_rmdir(const char *path) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -553,9 +514,7 @@ auto remote_client::fuse_rmdir(const char *path) -> packet::error_type {
|
||||
|
||||
auto remote_client::fuse_setattr_x(const char *path, remote::setattr_x &attr)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -565,11 +524,10 @@ auto remote_client::fuse_setattr_x(const char *path, remote::setattr_x &attr)
|
||||
return packet_client_.send(function_name, request, service_flags);
|
||||
}
|
||||
|
||||
auto remote_client::fuse_setbkuptime(
|
||||
const char *path, const remote::file_time &bkuptime) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_setbkuptime(const char *path,
|
||||
const remote::file_time &bkuptime)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -579,11 +537,10 @@ auto remote_client::fuse_setbkuptime(
|
||||
return packet_client_.send(function_name, request, service_flags);
|
||||
}
|
||||
|
||||
auto remote_client::fuse_setchgtime(
|
||||
const char *path, const remote::file_time &chgtime) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_setchgtime(const char *path,
|
||||
const remote::file_time &chgtime)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -593,11 +550,10 @@ auto remote_client::fuse_setchgtime(
|
||||
return packet_client_.send(function_name, request, service_flags);
|
||||
}
|
||||
|
||||
auto remote_client::fuse_setcrtime(
|
||||
const char *path, const remote::file_time &crtime) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_setcrtime(const char *path,
|
||||
const remote::file_time &crtime)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -608,9 +564,7 @@ auto remote_client::fuse_setcrtime(
|
||||
}
|
||||
|
||||
auto remote_client::fuse_setvolname(const char *volname) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(volname);
|
||||
@ -651,9 +605,7 @@ request.encode(flags); request.encode(position);
|
||||
|
||||
auto remote_client::fuse_statfs(const char *path, std::uint64_t frsize,
|
||||
remote::statfs &st) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -672,9 +624,7 @@ auto remote_client::fuse_statfs(const char *path, std::uint64_t frsize,
|
||||
|
||||
auto remote_client::fuse_statfs_x(const char *path, std::uint64_t bsize,
|
||||
remote::statfs_x &st) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -691,11 +641,10 @@ auto remote_client::fuse_statfs_x(const char *path, std::uint64_t bsize,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::fuse_truncate(
|
||||
const char *path, const remote::file_offset &size) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::fuse_truncate(const char *path,
|
||||
const remote::file_offset &size)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -706,9 +655,7 @@ auto remote_client::fuse_truncate(
|
||||
}
|
||||
|
||||
auto remote_client::fuse_unlink(const char *path) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -718,11 +665,9 @@ auto remote_client::fuse_unlink(const char *path) -> packet::error_type {
|
||||
}
|
||||
|
||||
auto remote_client::fuse_utimens(const char *path, const remote::file_time *tv,
|
||||
std::uint64_t op0,
|
||||
std::uint64_t op1) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
std::uint64_t op0, std::uint64_t op1)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -734,11 +679,10 @@ auto remote_client::fuse_utimens(const char *path, const remote::file_time *tv,
|
||||
return packet_client_.send(function_name, request, service_flags);
|
||||
}
|
||||
|
||||
auto remote_client::json_create_directory_snapshot(
|
||||
const std::string &path, json &json_data) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::json_create_directory_snapshot(const std::string &path,
|
||||
json &json_data)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -757,9 +701,7 @@ auto remote_client::json_create_directory_snapshot(
|
||||
auto remote_client::json_read_directory_snapshot(
|
||||
const std::string &path, const remote::file_handle &handle,
|
||||
std::uint32_t page, json &json_data) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -778,11 +720,9 @@ auto remote_client::json_read_directory_snapshot(
|
||||
}
|
||||
|
||||
auto remote_client::json_release_directory_snapshot(
|
||||
const std::string &path,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
const std::string &path, const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
|
@ -40,8 +40,8 @@
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
namespace repertory::remote_fuse {
|
||||
auto remote_fuse_drive::access_impl(std::string api_path,
|
||||
int mask) -> api_error {
|
||||
auto remote_fuse_drive::access_impl(std::string api_path, int mask)
|
||||
-> api_error {
|
||||
return utils::to_api_error(
|
||||
remote_instance_->fuse_access(api_path.c_str(), mask));
|
||||
}
|
||||
@ -59,8 +59,8 @@ auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode,
|
||||
struct fuse_file_info * /*f_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto remote_fuse_drive::chmod_impl(std::string api_path,
|
||||
mode_t mode) -> api_error {
|
||||
auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode)
|
||||
-> api_error {
|
||||
#endif
|
||||
return utils::to_api_error(remote_instance_->fuse_chmod(
|
||||
api_path.c_str(), static_cast<remote::file_mode>(mode)));
|
||||
@ -71,8 +71,8 @@ auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid,
|
||||
struct fuse_file_info * /*f_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid,
|
||||
gid_t gid) -> api_error {
|
||||
auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid)
|
||||
-> api_error {
|
||||
#endif
|
||||
return utils::to_api_error(
|
||||
remote_instance_->fuse_chown(api_path.c_str(), uid, gid));
|
||||
@ -88,9 +88,7 @@ auto remote_fuse_drive::create_impl(std::string api_path, mode_t mode,
|
||||
}
|
||||
|
||||
void remote_fuse_drive::destroy_impl(void *ptr) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
event_system::instance().raise<drive_unmount_pending>(get_mount_location());
|
||||
|
||||
@ -118,9 +116,10 @@ void remote_fuse_drive::destroy_impl(void *ptr) {
|
||||
fuse_base::destroy_impl(ptr);
|
||||
}
|
||||
|
||||
auto remote_fuse_drive::fgetattr_impl(
|
||||
std::string api_path, struct stat *unix_st,
|
||||
struct fuse_file_info *f_info) -> api_error {
|
||||
auto remote_fuse_drive::fgetattr_impl(std::string api_path,
|
||||
struct stat *unix_st,
|
||||
struct fuse_file_info *f_info)
|
||||
-> api_error {
|
||||
remote::stat r_stat{};
|
||||
auto directory = false;
|
||||
|
||||
@ -181,8 +180,8 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st,
|
||||
struct fuse_file_info * /*f_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto remote_fuse_drive::getattr_impl(std::string api_path,
|
||||
struct stat *unix_st) -> api_error {
|
||||
auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st)
|
||||
-> api_error {
|
||||
#endif
|
||||
bool directory = false;
|
||||
remote::stat r_stat{};
|
||||
@ -227,9 +226,7 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn,
|
||||
#else
|
||||
auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * {
|
||||
#endif
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto *ret = fuse_base::init_impl(conn, cfg);
|
||||
@ -267,8 +264,8 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * {
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_fuse_drive::mkdir_impl(std::string api_path,
|
||||
mode_t mode) -> api_error {
|
||||
auto remote_fuse_drive::mkdir_impl(std::string api_path, mode_t mode)
|
||||
-> api_error {
|
||||
return utils::to_api_error(remote_instance_->fuse_mkdir(
|
||||
api_path.c_str(), static_cast<remote::file_mode>(mode)));
|
||||
}
|
||||
@ -290,8 +287,9 @@ auto remote_fuse_drive::open_impl(std::string api_path,
|
||||
f_info->fh));
|
||||
}
|
||||
|
||||
auto remote_fuse_drive::opendir_impl(
|
||||
std::string api_path, struct fuse_file_info *f_info) -> api_error {
|
||||
auto remote_fuse_drive::opendir_impl(std::string api_path,
|
||||
struct fuse_file_info *f_info)
|
||||
-> api_error {
|
||||
|
||||
return utils::to_api_error(
|
||||
remote_instance_->fuse_opendir(api_path.c_str(), f_info->fh));
|
||||
@ -380,14 +378,18 @@ auto remote_fuse_drive::read_impl(std::string api_path, char *buffer,
|
||||
}
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto remote_fuse_drive::readdir_impl(
|
||||
std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
|
||||
off_t offset, struct fuse_file_info *f_info,
|
||||
fuse_readdir_flags /*flags*/) -> api_error {
|
||||
auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
|
||||
fuse_fill_dir_t fuse_fill_dir,
|
||||
off_t offset,
|
||||
struct fuse_file_info *f_info,
|
||||
fuse_readdir_flags /*flags*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto remote_fuse_drive::readdir_impl(
|
||||
std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
|
||||
off_t offset, struct fuse_file_info *f_info) -> api_error {
|
||||
auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
|
||||
fuse_fill_dir_t fuse_fill_dir,
|
||||
off_t offset,
|
||||
struct fuse_file_info *f_info)
|
||||
-> api_error {
|
||||
#endif
|
||||
std::string item_path;
|
||||
int res = 0;
|
||||
@ -415,14 +417,16 @@ auto remote_fuse_drive::readdir_impl(
|
||||
return utils::to_api_error(res);
|
||||
}
|
||||
|
||||
auto remote_fuse_drive::release_impl(
|
||||
std::string api_path, struct fuse_file_info *f_info) -> api_error {
|
||||
auto remote_fuse_drive::release_impl(std::string api_path,
|
||||
struct fuse_file_info *f_info)
|
||||
-> api_error {
|
||||
return utils::to_api_error(
|
||||
remote_instance_->fuse_release(api_path.c_str(), f_info->fh));
|
||||
}
|
||||
|
||||
auto remote_fuse_drive::releasedir_impl(
|
||||
std::string api_path, struct fuse_file_info *f_info) -> api_error {
|
||||
auto remote_fuse_drive::releasedir_impl(std::string api_path,
|
||||
struct fuse_file_info *f_info)
|
||||
-> api_error {
|
||||
return utils::to_api_error(
|
||||
remote_instance_->fuse_releasedir(api_path.c_str(), f_info->fh));
|
||||
}
|
||||
@ -519,8 +523,8 @@ api_error remote_fuse_drive::statfs_x_impl(std::string api_path,
|
||||
return utils::to_api_error(res);
|
||||
}
|
||||
#else // __APPLE__
|
||||
auto remote_fuse_drive::statfs_impl(std::string api_path,
|
||||
struct statvfs *stbuf) -> api_error {
|
||||
auto remote_fuse_drive::statfs_impl(std::string api_path, struct statvfs *stbuf)
|
||||
-> api_error {
|
||||
auto res = statvfs(config_.get_data_directory().c_str(), stbuf);
|
||||
if (res == 0) {
|
||||
remote::statfs r_stat{};
|
||||
@ -547,8 +551,8 @@ auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size,
|
||||
struct fuse_file_info * /*f_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto remote_fuse_drive::truncate_impl(std::string api_path,
|
||||
off_t size) -> api_error {
|
||||
auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size)
|
||||
-> api_error {
|
||||
#endif
|
||||
return utils::to_api_error(remote_instance_->fuse_truncate(
|
||||
api_path.c_str(), static_cast<remote::file_offset>(size)));
|
||||
@ -559,9 +563,10 @@ auto remote_fuse_drive::unlink_impl(std::string api_path) -> api_error {
|
||||
}
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto remote_fuse_drive::utimens_impl(
|
||||
std::string api_path, const struct timespec tv[2],
|
||||
struct fuse_file_info * /*f_info*/) -> api_error {
|
||||
auto remote_fuse_drive::utimens_impl(std::string api_path,
|
||||
const struct timespec tv[2],
|
||||
struct fuse_file_info * /*f_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto remote_fuse_drive::utimens_impl(std::string api_path,
|
||||
const struct timespec tv[2]) -> api_error {
|
||||
|
@ -112,9 +112,7 @@ void remote_server::populate_file_info(const std::string &api_path,
|
||||
const UINT64 &file_size,
|
||||
const UINT32 &attributes,
|
||||
remote::file_info &file_info) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
api_meta_map meta{};
|
||||
const auto res = drive_.get_item_meta(api_path, meta);
|
||||
@ -199,22 +197,17 @@ void remote_server::populate_stat(const struct stat64 &unix_st,
|
||||
|
||||
auto remote_server::fuse_access(const char *path, const std::int32_t &mask)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto res = access(file_path.c_str(), mask);
|
||||
auto ret = ((res < 0) ? -errno : 0);
|
||||
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_chflags(const char *path,
|
||||
std::uint32_t flags) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_chflags(const char *path, std::uint32_t flags)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path = utils::path::create_api_path(path);
|
||||
const auto file_path = construct_path(path);
|
||||
@ -234,9 +227,7 @@ auto remote_server::fuse_chflags(const char *path,
|
||||
|
||||
auto remote_server::fuse_chmod(const char *path, const remote::file_mode &mode)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto res = chmod(file_path.c_str(), mode);
|
||||
@ -248,9 +239,7 @@ auto remote_server::fuse_chmod(const char *path, const remote::file_mode &mode)
|
||||
auto remote_server::fuse_chown(const char *path, const remote::user_id &uid,
|
||||
const remote::group_id &gid)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto res = chown(file_path.c_str(), uid, gid);
|
||||
@ -263,9 +252,7 @@ auto remote_server::fuse_create(const char *path, const remote::file_mode &mode,
|
||||
const remote::open_flags &flags,
|
||||
remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto res =
|
||||
@ -282,9 +269,7 @@ auto remote_server::fuse_create(const char *path, const remote::file_mode &mode,
|
||||
}
|
||||
|
||||
auto remote_server::fuse_destroy() -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, "", 0);
|
||||
return 0;
|
||||
@ -328,12 +313,11 @@ length); ret = ((res < 0) ? -errno : 0); #endif
|
||||
return ret;
|
||||
}*/
|
||||
|
||||
auto remote_server::fuse_fgetattr(
|
||||
const char *path, remote::stat &r_stat, bool &directory,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat,
|
||||
bool &directory,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
r_stat = {};
|
||||
|
||||
@ -342,7 +326,7 @@ auto remote_server::fuse_fgetattr(
|
||||
auto res = has_open_info(static_cast<native_handle>(handle), EBADF);
|
||||
if (res == 0) {
|
||||
directory = utils::file::directory(file_path).exists();
|
||||
struct stat64 unix_st {};
|
||||
struct stat64 unix_st{};
|
||||
res = fstat64(static_cast<native_handle>(handle), &unix_st);
|
||||
if (res == 0) {
|
||||
populate_stat(unix_st, r_stat);
|
||||
@ -354,12 +338,11 @@ auto remote_server::fuse_fgetattr(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_fsetattr_x(
|
||||
const char *path, const remote::setattr_x &attr,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_fsetattr_x(const char *path,
|
||||
const remote::setattr_x &attr,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path = utils::path::create_api_path(path);
|
||||
const auto file_path = construct_path(path);
|
||||
@ -454,9 +437,7 @@ auto remote_server::fuse_fsetattr_x(
|
||||
auto remote_server::fuse_fsync(const char *path, const std::int32_t &datasync,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -476,12 +457,11 @@ auto remote_server::fuse_fsync(const char *path, const std::int32_t &datasync,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_ftruncate(
|
||||
const char *path, const remote::file_offset &size,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_ftruncate(const char *path,
|
||||
const remote::file_offset &size,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -498,9 +478,7 @@ auto remote_server::fuse_ftruncate(
|
||||
|
||||
auto remote_server::fuse_getattr(const char *path, remote::stat &r_stat,
|
||||
bool &directory) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path = utils::path::create_api_path(path);
|
||||
const auto file_path = construct_path(api_path);
|
||||
@ -510,7 +488,7 @@ auto remote_server::fuse_getattr(const char *path, remote::stat &r_stat,
|
||||
|
||||
directory = utils::file::directory(file_path).exists();
|
||||
|
||||
struct stat64 unix_st {};
|
||||
struct stat64 unix_st{};
|
||||
auto res = stat64(file_path.c_str(), &unix_st);
|
||||
if (res == 0) {
|
||||
populate_stat(unix_st, r_stat);
|
||||
@ -575,12 +553,11 @@ STATUS_NOT_IMPLEMENTED; #endif RAISE_REMOTE_FUSE_SERVER_EVENT(function_name,
|
||||
file_path, ret); return ret;
|
||||
}*/
|
||||
|
||||
auto remote_server::fuse_getxtimes(
|
||||
const char *path, remote::file_time &bkuptime,
|
||||
remote::file_time &crtime) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_getxtimes(const char *path,
|
||||
remote::file_time &bkuptime,
|
||||
remote::file_time &crtime)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path = utils::path::create_api_path(path);
|
||||
const auto file_path = construct_path(path);
|
||||
@ -610,9 +587,7 @@ auto remote_server::fuse_getxtimes(
|
||||
}
|
||||
|
||||
auto remote_server::fuse_init() -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, "", 0);
|
||||
return 0;
|
||||
@ -630,9 +605,7 @@ auto res = listxattr(file_path.c_str(), buffer, size); #endif auto ret = ((res <
|
||||
|
||||
auto remote_server::fuse_mkdir(const char *path, const remote::file_mode &mode)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto res = mkdir(file_path.c_str(), mode);
|
||||
@ -644,9 +617,7 @@ auto remote_server::fuse_mkdir(const char *path, const remote::file_mode &mode)
|
||||
auto remote_server::fuse_open(const char *path, const remote::open_flags &flags,
|
||||
remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto res = open(file_path.c_str(),
|
||||
@ -662,9 +633,7 @@ auto remote_server::fuse_open(const char *path, const remote::open_flags &flags,
|
||||
|
||||
auto remote_server::fuse_opendir(const char *path, remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -687,13 +656,12 @@ auto remote_server::fuse_opendir(const char *path, remote::file_handle &handle)
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_read(
|
||||
const char *path, char *buffer, const remote::file_size &read_size,
|
||||
const remote::file_offset &read_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_read(const char *path, char *buffer,
|
||||
const remote::file_size &read_size,
|
||||
const remote::file_offset &read_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
auto &data = *reinterpret_cast<data_buffer *>(buffer);
|
||||
@ -713,11 +681,9 @@ auto remote_server::fuse_read(
|
||||
return static_cast<packet::error_type>(ret);
|
||||
}
|
||||
|
||||
auto remote_server::fuse_rename(const char *from,
|
||||
const char *to) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_rename(const char *from, const char *to)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto from_path = utils::path::combine(mount_location_, {from});
|
||||
const auto to_path = utils::path::combine(mount_location_, {to});
|
||||
@ -732,9 +698,7 @@ auto remote_server::fuse_readdir(const char *path,
|
||||
const remote::file_offset &offset,
|
||||
const remote::file_handle &handle,
|
||||
std::string &item_path) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
auto res = 0;
|
||||
@ -756,11 +720,10 @@ auto remote_server::fuse_readdir(const char *path,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_release(
|
||||
const char *path, const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_release(const char *path,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet::error_type ret = 0;
|
||||
|
||||
@ -776,11 +739,10 @@ auto remote_server::fuse_release(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_releasedir(
|
||||
const char *path, const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_releasedir(const char *path,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -801,9 +763,7 @@ removexattr(file_path.c_str(), name); #endif auto ret = ((res < 0) ? -errno :
|
||||
}*/
|
||||
|
||||
auto remote_server::fuse_rmdir(const char *path) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto res = rmdir(file_path.c_str());
|
||||
@ -823,9 +783,7 @@ auto remote_server::fuse_rmdir(const char *path) -> packet::error_type {
|
||||
|
||||
auto remote_server::fuse_setattr_x(const char *path, remote::setattr_x &attr)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
auto ret = fuse_fsetattr_x(
|
||||
@ -834,11 +792,10 @@ auto remote_server::fuse_setattr_x(const char *path, remote::setattr_x &attr)
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_setbkuptime(
|
||||
const char *path, const remote::file_time &bkuptime) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_setbkuptime(const char *path,
|
||||
const remote::file_time &bkuptime)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path = utils::path::create_api_path(path);
|
||||
const auto file_path = construct_path(path);
|
||||
@ -856,11 +813,10 @@ auto remote_server::fuse_setbkuptime(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_setchgtime(
|
||||
const char *path, const remote::file_time &chgtime) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_setchgtime(const char *path,
|
||||
const remote::file_time &chgtime)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path = utils::path::create_api_path(path);
|
||||
const auto file_path = construct_path(path);
|
||||
@ -878,11 +834,10 @@ auto remote_server::fuse_setchgtime(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_setcrtime(
|
||||
const char *path, const remote::file_time &crtime) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_setcrtime(const char *path,
|
||||
const remote::file_time &crtime)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path = utils::path::create_api_path(path);
|
||||
const auto file_path = construct_path(path);
|
||||
@ -901,9 +856,7 @@ auto remote_server::fuse_setcrtime(
|
||||
}
|
||||
|
||||
auto remote_server::fuse_setvolname(const char *volname) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, volname, 0);
|
||||
return 0;
|
||||
@ -931,9 +884,7 @@ res = setxattr(file_path.c_str(), name, value, size, position, flags); auto ret
|
||||
|
||||
auto remote_server::fuse_statfs(const char *path, std::uint64_t frsize,
|
||||
remote::statfs &r_stat) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -954,9 +905,7 @@ auto remote_server::fuse_statfs(const char *path, std::uint64_t frsize,
|
||||
auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize,
|
||||
remote::statfs_x &r_stat)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -978,11 +927,10 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize,
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_truncate(
|
||||
const char *path, const remote::file_offset &size) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_truncate(const char *path,
|
||||
const remote::file_offset &size)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto res = truncate(file_path.c_str(), static_cast<off_t>(size));
|
||||
@ -992,9 +940,7 @@ auto remote_server::fuse_truncate(
|
||||
}
|
||||
|
||||
auto remote_server::fuse_unlink(const char *path) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto res = unlink(file_path.c_str());
|
||||
@ -1004,11 +950,9 @@ auto remote_server::fuse_unlink(const char *path) -> packet::error_type {
|
||||
}
|
||||
|
||||
auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
|
||||
std::uint64_t op0,
|
||||
std::uint64_t op1) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
std::uint64_t op0, std::uint64_t op1)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -1034,13 +978,12 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_write(
|
||||
const char *path, const char *buffer, const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_write(const char *path, const char *buffer,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -1069,11 +1012,9 @@ auto remote_server::fuse_write_base64(
|
||||
}
|
||||
|
||||
// WinFSP Layer
|
||||
auto remote_server::winfsp_can_delete(PVOID file_desc,
|
||||
PWSTR file_name) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR file_name)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto relative_path = utils::string::to_utf8(file_name);
|
||||
const auto file_path = construct_path(relative_path);
|
||||
@ -1098,11 +1039,9 @@ auto remote_server::winfsp_can_delete(PVOID file_desc,
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_cleanup(PVOID /*file_desc*/, PWSTR file_name,
|
||||
UINT32 flags,
|
||||
BOOLEAN &was_closed) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
UINT32 flags, BOOLEAN &was_closed)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto relative_path = utils::string::to_utf8(file_name);
|
||||
const auto file_path = construct_path(relative_path);
|
||||
@ -1159,9 +1098,7 @@ auto remote_server::winfsp_cleanup(PVOID /*file_desc*/, PWSTR file_name,
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_close(PVOID file_desc) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string file_path;
|
||||
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
|
||||
@ -1180,11 +1117,9 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
|
||||
UINT32 granted_access, UINT32 attributes,
|
||||
UINT64 /*allocation_size*/, PVOID *file_desc,
|
||||
remote::file_info *file_info,
|
||||
std::string &normalized_name,
|
||||
BOOLEAN &exists) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
std::string &normalized_name, BOOLEAN &exists)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto relative_path = utils::string::to_utf8(file_name);
|
||||
const auto file_path = construct_path(relative_path);
|
||||
@ -1233,9 +1168,7 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
|
||||
|
||||
auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
|
||||
auto ret = static_cast<packet::error_type>(
|
||||
@ -1255,11 +1188,10 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_get_file_info(
|
||||
PVOID file_desc, remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_get_file_info(PVOID file_desc,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
|
||||
auto ret = static_cast<packet::error_type>(
|
||||
@ -1280,9 +1212,7 @@ auto remote_server::winfsp_get_security_by_name(
|
||||
PWSTR file_name, PUINT32 attributes,
|
||||
std::uint64_t * /*security_descriptor_size*/,
|
||||
std::wstring & /*str_descriptor*/) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto ret = static_cast<packet::error_type>(STATUS_SUCCESS);
|
||||
const auto file_path = construct_path(file_name);
|
||||
@ -1303,12 +1233,11 @@ auto remote_server::winfsp_get_security_by_name(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_get_volume_info(
|
||||
UINT64 &total_size, UINT64 &free_size,
|
||||
std::string &volume_label) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_get_volume_info(UINT64 &total_size,
|
||||
UINT64 &free_size,
|
||||
std::string &volume_label)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
drive_.get_volume_info(total_size, free_size, volume_label);
|
||||
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, volume_label, STATUS_SUCCESS);
|
||||
@ -1317,22 +1246,19 @@ auto remote_server::winfsp_get_volume_info(
|
||||
|
||||
auto remote_server::winfsp_mounted(const std::wstring &location)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
RAISE_REMOTE_FUSE_SERVER_EVENT(
|
||||
function_name, utils::string::to_utf8(location), STATUS_SUCCESS);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_open(
|
||||
PWSTR file_name, UINT32 create_options, UINT32 granted_access,
|
||||
PVOID *file_desc, remote::file_info *file_info,
|
||||
std::string &normalized_name) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options,
|
||||
UINT32 granted_access, PVOID *file_desc,
|
||||
remote::file_info *file_info,
|
||||
std::string &normalized_name)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto relative_path = utils::string::to_utf8(file_name);
|
||||
const auto file_path = construct_path(relative_path);
|
||||
@ -1367,13 +1293,12 @@ auto remote_server::winfsp_open(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_overwrite(
|
||||
PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes,
|
||||
UINT64 /*allocation_size*/,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes,
|
||||
BOOLEAN replace_attributes,
|
||||
UINT64 /*allocation_size*/,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
|
||||
auto ret = static_cast<packet::error_type>(
|
||||
@ -1429,9 +1354,7 @@ auto remote_server::winfsp_overwrite(
|
||||
auto remote_server::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
UINT32 length, PUINT32 bytes_transferred)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
*bytes_transferred = 0;
|
||||
|
||||
@ -1458,9 +1381,7 @@ auto remote_server::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
|
||||
PWSTR marker, json &item_list)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
item_list.clear();
|
||||
|
||||
@ -1493,12 +1414,11 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_rename(
|
||||
PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name,
|
||||
BOOLEAN replace_if_exists) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name,
|
||||
PWSTR new_file_name,
|
||||
BOOLEAN replace_if_exists)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto relative_path = utils::string::to_utf8(file_name);
|
||||
const auto file_path = construct_path(relative_path);
|
||||
@ -1528,9 +1448,7 @@ auto remote_server::winfsp_set_basic_info(
|
||||
PVOID file_desc, UINT32 attributes, UINT64 creation_time,
|
||||
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
|
||||
auto ret = static_cast<packet::error_type>(
|
||||
@ -1593,12 +1511,11 @@ auto remote_server::winfsp_set_basic_info(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_set_file_size(
|
||||
PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
|
||||
BOOLEAN set_allocation_size,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
|
||||
auto ret = static_cast<packet::error_type>(
|
||||
@ -1626,22 +1543,20 @@ auto remote_server::winfsp_set_file_size(
|
||||
|
||||
auto remote_server::winfsp_unmounted(const std::wstring &location)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
RAISE_REMOTE_FUSE_SERVER_EVENT(
|
||||
function_name, utils::string::to_utf8(location), STATUS_SUCCESS);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_write(
|
||||
PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
|
||||
BOOLEAN write_to_end, BOOLEAN constrained_io, PUINT32 bytes_transferred,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
UINT32 length, BOOLEAN write_to_end,
|
||||
BOOLEAN constrained_io,
|
||||
PUINT32 bytes_transferred,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
*bytes_transferred = 0;
|
||||
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
|
||||
@ -1688,11 +1603,10 @@ auto remote_server::winfsp_write(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::json_create_directory_snapshot(
|
||||
const std::string &path, json &json_data) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::json_create_directory_snapshot(const std::string &path,
|
||||
json &json_data)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path = utils::path::create_api_path(path);
|
||||
const auto file_path = construct_path(api_path);
|
||||
@ -1722,9 +1636,7 @@ auto remote_server::json_create_directory_snapshot(
|
||||
auto remote_server::json_read_directory_snapshot(
|
||||
const std::string &path, const remote::file_handle &handle,
|
||||
std::uint32_t page, json &json_data) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
int res{-EBADF};
|
||||
|
||||
@ -1752,11 +1664,9 @@ auto remote_server::json_read_directory_snapshot(
|
||||
}
|
||||
|
||||
auto remote_server::json_release_directory_snapshot(
|
||||
const std::string &path,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
const std::string &path, const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
directory_cache_.remove_directory(handle);
|
||||
|
@ -54,11 +54,9 @@ remote_client::remote_client(const app_config &config)
|
||||
config.get_remote_receive_timeout_secs(),
|
||||
config.get_remote_send_timeout_secs(), config.get_remote_token()) {}
|
||||
|
||||
auto remote_client::winfsp_can_delete(PVOID file_desc,
|
||||
PWSTR file_name) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::winfsp_can_delete(PVOID file_desc, PWSTR file_name)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_desc);
|
||||
@ -75,11 +73,10 @@ auto remote_client::winfsp_can_delete(PVOID file_desc,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::json_create_directory_snapshot(
|
||||
const std::string &path, json &json_data) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::json_create_directory_snapshot(const std::string &path,
|
||||
json &json_data)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -100,9 +97,7 @@ auto remote_client::json_create_directory_snapshot(
|
||||
auto remote_client::json_read_directory_snapshot(
|
||||
const std::string &path, const remote::file_handle &handle,
|
||||
std::uint32_t page, json &json_data) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -123,11 +118,9 @@ auto remote_client::json_read_directory_snapshot(
|
||||
}
|
||||
|
||||
auto remote_client::json_release_directory_snapshot(
|
||||
const std::string &path,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
const std::string &path, const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(path);
|
||||
@ -143,11 +136,9 @@ auto remote_client::json_release_directory_snapshot(
|
||||
}
|
||||
|
||||
auto remote_client::winfsp_cleanup(PVOID file_desc, PWSTR file_name,
|
||||
UINT32 flags,
|
||||
BOOLEAN &was_closed) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
UINT32 flags, BOOLEAN &was_closed)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto handle{
|
||||
to_handle(file_desc),
|
||||
@ -178,9 +169,7 @@ auto remote_client::winfsp_cleanup(PVOID file_desc, PWSTR file_name,
|
||||
}
|
||||
|
||||
auto remote_client::winfsp_close(PVOID file_desc) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto handle{
|
||||
to_handle(file_desc),
|
||||
@ -211,11 +200,9 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options,
|
||||
UINT32 granted_access, UINT32 attributes,
|
||||
UINT64 allocation_size, PVOID *file_desc,
|
||||
remote::file_info *file_info,
|
||||
std::string &normalized_name,
|
||||
BOOLEAN &exists) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
std::string &normalized_name, BOOLEAN &exists)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_name);
|
||||
@ -255,9 +242,7 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options,
|
||||
|
||||
auto remote_client::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_desc);
|
||||
@ -285,11 +270,10 @@ auto remote_client::winfsp_get_dir_buffer([[maybe_unused]] PVOID file_desc,
|
||||
return static_cast<packet::error_type>(STATUS_INVALID_HANDLE);
|
||||
}
|
||||
|
||||
auto remote_client::winfsp_get_file_info(
|
||||
PVOID file_desc, remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::winfsp_get_file_info(PVOID file_desc,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_desc);
|
||||
@ -306,12 +290,12 @@ auto remote_client::winfsp_get_file_info(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::winfsp_get_security_by_name(
|
||||
PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size,
|
||||
std::wstring &string_descriptor) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::winfsp_get_security_by_name(PWSTR file_name,
|
||||
PUINT32 attributes,
|
||||
std::uint64_t *descriptor_size,
|
||||
std::wstring &string_descriptor)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_name);
|
||||
@ -340,12 +324,11 @@ auto remote_client::winfsp_get_security_by_name(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::winfsp_get_volume_info(
|
||||
UINT64 &total_size, UINT64 &free_size,
|
||||
std::string &volume_label) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::winfsp_get_volume_info(UINT64 &total_size,
|
||||
UINT64 &free_size,
|
||||
std::string &volume_label)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
packet response;
|
||||
@ -362,9 +345,7 @@ auto remote_client::winfsp_get_volume_info(
|
||||
|
||||
auto remote_client::winfsp_mounted(const std::wstring &location)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(std::string{project_get_version()});
|
||||
@ -384,13 +365,12 @@ auto remote_client::winfsp_mounted(const std::wstring &location)
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::winfsp_open(
|
||||
PWSTR file_name, UINT32 create_options, UINT32 granted_access,
|
||||
PVOID *file_desc, remote::file_info *file_info,
|
||||
std::string &normalized_name) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::winfsp_open(PWSTR file_name, UINT32 create_options,
|
||||
UINT32 granted_access, PVOID *file_desc,
|
||||
remote::file_info *file_info,
|
||||
std::string &normalized_name)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_name);
|
||||
@ -421,13 +401,12 @@ auto remote_client::winfsp_open(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::winfsp_overwrite(
|
||||
PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes,
|
||||
UINT64 allocation_size,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::winfsp_overwrite(PVOID file_desc, UINT32 attributes,
|
||||
BOOLEAN replace_attributes,
|
||||
UINT64 allocation_size,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_desc);
|
||||
@ -450,9 +429,7 @@ auto remote_client::winfsp_overwrite(
|
||||
auto remote_client::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
UINT32 length, PUINT32 bytes_transferred)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_desc);
|
||||
@ -469,7 +446,7 @@ auto remote_client::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
ret = response.decode(buffer, *bytes_transferred);
|
||||
#if defined(_WIN32)
|
||||
if ((ret == STATUS_SUCCESS) &&
|
||||
(not *bytes_transferred || (*bytes_transferred != length))) {
|
||||
(not*bytes_transferred || (*bytes_transferred != length))) {
|
||||
::SetLastError(ERROR_HANDLE_EOF);
|
||||
}
|
||||
#endif
|
||||
@ -486,9 +463,7 @@ auto remote_client::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
auto remote_client::winfsp_read_directory(PVOID file_desc, PWSTR pattern,
|
||||
PWSTR marker, json &item_list)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_desc);
|
||||
@ -509,12 +484,11 @@ auto remote_client::winfsp_read_directory(PVOID file_desc, PWSTR pattern,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::winfsp_rename(
|
||||
PVOID file_desc, PWSTR file_name, PWSTR new_file_name,
|
||||
BOOLEAN replace_if_exists) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::winfsp_rename(PVOID file_desc, PWSTR file_name,
|
||||
PWSTR new_file_name,
|
||||
BOOLEAN replace_if_exists)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_desc);
|
||||
@ -539,9 +513,7 @@ auto remote_client::winfsp_set_basic_info(
|
||||
PVOID file_desc, UINT32 attributes, UINT64 creation_time,
|
||||
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_desc);
|
||||
@ -563,12 +535,11 @@ auto remote_client::winfsp_set_basic_info(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::winfsp_set_file_size(
|
||||
PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
|
||||
BOOLEAN set_allocation_size,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_desc);
|
||||
@ -589,9 +560,7 @@ auto remote_client::winfsp_set_file_size(
|
||||
|
||||
auto remote_client::winfsp_unmounted(const std::wstring &location)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto mount_location{
|
||||
utils::string::to_utf8(location),
|
||||
@ -610,13 +579,13 @@ auto remote_client::winfsp_unmounted(const std::wstring &location)
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_client::winfsp_write(
|
||||
PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
|
||||
BOOLEAN write_to_end, BOOLEAN constrained_io, PUINT32 bytes_transferred,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_client::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
UINT32 length, BOOLEAN write_to_end,
|
||||
BOOLEAN constrained_io,
|
||||
PUINT32 bytes_transferred,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
packet request;
|
||||
request.encode(file_desc);
|
||||
|
@ -107,9 +107,7 @@ void remote_server::populate_stat(const char *path, bool directory,
|
||||
// FUSE Layer
|
||||
auto remote_server::fuse_access(const char *path, const std::int32_t &mask)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto file_path{
|
||||
construct_path(path),
|
||||
@ -133,9 +131,7 @@ auto remote_server::fuse_access(const char *path, const std::int32_t &mask)
|
||||
|
||||
auto remote_server::fuse_chflags(const char *path, std::uint32_t /*flags*/)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
@ -146,9 +142,7 @@ auto remote_server::fuse_chflags(const char *path, std::uint32_t /*flags*/)
|
||||
auto remote_server::fuse_chmod(const char *path,
|
||||
const remote::file_mode & /*mode*/)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
@ -156,12 +150,11 @@ auto remote_server::fuse_chmod(const char *path,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_chown(
|
||||
const char *path, const remote::user_id & /*uid*/,
|
||||
const remote::group_id & /*gid*/) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_chown(const char *path,
|
||||
const remote::user_id & /*uid*/,
|
||||
const remote::group_id & /*gid*/)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
@ -170,9 +163,7 @@ auto remote_server::fuse_chown(
|
||||
}
|
||||
|
||||
auto remote_server::fuse_destroy() -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, "", 0);
|
||||
return 0;
|
||||
@ -190,12 +181,11 @@ construct_path(path); auto res = HasOpenFileCompatInfo(handle, EBADF); if (res
|
||||
return ret;
|
||||
}*/
|
||||
|
||||
auto remote_server::fuse_fgetattr(
|
||||
const char *path, remote::stat &r_stat, bool &directory,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat,
|
||||
bool &directory,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
r_stat = {};
|
||||
|
||||
@ -206,7 +196,7 @@ auto remote_server::fuse_fgetattr(
|
||||
};
|
||||
if (res == 0) {
|
||||
directory = utils::file::directory(file_path).exists();
|
||||
struct _stat64 unix_st {};
|
||||
struct _stat64 unix_st{};
|
||||
res = _fstat64(static_cast<int>(handle), &unix_st);
|
||||
if (res == 0) {
|
||||
populate_stat(path, directory, r_stat, unix_st);
|
||||
@ -218,12 +208,11 @@ auto remote_server::fuse_fgetattr(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_fsetattr_x(
|
||||
const char *path, const remote::setattr_x & /*attr*/,
|
||||
const remote::file_handle & /*handle*/) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_fsetattr_x(const char *path,
|
||||
const remote::setattr_x & /*attr*/,
|
||||
const remote::file_handle & /*handle*/)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
@ -231,12 +220,11 @@ auto remote_server::fuse_fsetattr_x(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_fsync(
|
||||
const char *path, const std::int32_t & /*datasync*/,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_fsync(const char *path,
|
||||
const std::int32_t & /*datasync*/,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -262,12 +250,11 @@ auto remote_server::fuse_fsync(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_ftruncate(
|
||||
const char *path, const remote::file_offset &size,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_ftruncate(const char *path,
|
||||
const remote::file_offset &size,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -298,9 +285,7 @@ auto remote_server::fuse_ftruncate(
|
||||
|
||||
auto remote_server::fuse_getattr(const char *path, remote::stat &r_st,
|
||||
bool &directory) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
r_st = {};
|
||||
|
||||
@ -308,7 +293,7 @@ auto remote_server::fuse_getattr(const char *path, remote::stat &r_st,
|
||||
|
||||
directory = utils::file::directory(file_path).exists();
|
||||
|
||||
struct _stat64 st1 {};
|
||||
struct _stat64 st1{};
|
||||
auto res{
|
||||
_stat64(file_path.c_str(), &st1),
|
||||
};
|
||||
@ -334,12 +319,11 @@ STATUS_NOT_IMPLEMENTED; RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name,
|
||||
file_path, ret); return ret;
|
||||
}*/
|
||||
|
||||
auto remote_server::fuse_getxtimes(
|
||||
const char *path, remote::file_time & /*bkuptime*/,
|
||||
remote::file_time & /*crtime*/) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_getxtimes(const char *path,
|
||||
remote::file_time & /*bkuptime*/,
|
||||
remote::file_time & /*crtime*/)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
@ -348,9 +332,7 @@ auto remote_server::fuse_getxtimes(
|
||||
}
|
||||
|
||||
auto remote_server::fuse_init() -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, "", 0);
|
||||
return 0;
|
||||
@ -366,9 +348,7 @@ construct_path(path); const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
auto remote_server::fuse_mkdir(const char *path,
|
||||
const remote::file_mode & /*mode*/)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
auto res{
|
||||
@ -381,9 +361,7 @@ auto remote_server::fuse_mkdir(const char *path,
|
||||
|
||||
auto remote_server::fuse_opendir(const char *path, remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto unicode_file_path = utils::string::from_utf8(file_path);
|
||||
@ -410,9 +388,7 @@ auto remote_server::fuse_create(const char *path, const remote::file_mode &mode,
|
||||
const remote::open_flags &flags,
|
||||
remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto ret = -1;
|
||||
|
||||
@ -449,9 +425,7 @@ auto remote_server::fuse_create(const char *path, const remote::file_mode &mode,
|
||||
auto remote_server::fuse_open(const char *path, const remote::open_flags &flags,
|
||||
remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
auto res{-1};
|
||||
@ -479,13 +453,12 @@ auto remote_server::fuse_open(const char *path, const remote::open_flags &flags,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_read(
|
||||
const char *path, char *buffer, const remote::file_size &read_size,
|
||||
const remote::file_offset &read_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_read(const char *path, char *buffer,
|
||||
const remote::file_size &read_size,
|
||||
const remote::file_offset &read_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
auto &data = *reinterpret_cast<data_buffer *>(buffer);
|
||||
@ -515,11 +488,9 @@ auto remote_server::fuse_read(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_rename(const char *from,
|
||||
const char *to) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_rename(const char *from, const char *to)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto from_path = utils::path::combine(mount_location_, {from});
|
||||
const auto to_path = utils::path::combine(mount_location_, {to});
|
||||
@ -533,13 +504,12 @@ auto remote_server::fuse_rename(const char *from,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_write(
|
||||
const char *path, const char *buffer, const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_write(const char *path, const char *buffer,
|
||||
const remote::file_size &write_size,
|
||||
const remote::file_offset &write_offset,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
std::size_t bytes_written{};
|
||||
@ -583,9 +553,7 @@ auto remote_server::fuse_readdir(const char *path,
|
||||
const remote::file_offset &offset,
|
||||
const remote::file_handle &handle,
|
||||
std::string &item_path) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
auto res{0};
|
||||
@ -607,11 +575,10 @@ auto remote_server::fuse_readdir(const char *path,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_release(
|
||||
const char *path, const remote::file_handle &handle) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_release(const char *path,
|
||||
const remote::file_handle &handle)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -628,9 +595,7 @@ auto remote_server::fuse_release(
|
||||
auto remote_server::fuse_releasedir(const char *path,
|
||||
const remote::file_handle & /*handle*/)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, file_path, 0);
|
||||
@ -645,9 +610,7 @@ file_path, ret); return ret;
|
||||
}*/
|
||||
|
||||
auto remote_server::fuse_rmdir(const char *path) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
auto res{
|
||||
@ -658,11 +621,10 @@ auto remote_server::fuse_rmdir(const char *path) -> packet::error_type {
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_setattr_x(
|
||||
const char *path, remote::setattr_x & /*attr*/) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_setattr_x(const char *path,
|
||||
remote::setattr_x & /*attr*/)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
@ -673,9 +635,7 @@ auto remote_server::fuse_setattr_x(
|
||||
auto remote_server::fuse_setbkuptime(const char *path,
|
||||
const remote::file_time & /*bkuptime*/)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
@ -686,9 +646,7 @@ auto remote_server::fuse_setbkuptime(const char *path,
|
||||
auto remote_server::fuse_setchgtime(const char *path,
|
||||
const remote::file_time & /*chgtime*/)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
@ -699,9 +657,7 @@ auto remote_server::fuse_setchgtime(const char *path,
|
||||
auto remote_server::fuse_setcrtime(const char *path,
|
||||
const remote::file_time & /*crtime*/)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
@ -710,9 +666,7 @@ auto remote_server::fuse_setcrtime(const char *path,
|
||||
}
|
||||
|
||||
auto remote_server::fuse_setvolname(const char *volname) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, volname, 0);
|
||||
return 0;
|
||||
@ -735,9 +689,7 @@ construct_path(path); const auto ret = STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
auto remote_server::fuse_statfs(const char *path, std::uint64_t frsize,
|
||||
remote::statfs &r_stat) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -760,9 +712,7 @@ auto remote_server::fuse_statfs(const char *path, std::uint64_t frsize,
|
||||
auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize,
|
||||
remote::statfs_x &r_stat)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -785,11 +735,10 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize,
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto remote_server::fuse_truncate(
|
||||
const char *path, const remote::file_offset &size) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::fuse_truncate(const char *path,
|
||||
const remote::file_offset &size)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto unicode_file_path = utils::string::from_utf8(file_path);
|
||||
@ -823,9 +772,7 @@ auto remote_server::fuse_truncate(
|
||||
}
|
||||
|
||||
auto remote_server::fuse_unlink(const char *path) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
auto res{
|
||||
@ -837,11 +784,9 @@ auto remote_server::fuse_unlink(const char *path) -> packet::error_type {
|
||||
}
|
||||
|
||||
auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
|
||||
std::uint64_t op0,
|
||||
std::uint64_t op1) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
std::uint64_t op0, std::uint64_t op1)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
const auto unicode_file_path = utils::string::from_utf8(file_path);
|
||||
@ -899,11 +844,10 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
|
||||
}
|
||||
|
||||
// JSON Layer
|
||||
auto remote_server::json_create_directory_snapshot(
|
||||
const std::string &path, json &json_data) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::json_create_directory_snapshot(const std::string &path,
|
||||
json &json_data)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -932,9 +876,7 @@ auto remote_server::json_create_directory_snapshot(
|
||||
auto remote_server::json_read_directory_snapshot(
|
||||
const std::string &path, const remote::file_handle &handle,
|
||||
std::uint32_t page, json &json_data) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
@ -962,11 +904,9 @@ auto remote_server::json_read_directory_snapshot(
|
||||
}
|
||||
|
||||
auto remote_server::json_release_directory_snapshot(
|
||||
const std::string &path,
|
||||
const remote::file_handle & /*handle*/) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
const std::string &path, const remote::file_handle & /*handle*/)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = construct_path(path);
|
||||
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, file_path, 0);
|
||||
@ -977,9 +917,7 @@ auto remote_server::json_release_directory_snapshot(
|
||||
// WinFSP Layer
|
||||
auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR /*file_name*/)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto *handle = reinterpret_cast<HANDLE>(file_desc);
|
||||
|
||||
@ -998,11 +936,9 @@ auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR /*file_name*/)
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_cleanup(PVOID file_desc, PWSTR /*file_name*/,
|
||||
UINT32 flags,
|
||||
BOOLEAN &was_closed) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
UINT32 flags, BOOLEAN &was_closed)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = get_open_file_path(file_desc);
|
||||
was_closed = FALSE;
|
||||
@ -1020,9 +956,7 @@ auto remote_server::winfsp_cleanup(PVOID file_desc, PWSTR /*file_name*/,
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_close(PVOID file_desc) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = get_open_file_path(file_desc);
|
||||
|
||||
@ -1040,11 +974,9 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
|
||||
UINT32 granted_access, UINT32 attributes,
|
||||
UINT64 /*allocation_size*/, PVOID *file_desc,
|
||||
remote::file_info *file_info,
|
||||
std::string &normalized_name,
|
||||
BOOLEAN &exists) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
std::string &normalized_name, BOOLEAN &exists)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = utils::string::from_utf8(utils::path::combine(
|
||||
mount_location_, {utils::string::to_utf8(file_name)}));
|
||||
@ -1089,9 +1021,7 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
|
||||
|
||||
auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto *handle = reinterpret_cast<HANDLE>(file_desc);
|
||||
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
|
||||
@ -1109,11 +1039,10 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_get_file_info(
|
||||
PVOID file_desc, remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_get_file_info(PVOID file_desc,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto *handle = reinterpret_cast<HANDLE>(file_desc);
|
||||
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
|
||||
@ -1126,12 +1055,12 @@ auto remote_server::winfsp_get_file_info(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_get_security_by_name(
|
||||
PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size,
|
||||
std::wstring &string_descriptor) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_get_security_by_name(PWSTR file_name,
|
||||
PUINT32 attributes,
|
||||
std::uint64_t *descriptor_size,
|
||||
std::wstring &string_descriptor)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = utils::string::from_utf8(utils::path::combine(
|
||||
mount_location_, {utils::string::to_utf8(file_name)}));
|
||||
@ -1168,12 +1097,11 @@ auto remote_server::winfsp_get_security_by_name(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_get_volume_info(
|
||||
UINT64 &total_size, UINT64 &free_size,
|
||||
std::string &volume_label) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_get_volume_info(UINT64 &total_size,
|
||||
UINT64 &free_size,
|
||||
std::string &volume_label)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
drive_.get_volume_info(total_size, free_size, volume_label);
|
||||
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, volume_label, STATUS_SUCCESS);
|
||||
@ -1182,22 +1110,19 @@ auto remote_server::winfsp_get_volume_info(
|
||||
|
||||
auto remote_server::winfsp_mounted(const std::wstring &location)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
RAISE_REMOTE_WINFSP_SERVER_EVENT(
|
||||
function_name, utils::string::to_utf8(location), STATUS_SUCCESS);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_open(
|
||||
PWSTR file_name, UINT32 create_options, UINT32 granted_access,
|
||||
PVOID *file_desc, remote::file_info *file_info,
|
||||
std::string &normalized_name) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options,
|
||||
UINT32 granted_access, PVOID *file_desc,
|
||||
remote::file_info *file_info,
|
||||
std::string &normalized_name)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto file_path = utils::string::from_utf8(utils::path::combine(
|
||||
mount_location_, {utils::string::to_utf8(file_name)}));
|
||||
@ -1228,13 +1153,12 @@ auto remote_server::winfsp_open(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_overwrite(
|
||||
PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes,
|
||||
UINT64 /*allocation_size*/,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes,
|
||||
BOOLEAN replace_attributes,
|
||||
UINT64 /*allocation_size*/,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto *handle = reinterpret_cast<HANDLE>(file_desc);
|
||||
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
|
||||
@ -1289,9 +1213,7 @@ auto remote_server::winfsp_overwrite(
|
||||
auto remote_server::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
UINT32 length, PUINT32 bytes_transferred)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
*bytes_transferred = 0U;
|
||||
|
||||
@ -1319,9 +1241,7 @@ auto remote_server::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
|
||||
PWSTR marker, json &item_list)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto ret = STATUS_INVALID_HANDLE;
|
||||
item_list.clear();
|
||||
@ -1348,12 +1268,11 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_rename(
|
||||
PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name,
|
||||
BOOLEAN replace_if_exists) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name,
|
||||
PWSTR new_file_name,
|
||||
BOOLEAN replace_if_exists)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto from_path = utils::string::from_utf8(utils::path::combine(
|
||||
mount_location_, {utils::string::to_utf8(file_name)}));
|
||||
@ -1375,9 +1294,7 @@ auto remote_server::winfsp_set_basic_info(
|
||||
PVOID file_desc, UINT32 attributes, UINT64 creation_time,
|
||||
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto *handle = reinterpret_cast<HANDLE>(file_desc);
|
||||
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
|
||||
@ -1406,12 +1323,11 @@ auto remote_server::winfsp_set_basic_info(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_set_file_size(
|
||||
PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
|
||||
BOOLEAN set_allocation_size,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto *handle = reinterpret_cast<HANDLE>(file_desc);
|
||||
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
|
||||
@ -1446,22 +1362,20 @@ auto remote_server::winfsp_set_file_size(
|
||||
|
||||
auto remote_server::winfsp_unmounted(const std::wstring &location)
|
||||
-> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
RAISE_REMOTE_WINFSP_SERVER_EVENT(
|
||||
function_name, utils::string::to_utf8(location), STATUS_SUCCESS);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
auto remote_server::winfsp_write(
|
||||
PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
|
||||
BOOLEAN /*write_to_end*/, BOOLEAN constrained_io, PUINT32 bytes_transferred,
|
||||
remote::file_info *file_info) -> packet::error_type {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
|
||||
UINT32 length, BOOLEAN /*write_to_end*/,
|
||||
BOOLEAN constrained_io,
|
||||
PUINT32 bytes_transferred,
|
||||
remote::file_info *file_info)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto *handle = reinterpret_cast<HANDLE>(file_desc);
|
||||
*bytes_transferred = 0U;
|
||||
|
@ -50,9 +50,7 @@ remote_winfsp_drive::winfsp_service::winfsp_service(
|
||||
host_(drive) {}
|
||||
|
||||
auto remote_winfsp_drive::winfsp_service::OnStart(ULONG, PWSTR *) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto mount_location = utils::string::to_lower(utils::path::absolute(
|
||||
(drive_args_.size() > 1U) ? drive_args_.at(1U) : ""));
|
||||
@ -88,9 +86,7 @@ auto remote_winfsp_drive::winfsp_service::OnStart(ULONG, PWSTR *) -> NTSTATUS {
|
||||
}
|
||||
|
||||
auto remote_winfsp_drive::winfsp_service::OnStop() -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
host_.Unmount();
|
||||
if (not lock_.set_mount_state(false, "", -1)) {
|
||||
@ -131,8 +127,8 @@ auto remote_winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
|
||||
UINT32 granted_access, UINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR /*descriptor*/,
|
||||
UINT64 allocation_size, PVOID * /*file_node*/,
|
||||
PVOID *file_desc,
|
||||
OpenFileInfo *ofi) -> NTSTATUS {
|
||||
PVOID *file_desc, OpenFileInfo *ofi)
|
||||
-> NTSTATUS {
|
||||
remote::file_info fi{};
|
||||
std::string normalized_name;
|
||||
BOOLEAN exists = 0;
|
||||
@ -166,9 +162,10 @@ auto remote_winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto remote_winfsp_drive::GetSecurityByName(
|
||||
PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor,
|
||||
SIZE_T *descriptor_size) -> NTSTATUS {
|
||||
auto remote_winfsp_drive::GetSecurityByName(PWSTR file_name, PUINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
SIZE_T *descriptor_size)
|
||||
-> NTSTATUS {
|
||||
std::wstring string_descriptor;
|
||||
std::uint64_t sds = (descriptor_size == nullptr) ? 0 : *descriptor_size;
|
||||
auto ret = remote_instance_->winfsp_get_security_by_name(
|
||||
@ -266,9 +263,7 @@ auto remote_winfsp_drive::mount(const std::vector<std::string> &drive_args)
|
||||
}
|
||||
|
||||
auto remote_winfsp_drive::Mounted(PVOID host) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto *file_system_host = reinterpret_cast<FileSystemHost *>(host);
|
||||
remote_instance_ = factory_();
|
||||
@ -285,8 +280,8 @@ auto remote_winfsp_drive::Mounted(PVOID host) -> NTSTATUS {
|
||||
|
||||
auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
|
||||
UINT32 granted_access, PVOID * /*file_node*/,
|
||||
PVOID *file_desc,
|
||||
OpenFileInfo *ofi) -> NTSTATUS {
|
||||
PVOID *file_desc, OpenFileInfo *ofi)
|
||||
-> NTSTATUS {
|
||||
remote::file_info fi{};
|
||||
std::string normalize_name;
|
||||
auto ret =
|
||||
@ -306,8 +301,8 @@ auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
|
||||
auto remote_winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
|
||||
UINT32 attributes,
|
||||
BOOLEAN replace_attributes,
|
||||
UINT64 allocation_size,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
UINT64 allocation_size, FileInfo *file_info)
|
||||
-> NTSTATUS {
|
||||
remote::file_info fi{};
|
||||
auto ret = remote_instance_->winfsp_overwrite(
|
||||
file_desc, attributes, replace_attributes, allocation_size, &fi);
|
||||
@ -423,8 +418,8 @@ auto remote_winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc,
|
||||
UINT32 attributes, UINT64 creation_time,
|
||||
UINT64 last_access_time,
|
||||
UINT64 last_write_time,
|
||||
UINT64 change_time,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
UINT64 change_time, FileInfo *file_info)
|
||||
-> NTSTATUS {
|
||||
remote::file_info fi{};
|
||||
auto ret = remote_instance_->winfsp_set_basic_info(
|
||||
file_desc, attributes, creation_time, last_access_time, last_write_time,
|
||||
@ -460,9 +455,7 @@ auto remote_winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc,
|
||||
}
|
||||
|
||||
VOID remote_winfsp_drive::Unmounted(PVOID host) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
server_->stop();
|
||||
server_.reset();
|
||||
@ -478,8 +471,8 @@ VOID remote_winfsp_drive::Unmounted(PVOID host) {
|
||||
auto remote_winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc,
|
||||
PVOID buffer, UINT64 offset, ULONG length,
|
||||
BOOLEAN write_to_end, BOOLEAN constrained_io,
|
||||
PULONG bytes_transferred,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
PULONG bytes_transferred, FileInfo *file_info)
|
||||
-> NTSTATUS {
|
||||
remote::file_info fi{};
|
||||
auto ret = remote_instance_->winfsp_write(
|
||||
file_desc, buffer, offset, length, write_to_end, constrained_io,
|
||||
|
@ -67,11 +67,9 @@ winfsp_drive::winfsp_service::winfsp_service(
|
||||
host_(drive),
|
||||
config_(config) {}
|
||||
|
||||
auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/,
|
||||
PWSTR * /*Argv*/) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/, PWSTR * /*Argv*/)
|
||||
-> NTSTATUS {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto mount_location = utils::string::to_lower(
|
||||
utils::path::absolute((drive_args_.size() > 1U) ? drive_args_[1U] : ""));
|
||||
@ -108,9 +106,7 @@ auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/,
|
||||
}
|
||||
|
||||
auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
host_.Unmount();
|
||||
|
||||
@ -133,9 +129,7 @@ void winfsp_drive::shutdown() { ::GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); }
|
||||
|
||||
auto winfsp_drive::CanDelete(PVOID /*file_node*/, PVOID file_desc,
|
||||
PWSTR /*file_name*/) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
auto error = api_error::invalid_handle;
|
||||
@ -163,9 +157,7 @@ auto winfsp_drive::CanDelete(PVOID /*file_node*/, PVOID file_desc,
|
||||
|
||||
VOID winfsp_drive::Cleanup(PVOID file_node, PVOID file_desc,
|
||||
PWSTR /*file_name*/, ULONG flags) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
auto handle =
|
||||
@ -265,9 +257,7 @@ VOID winfsp_drive::Cleanup(PVOID file_node, PVOID file_desc,
|
||||
}
|
||||
|
||||
VOID winfsp_drive::Close(PVOID /*file_node*/, PVOID file_desc) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
auto handle =
|
||||
@ -295,9 +285,7 @@ auto winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
|
||||
PSECURITY_DESCRIPTOR /*descriptor*/,
|
||||
UINT64 /*allocation_size*/, PVOID * /*file_node*/,
|
||||
PVOID *file_desc, OpenFileInfo *ofi) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
// TODO Need to revisit this
|
||||
// (ConvertSecurityDescriptorToStringSecurityDescriptor/ConvertStringSecurityDescriptorToSecurityDescriptor)
|
||||
@ -350,9 +338,7 @@ auto winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
|
||||
|
||||
auto winfsp_drive::Flush(PVOID /*file_node*/, PVOID file_desc,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
auto error = api_error::success;
|
||||
@ -391,9 +377,7 @@ auto winfsp_drive::get_directory_item_count(const std::string &api_path) const
|
||||
|
||||
auto winfsp_drive::get_directory_items(const std::string &api_path) const
|
||||
-> directory_item_list {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
directory_item_list list;
|
||||
auto res = provider_.get_directory_items(api_path, list);
|
||||
@ -406,9 +390,7 @@ auto winfsp_drive::get_directory_items(const std::string &api_path) const
|
||||
|
||||
auto winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
auto error = api_error::invalid_handle;
|
||||
@ -433,9 +415,7 @@ auto winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc,
|
||||
|
||||
auto winfsp_drive::get_file_size(const std::string &api_path) const
|
||||
-> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::uint64_t file_size{};
|
||||
auto res = provider_.get_file_size(api_path, file_size);
|
||||
@ -464,9 +444,10 @@ auto winfsp_drive::get_item_meta(const std::string &api_path,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto winfsp_drive::get_security_by_name(
|
||||
PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor,
|
||||
std::uint64_t *descriptor_size) -> NTSTATUS {
|
||||
auto winfsp_drive::get_security_by_name(PWSTR file_name, PUINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
std::uint64_t *descriptor_size)
|
||||
-> NTSTATUS {
|
||||
const auto api_path =
|
||||
utils::path::create_api_path(utils::string::to_utf8(file_name));
|
||||
|
||||
@ -502,9 +483,7 @@ auto winfsp_drive::get_security_by_name(
|
||||
auto winfsp_drive::GetSecurityByName(PWSTR file_name, PUINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
SIZE_T *descriptor_size) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path =
|
||||
utils::path::create_api_path(utils::string::to_utf8(file_name));
|
||||
@ -541,9 +520,7 @@ void winfsp_drive::get_volume_info(UINT64 &total_size, UINT64 &free_size,
|
||||
}
|
||||
|
||||
auto winfsp_drive::GetVolumeInfo(VolumeInfo *volume_info) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const std::wstring volume_label = utils::string::from_utf8(
|
||||
utils::create_volume_label(config_.get_provider_type()));
|
||||
@ -619,9 +596,7 @@ auto winfsp_drive::mount(const std::vector<std::string> &drive_args) -> int {
|
||||
}
|
||||
|
||||
auto winfsp_drive::Mounted(PVOID host) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto ret{STATUS_SUCCESS};
|
||||
if (not utils::file::change_to_process_directory()) {
|
||||
@ -687,9 +662,7 @@ auto winfsp_drive::Mounted(PVOID host) -> NTSTATUS {
|
||||
auto winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
|
||||
UINT32 granted_access, PVOID * /*file_node*/,
|
||||
PVOID *file_desc, OpenFileInfo *ofi) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path =
|
||||
utils::path::create_api_path(utils::string::to_utf8(file_name));
|
||||
@ -734,11 +707,9 @@ auto winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
|
||||
|
||||
auto winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
|
||||
UINT32 attributes, BOOLEAN replace_attributes,
|
||||
UINT64 /*allocation_size*/,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
UINT64 /*allocation_size*/, FileInfo *file_info)
|
||||
-> NTSTATUS {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
auto error = api_error::invalid_handle;
|
||||
@ -811,8 +782,9 @@ void winfsp_drive::populate_file_info(const std::string &api_path,
|
||||
populate_file_info(file_size, meta, ofi.FileInfo);
|
||||
}
|
||||
|
||||
auto winfsp_drive::populate_file_info(
|
||||
const std::string &api_path, remote::file_info &file_info) -> api_error {
|
||||
auto winfsp_drive::populate_file_info(const std::string &api_path,
|
||||
remote::file_info &file_info)
|
||||
-> api_error {
|
||||
api_meta_map meta{};
|
||||
auto ret = provider_.get_item_meta(api_path, meta);
|
||||
if (ret == api_error::success) {
|
||||
@ -845,11 +817,9 @@ void winfsp_drive::populate_file_info(std::uint64_t file_size,
|
||||
}
|
||||
|
||||
auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer,
|
||||
UINT64 offset, ULONG length,
|
||||
PULONG bytes_transferred) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
UINT64 offset, ULONG length, PULONG bytes_transferred)
|
||||
-> NTSTATUS {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
*bytes_transferred = 0U;
|
||||
|
||||
@ -899,11 +869,9 @@ auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer,
|
||||
|
||||
auto winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
||||
PWSTR /*pattern*/, PWSTR marker, PVOID buffer,
|
||||
ULONG buffer_length,
|
||||
PULONG bytes_transferred) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
ULONG buffer_length, PULONG bytes_transferred)
|
||||
-> NTSTATUS {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
auto error = api_error::invalid_handle;
|
||||
@ -1002,9 +970,7 @@ auto winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
||||
auto winfsp_drive::Rename(PVOID /*file_node*/, PVOID /*file_desc*/,
|
||||
PWSTR file_name, PWSTR new_file_name,
|
||||
BOOLEAN replace_if_exists) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto from_api_path =
|
||||
utils::path::create_api_path(utils::string::to_utf8(file_name));
|
||||
@ -1034,11 +1000,9 @@ auto winfsp_drive::Rename(PVOID /*file_node*/, PVOID /*file_desc*/,
|
||||
auto winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc,
|
||||
UINT32 attributes, UINT64 creation_time,
|
||||
UINT64 last_access_time, UINT64 last_write_time,
|
||||
UINT64 change_time,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
UINT64 change_time, FileInfo *file_info)
|
||||
-> NTSTATUS {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
auto error = api_error::invalid_handle;
|
||||
@ -1115,9 +1079,7 @@ void winfsp_drive::set_file_info(remote::file_info &dest,
|
||||
auto winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc,
|
||||
UINT64 new_size, BOOLEAN set_allocation_size,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
auto error = api_error::invalid_handle;
|
||||
@ -1172,9 +1134,7 @@ auto winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc,
|
||||
}
|
||||
|
||||
VOID winfsp_drive::Unmounted(PVOID host) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto *file_system_host = reinterpret_cast<FileSystemHost *>(host);
|
||||
const auto mount_location =
|
||||
@ -1206,9 +1166,7 @@ auto winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc, PVOID buffer,
|
||||
UINT64 offset, ULONG length, BOOLEAN write_to_end,
|
||||
BOOLEAN constrained_io, PULONG bytes_transferred,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
*bytes_transferred = 0;
|
||||
|
||||
|
@ -40,8 +40,8 @@
|
||||
#include "utils/time.hpp"
|
||||
|
||||
namespace {
|
||||
[[nodiscard]] auto
|
||||
create_resume_entry(const repertory::i_open_file &file) -> json {
|
||||
[[nodiscard]] auto create_resume_entry(const repertory::i_open_file &file)
|
||||
-> json {
|
||||
return {
|
||||
{"chunk_size", file.get_chunk_size()},
|
||||
{"path", file.get_api_path()},
|
||||
@ -207,9 +207,7 @@ auto file_manager::create(const std::string &api_path, api_meta_map &meta,
|
||||
}
|
||||
|
||||
auto file_manager::evict_file(const std::string &api_path) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (provider_.is_direct_only()) {
|
||||
return false;
|
||||
@ -260,9 +258,7 @@ auto file_manager::evict_file(const std::string &api_path) -> bool {
|
||||
|
||||
auto file_manager::get_directory_items(const std::string &api_path) const
|
||||
-> directory_item_list {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
directory_item_list list{};
|
||||
auto res = provider_.get_directory_items(api_path, list);
|
||||
@ -351,9 +347,7 @@ auto file_manager::get_open_handle_count() const -> std::size_t {
|
||||
}
|
||||
|
||||
auto file_manager::get_stored_downloads() const -> std::vector<json> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::vector<json> ret;
|
||||
if (not provider_.is_direct_only()) {
|
||||
@ -461,10 +455,11 @@ auto file_manager::open(const std::string &api_path, bool directory,
|
||||
return open(api_path, directory, ofd, handle, file, nullptr);
|
||||
}
|
||||
|
||||
auto file_manager::open(
|
||||
const std::string &api_path, bool directory, const open_file_data &ofd,
|
||||
std::uint64_t &handle, std::shared_ptr<i_open_file> &file,
|
||||
std::shared_ptr<i_closeable_open_file> closeable_file) -> api_error {
|
||||
auto file_manager::open(const std::string &api_path, bool directory,
|
||||
const open_file_data &ofd, std::uint64_t &handle,
|
||||
std::shared_ptr<i_open_file> &file,
|
||||
std::shared_ptr<i_closeable_open_file> closeable_file)
|
||||
-> api_error {
|
||||
const auto create_and_add_handle =
|
||||
[&](std::shared_ptr<i_closeable_open_file> cur_file) {
|
||||
handle = get_next_handle();
|
||||
@ -546,9 +541,7 @@ void file_manager::queue_upload(const std::string &api_path,
|
||||
}
|
||||
|
||||
auto file_manager::remove_file(const std::string &api_path) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
recur_mutex_lock open_lock(open_file_mtx_);
|
||||
|
||||
@ -603,9 +596,7 @@ void file_manager::remove_upload(const std::string &api_path) {
|
||||
}
|
||||
|
||||
void file_manager::remove_upload(const std::string &api_path, bool no_lock) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (provider_.is_direct_only()) {
|
||||
return;
|
||||
@ -727,8 +718,8 @@ auto file_manager::rename_directory(const std::string &from_api_path,
|
||||
}
|
||||
|
||||
auto file_manager::rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path,
|
||||
bool overwrite) -> api_error {
|
||||
const std::string &to_api_path, bool overwrite)
|
||||
-> api_error {
|
||||
if (not provider_.is_rename_supported()) {
|
||||
return api_error::not_implemented;
|
||||
}
|
||||
@ -800,9 +791,7 @@ auto file_manager::rename_file(const std::string &from_api_path,
|
||||
}
|
||||
|
||||
void file_manager::start() {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
polling::instance().set_callback(
|
||||
{"timed_out_close", polling::frequency::second,
|
||||
@ -980,9 +969,7 @@ void file_manager::store_resume(const i_open_file &file) {
|
||||
|
||||
void file_manager::swap_renamed_items(std::string from_api_path,
|
||||
std::string to_api_path, bool directory) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto file_iter = open_file_lookup_.find(from_api_path);
|
||||
if (file_iter != open_file_lookup_.end()) {
|
||||
@ -1009,9 +996,7 @@ void file_manager::swap_renamed_items(std::string from_api_path,
|
||||
}
|
||||
|
||||
void file_manager::upload_completed(const file_upload_completed &evt) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
unique_mutex_lock upload_lock(upload_mtx_);
|
||||
|
||||
@ -1053,9 +1038,7 @@ void file_manager::upload_completed(const file_upload_completed &evt) {
|
||||
}
|
||||
|
||||
void file_manager::upload_handler() {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
while (not stop_requested_) {
|
||||
auto should_wait{true};
|
||||
|
@ -248,9 +248,7 @@ auto file_manager::open_file::native_operation(
|
||||
auto file_manager::open_file::native_operation(
|
||||
std::uint64_t new_file_size,
|
||||
i_open_file::native_operation_callback callback) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (fsi_.directory) {
|
||||
return api_error::invalid_operation;
|
||||
@ -339,8 +337,8 @@ auto file_manager::open_file::native_operation(
|
||||
}
|
||||
|
||||
auto file_manager::open_file::read(std::size_t read_size,
|
||||
std::uint64_t read_offset,
|
||||
data_buffer &data) -> api_error {
|
||||
std::uint64_t read_offset, data_buffer &data)
|
||||
-> api_error {
|
||||
if (fsi_.directory) {
|
||||
return api_error::invalid_operation;
|
||||
}
|
||||
@ -418,9 +416,7 @@ auto file_manager::open_file::resize(std::uint64_t new_file_size) -> api_error {
|
||||
}
|
||||
|
||||
auto file_manager::open_file::close() -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (not fsi_.directory && not stop_requested_) {
|
||||
stop_requested_ = true;
|
||||
@ -533,9 +529,7 @@ void file_manager::open_file::update_background_reader(std::size_t read_chunk) {
|
||||
auto file_manager::open_file::write(std::uint64_t write_offset,
|
||||
const data_buffer &data,
|
||||
std::size_t &bytes_written) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
bytes_written = 0U;
|
||||
|
||||
|
@ -73,7 +73,7 @@ file_manager::ring_buffer_open_file::ring_buffer_open_file(
|
||||
fsi_.source_path =
|
||||
utils::path::combine(buffer_directory, {utils::create_uuid_string()});
|
||||
nf_ = utils::file::file::open_or_create_file(fsi_.source_path);
|
||||
if (not *nf_) {
|
||||
if (not*nf_) {
|
||||
throw std::runtime_error("failed to create buffer file|err|" +
|
||||
std::to_string(utils::get_last_error_code()));
|
||||
}
|
||||
@ -86,9 +86,7 @@ file_manager::ring_buffer_open_file::ring_buffer_open_file(
|
||||
}
|
||||
|
||||
file_manager::ring_buffer_open_file::~ring_buffer_open_file() {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
close();
|
||||
|
||||
|
@ -49,9 +49,7 @@ void file_manager::upload::cancel() {
|
||||
void file_manager::upload::stop() { stop_requested_ = true; }
|
||||
|
||||
void file_manager::upload::upload_thread() {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
error_ =
|
||||
provider_.upload_file(fsi_.api_path, fsi_.source_path, stop_requested_);
|
||||
|
@ -102,9 +102,7 @@ auto lock_data::get_state_directory() -> std::string {
|
||||
}
|
||||
|
||||
auto lock_data::grab_lock(std::uint8_t retry_count) -> lock_result {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (lock_fd_ == -1) {
|
||||
return lock_result::failure;
|
||||
@ -126,9 +124,7 @@ auto lock_data::grab_lock(std::uint8_t retry_count) -> lock_result {
|
||||
|
||||
auto lock_data::set_mount_state(bool active, const std::string &mount_location,
|
||||
int pid) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto ret = false;
|
||||
auto handle =
|
||||
|
@ -27,8 +27,8 @@
|
||||
#include "utils/error_utils.hpp"
|
||||
|
||||
namespace repertory {
|
||||
auto lock_data::get_mount_state(const provider_type & /*pt*/,
|
||||
json &mount_state) -> bool {
|
||||
auto lock_data::get_mount_state(const provider_type & /*pt*/, json &mount_state)
|
||||
-> bool {
|
||||
const auto ret = get_mount_state(mount_state);
|
||||
if (ret) {
|
||||
const auto mount_id =
|
||||
@ -73,9 +73,7 @@ auto lock_data::get_mount_state(json &mount_state) -> bool {
|
||||
}
|
||||
|
||||
auto lock_data::grab_lock(std::uint8_t retry_count) -> lock_result {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto ret = lock_result::success;
|
||||
if (mutex_handle_ == INVALID_HANDLE_VALUE) {
|
||||
|
@ -33,8 +33,8 @@
|
||||
|
||||
namespace repertory {
|
||||
auto base_provider::create_api_file(std::string path, std::string key,
|
||||
std::uint64_t size,
|
||||
std::uint64_t file_time) -> api_file {
|
||||
std::uint64_t size, std::uint64_t file_time)
|
||||
-> api_file {
|
||||
api_file file{};
|
||||
file.api_path = utils::path::create_api_path(path);
|
||||
file.api_parent = utils::path::get_parent_api_path(file.api_path);
|
||||
@ -66,11 +66,9 @@ auto base_provider::create_api_file(std::string path, std::uint64_t size,
|
||||
}
|
||||
|
||||
auto base_provider::create_directory_clone_source_meta(
|
||||
const std::string &source_api_path,
|
||||
const std::string &api_path) -> api_error {
|
||||
constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
const std::string &source_api_path, const std::string &api_path)
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
bool exists{};
|
||||
auto res = is_file(source_api_path, exists);
|
||||
@ -122,9 +120,7 @@ auto base_provider::create_directory_clone_source_meta(
|
||||
|
||||
auto base_provider::create_directory(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
bool exists{};
|
||||
auto res = is_directory(api_path, exists);
|
||||
@ -168,11 +164,9 @@ auto base_provider::create_directory(const std::string &api_path,
|
||||
return set_item_meta(api_path, meta);
|
||||
}
|
||||
|
||||
auto base_provider::create_file(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto base_provider::create_file(const std::string &api_path, api_meta_map &meta)
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
bool exists{};
|
||||
auto res = is_directory(api_path, exists);
|
||||
@ -228,11 +222,10 @@ auto base_provider::create_file(const std::string &api_path,
|
||||
return api_error::error;
|
||||
}
|
||||
|
||||
auto base_provider::get_api_path_from_source(
|
||||
const std::string &source_path, std::string &api_path) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto base_provider::get_api_path_from_source(const std::string &source_path,
|
||||
std::string &api_path) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (source_path.empty()) {
|
||||
utils::error::raise_api_path_error(function_name, api_path,
|
||||
@ -244,11 +237,10 @@ auto base_provider::get_api_path_from_source(
|
||||
return db3_->get_api_path(source_path, api_path);
|
||||
}
|
||||
|
||||
auto base_provider::get_directory_items(
|
||||
const std::string &api_path, directory_item_list &list) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto base_provider::get_directory_items(const std::string &api_path,
|
||||
directory_item_list &list) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
bool exists{};
|
||||
auto res = is_directory(api_path, exists);
|
||||
@ -311,9 +303,10 @@ auto base_provider::get_file_size(const std::string &api_path,
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto base_provider::get_filesystem_item(
|
||||
const std::string &api_path, bool directory,
|
||||
filesystem_item &fsi) const -> api_error {
|
||||
auto base_provider::get_filesystem_item(const std::string &api_path,
|
||||
bool directory,
|
||||
filesystem_item &fsi) const
|
||||
-> api_error {
|
||||
bool exists{};
|
||||
auto res = is_directory(api_path, exists);
|
||||
if (res != api_error::success) {
|
||||
@ -346,9 +339,10 @@ auto base_provider::get_filesystem_item(
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto base_provider::get_filesystem_item_and_file(
|
||||
const std::string &api_path, api_file &file,
|
||||
filesystem_item &fsi) const -> api_error {
|
||||
auto base_provider::get_filesystem_item_and_file(const std::string &api_path,
|
||||
api_file &file,
|
||||
filesystem_item &fsi) const
|
||||
-> api_error {
|
||||
auto res = get_file(api_path, file);
|
||||
if (res != api_error::success) {
|
||||
return res;
|
||||
@ -409,9 +403,7 @@ auto base_provider::get_total_item_count() const -> std::uint64_t {
|
||||
}
|
||||
|
||||
auto base_provider::get_used_drive_space() const -> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto used_space = get_used_drive_space_impl();
|
||||
@ -437,9 +429,7 @@ auto base_provider::is_file_writeable(const std::string &api_path) const
|
||||
}
|
||||
|
||||
void base_provider::remove_deleted_files(bool source_only) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (not is_direct_only()) {
|
||||
auto source_list =
|
||||
@ -734,9 +724,7 @@ void base_provider::stop() {
|
||||
auto base_provider::upload_file(const std::string &api_path,
|
||||
const std::string &source_path,
|
||||
stop_type &stop_requested) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
event_system::instance().raise<provider_upload_begin>(api_path, source_path);
|
||||
|
||||
|
@ -69,9 +69,10 @@ const std::map<std::string, std::string> sql_create_tables = {
|
||||
namespace repertory {
|
||||
encrypt_provider::encrypt_provider(app_config &config) : config_(config) {}
|
||||
|
||||
auto encrypt_provider::create_api_file(
|
||||
const std::string &api_path, bool directory,
|
||||
const std::string &source_path) -> api_file {
|
||||
auto encrypt_provider::create_api_file(const std::string &api_path,
|
||||
bool directory,
|
||||
const std::string &source_path)
|
||||
-> api_file {
|
||||
auto times = utils::file::get_times(source_path);
|
||||
if (not times.has_value()) {
|
||||
throw std::runtime_error("failed to get file times");
|
||||
@ -97,10 +98,10 @@ auto encrypt_provider::create_api_file(
|
||||
void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory,
|
||||
const api_file &file) {
|
||||
#if defined(_WIN32)
|
||||
struct _stat64 buf {};
|
||||
struct _stat64 buf{};
|
||||
_stat64(file.source_path.c_str(), &buf);
|
||||
#else // !defined(_WIN32)
|
||||
struct stat buf {};
|
||||
struct stat buf{};
|
||||
stat(file.source_path.c_str(), &buf);
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
@ -187,11 +188,10 @@ auto encrypt_provider::do_fs_operation(
|
||||
return callback(cfg, source_path);
|
||||
}
|
||||
|
||||
auto encrypt_provider::get_api_path_from_source(
|
||||
const std::string &source_path, std::string &api_path) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto encrypt_provider::get_api_path_from_source(const std::string &source_path,
|
||||
std::string &api_path) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto result = utils::db::sqlite::db_select{*db_, file_table}
|
||||
@ -231,9 +231,7 @@ auto encrypt_provider::get_api_path_from_source(
|
||||
|
||||
auto encrypt_provider::get_directory_item_count(
|
||||
const std::string &api_path) const -> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::uint64_t count{};
|
||||
auto res = do_fs_operation(
|
||||
@ -257,11 +255,10 @@ auto encrypt_provider::get_directory_item_count(
|
||||
return count;
|
||||
}
|
||||
|
||||
auto encrypt_provider::get_directory_items(
|
||||
const std::string &api_path, directory_item_list &list) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto encrypt_provider::get_directory_items(const std::string &api_path,
|
||||
directory_item_list &list) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return do_fs_operation(
|
||||
api_path, true,
|
||||
@ -374,9 +371,7 @@ auto encrypt_provider::get_directory_items(
|
||||
|
||||
auto encrypt_provider::get_file(const std::string &api_path,
|
||||
api_file &file) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
bool exists{};
|
||||
@ -411,9 +406,7 @@ auto encrypt_provider::get_file(const std::string &api_path,
|
||||
}
|
||||
|
||||
auto encrypt_provider::get_file_list(api_file_list &list) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto cfg = config_.get_encrypt_config();
|
||||
event_system::instance().raise<debug_log>(std::string{function_name},
|
||||
@ -437,11 +430,10 @@ auto encrypt_provider::get_file_list(api_file_list &list) const -> api_error {
|
||||
return api_error::error;
|
||||
}
|
||||
|
||||
auto encrypt_provider::get_file_size(
|
||||
const std::string &api_path, std::uint64_t &file_size) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto encrypt_provider::get_file_size(const std::string &api_path,
|
||||
std::uint64_t &file_size) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto result = utils::db::sqlite::db_select{*db_, source_table}
|
||||
@ -466,9 +458,10 @@ auto encrypt_provider::get_file_size(
|
||||
return api_error::error;
|
||||
}
|
||||
|
||||
auto encrypt_provider::get_filesystem_item(
|
||||
const std::string &api_path, bool directory,
|
||||
filesystem_item &fsi) const -> api_error {
|
||||
auto encrypt_provider::get_filesystem_item(const std::string &api_path,
|
||||
bool directory,
|
||||
filesystem_item &fsi) const
|
||||
-> api_error {
|
||||
auto result = utils::db::sqlite::db_select{*db_, source_table}
|
||||
.column("source_path")
|
||||
.where("api_path")
|
||||
@ -544,12 +537,11 @@ auto encrypt_provider::get_filesystem_item_from_source_path(
|
||||
return get_filesystem_item(api_path, false, fsi);
|
||||
}
|
||||
|
||||
auto encrypt_provider::get_filesystem_item_and_file(
|
||||
const std::string &api_path, api_file &file,
|
||||
filesystem_item &fsi) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto encrypt_provider::get_filesystem_item_and_file(const std::string &api_path,
|
||||
api_file &file,
|
||||
filesystem_item &fsi) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
bool exists{};
|
||||
@ -582,9 +574,7 @@ auto encrypt_provider::get_pinned_files() const -> std::vector<std::string> {
|
||||
|
||||
auto encrypt_provider::get_item_meta(const std::string &api_path,
|
||||
api_meta_map &meta) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto result = utils::db::sqlite::db_select{*db_, source_table}
|
||||
@ -677,8 +667,8 @@ auto encrypt_provider::is_directory(const std::string &api_path,
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto encrypt_provider::is_file(const std::string &api_path,
|
||||
bool &exists) const -> api_error {
|
||||
auto encrypt_provider::is_file(const std::string &api_path, bool &exists) const
|
||||
-> api_error {
|
||||
auto result = utils::db::sqlite::db_select{*db_, source_table}
|
||||
.column("source_path")
|
||||
.where("api_path")
|
||||
@ -863,9 +853,7 @@ auto encrypt_provider::read_file_bytes(const std::string &api_path,
|
||||
std::size_t size, std::uint64_t offset,
|
||||
data_buffer &data,
|
||||
stop_type &stop_requested) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto result = utils::db::sqlite::db_select{*db_, source_table}
|
||||
.column("source_path")
|
||||
@ -1037,9 +1025,7 @@ void encrypt_provider::remove_deleted_files() {
|
||||
|
||||
auto encrypt_provider::start(api_item_added_callback /*api_item_added*/,
|
||||
i_file_manager * /*mgr*/) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (not is_online()) {
|
||||
return false;
|
||||
|
@ -32,9 +32,7 @@
|
||||
|
||||
namespace repertory {
|
||||
meta_db::meta_db(const app_config &cfg) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto db_path = utils::path::combine(cfg.get_data_directory(), {"meta.db3"});
|
||||
|
||||
@ -110,11 +108,9 @@ auto meta_db::get_api_path_list() -> std::vector<std::string> {
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto meta_db::get_item_meta(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto meta_db::get_item_meta(const std::string &api_path, api_meta_map &meta)
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto result = utils::db::sqlite::db_select{*db_, table_name}
|
||||
.column("*")
|
||||
@ -153,9 +149,7 @@ auto meta_db::get_item_meta(const std::string &api_path,
|
||||
|
||||
auto meta_db::get_item_meta(const std::string &api_path, const std::string &key,
|
||||
std::string &value) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto result = utils::db::sqlite::db_select{*db_, table_name}
|
||||
.column("*")
|
||||
@ -196,9 +190,7 @@ auto meta_db::get_item_meta(const std::string &api_path, const std::string &key,
|
||||
}
|
||||
|
||||
auto meta_db::get_pinned_files() const -> std::vector<std::string> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::vector<std::string> ret{};
|
||||
|
||||
@ -222,9 +214,7 @@ auto meta_db::get_pinned_files() const -> std::vector<std::string> {
|
||||
}
|
||||
|
||||
auto meta_db::get_total_item_count() const -> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::uint64_t ret{};
|
||||
|
||||
@ -247,9 +237,7 @@ auto meta_db::get_total_item_count() const -> std::uint64_t {
|
||||
}
|
||||
|
||||
void meta_db::remove_api_path(const std::string &api_path) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto result = utils::db::sqlite::db_delete{*db_, table_name}
|
||||
.where("api_path")
|
||||
@ -304,11 +292,9 @@ auto meta_db::set_item_meta(const std::string &api_path,
|
||||
return update_item_meta(api_path, existing_meta);
|
||||
}
|
||||
|
||||
auto meta_db::update_item_meta(const std::string &api_path,
|
||||
api_meta_map meta) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto meta_db::update_item_meta(const std::string &api_path, api_meta_map meta)
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto directory = utils::string::to_bool(meta[META_DIRECTORY]);
|
||||
auto pinned = utils::string::to_bool(meta[META_PINNED]);
|
||||
|
@ -43,8 +43,9 @@ s3_provider::s3_provider(app_config &config, i_http_comm &comm)
|
||||
get_comm().enable_s3_path_style(config.get_s3_config().use_path_style);
|
||||
}
|
||||
|
||||
auto s3_provider::add_if_not_found(
|
||||
api_file &file, const std::string &object_name) const -> api_error {
|
||||
auto s3_provider::add_if_not_found(api_file &file,
|
||||
const std::string &object_name) const
|
||||
-> api_error {
|
||||
api_meta_map meta{};
|
||||
if (get_item_meta(file.api_path, meta) == api_error::item_not_found) {
|
||||
auto err = create_path_directories(
|
||||
@ -70,7 +71,7 @@ auto s3_provider::convert_api_date(std::string_view date) -> std::uint64_t {
|
||||
utils::string::split(date_parts.at(1U), 'Z', true).at(0U)) *
|
||||
1000000UL;
|
||||
|
||||
struct tm tm1 {};
|
||||
struct tm tm1{};
|
||||
#if defined(_WIN32)
|
||||
utils::time::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
||||
return nanos + utils::time::windows_time_t_to_unix_time(_mkgmtime(&tm1));
|
||||
@ -83,9 +84,7 @@ auto s3_provider::convert_api_date(std::string_view date) -> std::uint64_t {
|
||||
|
||||
auto s3_provider::create_directory_impl(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto cfg = get_config().get_s3_config();
|
||||
const auto is_encrypted = not cfg.encryption_token.empty();
|
||||
@ -138,9 +137,7 @@ auto s3_provider::create_directory_impl(const std::string &api_path,
|
||||
|
||||
auto s3_provider::create_file_extra(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (not get_config().get_s3_config().encryption_token.empty()) {
|
||||
std::string encrypted_file_path;
|
||||
@ -165,8 +162,9 @@ auto s3_provider::create_file_extra(const std::string &api_path,
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto s3_provider::create_path_directories(
|
||||
const std::string &api_path, const std::string &key) const -> api_error {
|
||||
auto s3_provider::create_path_directories(const std::string &api_path,
|
||||
const std::string &key) const
|
||||
-> api_error {
|
||||
if (api_path == "/") {
|
||||
return api_error::success;
|
||||
}
|
||||
@ -224,9 +222,7 @@ auto s3_provider::decrypt_object_name(std::string &object_name) const
|
||||
|
||||
auto s3_provider::get_directory_item_count(const std::string &api_path) const
|
||||
-> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
const auto cfg = get_config().get_s3_config();
|
||||
@ -284,8 +280,9 @@ auto s3_provider::get_directory_item_count(const std::string &api_path) const
|
||||
return 0U;
|
||||
}
|
||||
|
||||
auto s3_provider::get_directory_items_impl(
|
||||
const std::string &api_path, directory_item_list &list) const -> api_error {
|
||||
auto s3_provider::get_directory_items_impl(const std::string &api_path,
|
||||
directory_item_list &list) const
|
||||
-> api_error {
|
||||
const auto cfg = get_config().get_s3_config();
|
||||
const auto is_encrypted = not cfg.encryption_token.empty();
|
||||
|
||||
@ -400,11 +397,9 @@ auto s3_provider::get_directory_items_impl(
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto s3_provider::get_file(const std::string &api_path,
|
||||
api_file &file) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto s3_provider::get_file(const std::string &api_path, api_file &file) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
bool is_encrypted{};
|
||||
@ -494,8 +489,9 @@ auto s3_provider::get_file_list(api_file_list &list) const -> api_error {
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto s3_provider::get_last_modified(
|
||||
bool directory, const std::string &api_path) const -> std::uint64_t {
|
||||
auto s3_provider::get_last_modified(bool directory,
|
||||
const std::string &api_path) const
|
||||
-> std::uint64_t {
|
||||
bool is_encrypted{};
|
||||
std::string object_name;
|
||||
head_object_result result{};
|
||||
@ -505,12 +501,11 @@ auto s3_provider::get_last_modified(
|
||||
: utils::time::get_time_now();
|
||||
}
|
||||
|
||||
auto s3_provider::get_object_info(
|
||||
bool directory, const std::string &api_path, bool &is_encrypted,
|
||||
std::string &object_name, head_object_result &result) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto s3_provider::get_object_info(bool directory, const std::string &api_path,
|
||||
bool &is_encrypted, std::string &object_name,
|
||||
head_object_result &result) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
const auto cfg = get_config().get_s3_config();
|
||||
@ -556,10 +551,11 @@ auto s3_provider::get_object_info(
|
||||
return api_error::error;
|
||||
}
|
||||
|
||||
auto s3_provider::get_object_list(
|
||||
std::string &response_data, long &response_code,
|
||||
std::optional<std::string> delimiter,
|
||||
std::optional<std::string> prefix) const -> bool {
|
||||
auto s3_provider::get_object_list(std::string &response_data,
|
||||
long &response_code,
|
||||
std::optional<std::string> delimiter,
|
||||
std::optional<std::string> prefix) const
|
||||
-> bool {
|
||||
curl::requests::http_get get{};
|
||||
get.allow_timeout = true;
|
||||
get.aws_service = "aws:amz:" + get_config().get_s3_config().region + ":s3";
|
||||
@ -616,11 +612,9 @@ auto s3_provider::get_used_drive_space_impl() const -> std::uint64_t {
|
||||
});
|
||||
}
|
||||
|
||||
auto s3_provider::is_directory(const std::string &api_path,
|
||||
bool &exists) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto s3_provider::is_directory(const std::string &api_path, bool &exists) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
exists = false;
|
||||
if (api_path == "/") {
|
||||
@ -646,11 +640,9 @@ auto s3_provider::is_directory(const std::string &api_path,
|
||||
return api_error::error;
|
||||
}
|
||||
|
||||
auto s3_provider::is_file(const std::string &api_path,
|
||||
bool &exists) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto s3_provider::is_file(const std::string &api_path, bool &exists) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
exists = false;
|
||||
if (api_path == "/") {
|
||||
@ -683,9 +675,7 @@ auto s3_provider::is_online() const -> bool {
|
||||
auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
|
||||
std::uint64_t offset, data_buffer &data,
|
||||
stop_type &stop_requested) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
const auto cfg = get_config().get_s3_config();
|
||||
@ -791,9 +781,7 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
|
||||
|
||||
auto s3_provider::remove_directory_impl(const std::string &api_path)
|
||||
-> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto cfg = get_config().get_s3_config();
|
||||
const auto is_encrypted = not cfg.encryption_token.empty();
|
||||
@ -835,9 +823,7 @@ auto s3_provider::remove_directory_impl(const std::string &api_path)
|
||||
}
|
||||
|
||||
auto s3_provider::remove_file_impl(const std::string &api_path) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto cfg = get_config().get_s3_config();
|
||||
const auto is_encrypted = not cfg.encryption_token.empty();
|
||||
|
@ -45,8 +45,8 @@ namespace {
|
||||
return cfg.bucket;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_last_modified(const nlohmann::json &obj) -> std::uint64_t {
|
||||
[[nodiscard]] auto get_last_modified(const nlohmann::json &obj)
|
||||
-> std::uint64_t {
|
||||
try {
|
||||
return repertory::s3_provider::convert_api_date(
|
||||
obj["modTime"].get<std::string>());
|
||||
@ -60,11 +60,10 @@ namespace repertory {
|
||||
sia_provider::sia_provider(app_config &config, i_http_comm &comm)
|
||||
: base_provider(config, comm) {}
|
||||
|
||||
auto sia_provider::create_directory_impl(
|
||||
const std::string &api_path, api_meta_map & /* meta */) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto sia_provider::create_directory_impl(const std::string &api_path,
|
||||
api_meta_map & /* meta */)
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
curl::requests::http_put_file put_file{};
|
||||
put_file.allow_timeout = true;
|
||||
@ -91,9 +90,7 @@ auto sia_provider::create_directory_impl(
|
||||
|
||||
auto sia_provider::get_directory_item_count(const std::string &api_path) const
|
||||
-> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
json object_list{};
|
||||
@ -129,11 +126,10 @@ auto sia_provider::get_directory_item_count(const std::string &api_path) const
|
||||
return 0U;
|
||||
}
|
||||
|
||||
auto sia_provider::get_directory_items_impl(
|
||||
const std::string &api_path, directory_item_list &list) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto sia_provider::get_directory_items_impl(const std::string &api_path,
|
||||
directory_item_list &list) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
json object_list{};
|
||||
if (not get_object_list(api_path, object_list)) {
|
||||
@ -190,8 +186,8 @@ auto sia_provider::get_directory_items_impl(
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto sia_provider::get_file(const std::string &api_path,
|
||||
api_file &file) const -> api_error {
|
||||
auto sia_provider::get_file(const std::string &api_path, api_file &file) const
|
||||
-> api_error {
|
||||
json file_data{};
|
||||
auto res = get_object_info(api_path, file_data);
|
||||
if (res != api_error::success) {
|
||||
@ -219,9 +215,7 @@ auto sia_provider::get_file(const std::string &api_path,
|
||||
}
|
||||
|
||||
auto sia_provider::get_file_list(api_file_list &list) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
using dir_func = std::function<api_error(std::string api_path)>;
|
||||
const dir_func get_files_in_dir = [&](std::string api_path) -> api_error {
|
||||
@ -287,9 +281,7 @@ auto sia_provider::get_file_list(api_file_list &list) const -> api_error {
|
||||
|
||||
auto sia_provider::get_object_info(const std::string &api_path,
|
||||
json &object_info) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
curl::requests::http_get get{};
|
||||
@ -331,9 +323,7 @@ auto sia_provider::get_object_info(const std::string &api_path,
|
||||
|
||||
auto sia_provider::get_object_list(const std::string &api_path,
|
||||
nlohmann::json &object_list) const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
curl::requests::http_get get{};
|
||||
get.allow_timeout = true;
|
||||
@ -366,9 +356,7 @@ auto sia_provider::get_object_list(const std::string &api_path,
|
||||
}
|
||||
|
||||
auto sia_provider::get_total_drive_space() const -> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
curl::requests::http_get get{};
|
||||
@ -406,9 +394,7 @@ auto sia_provider::get_total_drive_space() const -> std::uint64_t {
|
||||
}
|
||||
|
||||
auto sia_provider::get_used_drive_space_impl() const -> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
curl::requests::http_get get{};
|
||||
get.allow_timeout = true;
|
||||
@ -438,11 +424,9 @@ auto sia_provider::get_used_drive_space_impl() const -> std::uint64_t {
|
||||
return object_data["totalObjectsSize"].get<std::uint64_t>();
|
||||
}
|
||||
|
||||
auto sia_provider::is_directory(const std::string &api_path,
|
||||
bool &exists) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto sia_provider::is_directory(const std::string &api_path, bool &exists) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (api_path == "/") {
|
||||
exists = true;
|
||||
@ -473,11 +457,9 @@ auto sia_provider::is_directory(const std::string &api_path,
|
||||
return api_error::error;
|
||||
}
|
||||
|
||||
auto sia_provider::is_file(const std::string &api_path,
|
||||
bool &exists) const -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto sia_provider::is_file(const std::string &api_path, bool &exists) const
|
||||
-> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
exists = false;
|
||||
if (api_path == "/") {
|
||||
@ -506,9 +488,7 @@ auto sia_provider::is_file(const std::string &api_path,
|
||||
}
|
||||
|
||||
auto sia_provider::is_online() const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
curl::requests::http_get get{};
|
||||
@ -551,9 +531,7 @@ auto sia_provider::read_file_bytes(const std::string &api_path,
|
||||
std::size_t size, std::uint64_t offset,
|
||||
data_buffer &buffer,
|
||||
stop_type &stop_requested) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
curl::requests::http_get get{};
|
||||
get.path = "/api/worker/objects" + api_path;
|
||||
@ -607,9 +585,7 @@ auto sia_provider::read_file_bytes(const std::string &api_path,
|
||||
|
||||
auto sia_provider::remove_directory_impl(const std::string &api_path)
|
||||
-> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
curl::requests::http_delete del{};
|
||||
del.allow_timeout = true;
|
||||
@ -635,9 +611,7 @@ auto sia_provider::remove_directory_impl(const std::string &api_path)
|
||||
}
|
||||
|
||||
auto sia_provider::remove_file_impl(const std::string &api_path) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
curl::requests::http_delete del{};
|
||||
del.allow_timeout = true;
|
||||
@ -665,9 +639,7 @@ auto sia_provider::remove_file_impl(const std::string &api_path) -> api_error {
|
||||
|
||||
auto sia_provider::rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
curl::requests::http_post post{};
|
||||
post.json = nlohmann::json({
|
||||
@ -713,9 +685,7 @@ void sia_provider::stop() {
|
||||
auto sia_provider::upload_file_impl(const std::string &api_path,
|
||||
const std::string &source_path,
|
||||
stop_type &stop_requested) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
curl::requests::http_put_file put_file{};
|
||||
put_file.path = "/api/worker/objects" + api_path;
|
||||
|
@ -88,9 +88,7 @@ void full_server::handle_get_pinned_files(const httplib::Request & /*req*/,
|
||||
|
||||
void full_server::handle_get_pinned_status(const httplib::Request &req,
|
||||
httplib::Response &res) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path =
|
||||
utils::path::create_api_path(req.get_param_value("api_path"));
|
||||
@ -114,9 +112,7 @@ void full_server::handle_get_pinned_status(const httplib::Request &req,
|
||||
|
||||
void full_server::handle_pin_file(const httplib::Request &req,
|
||||
httplib::Response &res) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path =
|
||||
utils::path::create_api_path(req.get_param_value("api_path"));
|
||||
@ -145,9 +141,7 @@ void full_server::handle_pin_file(const httplib::Request &req,
|
||||
|
||||
void full_server::handle_unpin_file(const httplib::Request &req,
|
||||
httplib::Response &res) {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto api_path =
|
||||
utils::path::create_api_path(req.get_param_value("api_path"));
|
||||
|
@ -29,9 +29,7 @@ namespace repertory {
|
||||
server::server(app_config &config) : config_(config) {}
|
||||
|
||||
auto server::check_authorization(const httplib::Request &req) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (config_.get_api_auth().empty() || config_.get_api_user().empty()) {
|
||||
utils::error::raise_error(function_name,
|
||||
@ -134,9 +132,7 @@ void server::initialize(httplib::Server &inst) {
|
||||
}
|
||||
|
||||
void server::start() {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
mutex_lock lock(start_stop_mutex_);
|
||||
if (not started_) {
|
||||
|
@ -29,6 +29,11 @@
|
||||
namespace {
|
||||
struct repertory_exception_handler final
|
||||
: repertory::utils::error::i_exception_handler {
|
||||
void handle_error(std::string_view function_name,
|
||||
std::string_view msg) const override {
|
||||
repertory::utils::error::raise_error(function_name, msg);
|
||||
}
|
||||
|
||||
void handle_exception(std::string_view function_name) const override {
|
||||
repertory::utils::error::raise_error(function_name, "|exception|unknown");
|
||||
}
|
||||
@ -39,7 +44,7 @@ struct repertory_exception_handler final
|
||||
}
|
||||
};
|
||||
|
||||
static std::unique_ptr<repertory_exception_handler> handler{([]() -> auto * {
|
||||
std::unique_ptr<repertory_exception_handler> handler{([]() -> auto * {
|
||||
auto *ptr = new repertory_exception_handler{};
|
||||
repertory::utils::error::set_exception_handler(ptr);
|
||||
return ptr;
|
||||
|
@ -30,9 +30,7 @@
|
||||
namespace repertory::utils::file {
|
||||
auto get_directory_files(std::string_view path, bool oldest_first,
|
||||
bool recursive) -> std::deque<std::string> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto abs_path = utils::path::absolute(path);
|
||||
std::deque<std::string> ret;
|
||||
@ -96,7 +94,7 @@ auto get_directory_files(std::string_view path, bool oldest_first,
|
||||
|
||||
const auto add_to_lookup = [&](const std::string &lookup_path) {
|
||||
if (lookup.find(lookup_path) == lookup.end()) {
|
||||
struct stat st {};
|
||||
struct stat st{};
|
||||
stat(lookup_path.c_str(), &st);
|
||||
#if defined(__APPLE__)
|
||||
lookup[lookup_path] =
|
||||
|
@ -36,11 +36,12 @@ template <typename drive> inline void help(std::vector<const char *> args) {
|
||||
std::cout << " -di,--drive_information Display mounted drive "
|
||||
"information"
|
||||
<< std::endl;
|
||||
std::cout
|
||||
<< " -na,--name Unique name for S3 or Sia "
|
||||
"instance [Required]"
|
||||
<< std::endl;
|
||||
std::cout << " -s3,--s3 Enables S3 mode"
|
||||
<< std::endl;
|
||||
std::cout << " -na,--name Unique name for S3 "
|
||||
"instance [Required]"
|
||||
<< std::endl;
|
||||
std::cout
|
||||
<< " -gc,--generate_config Generate initial configuration"
|
||||
<< std::endl;
|
||||
|
@ -76,7 +76,11 @@ mount(std::vector<const char *> args, std::string data_directory,
|
||||
config.set_remote_host_name_or_ip(remote_host);
|
||||
config.set_remote_port(remote_port);
|
||||
config.save();
|
||||
} else if (prov == provider_type::sia &&
|
||||
config.get_sia_config().bucket.empty()) {
|
||||
config.set_value_by_name("SiaConfig.Bucket", unique_id);
|
||||
}
|
||||
|
||||
std::cout << "Generated " << app_config::get_provider_display_name(prov)
|
||||
<< " Configuration" << std::endl;
|
||||
std::cout << config.get_config_file_path() << std::endl;
|
||||
@ -88,7 +92,7 @@ mount(std::vector<const char *> args, std::string data_directory,
|
||||
if (utils::cli::has_option(args, utils::cli::options::hidden_option)) {
|
||||
::ShowWindow(::GetConsoleWindow(), SW_HIDE);
|
||||
}
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
const auto drive_args =
|
||||
utils::cli::parse_drive_options(args, prov, data_directory);
|
||||
app_config config(prov, data_directory);
|
||||
@ -112,7 +116,7 @@ mount(std::vector<const char *> args, std::string data_directory,
|
||||
|
||||
return exit_code::mount_result;
|
||||
}
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
std::cout << "Initializing "
|
||||
<< app_config::get_provider_display_name(prov)
|
||||
<< (unique_id.empty() ? ""
|
||||
@ -152,6 +156,11 @@ mount(std::vector<const char *> args, std::string data_directory,
|
||||
ret = exit_code::startup_exception;
|
||||
}
|
||||
} else {
|
||||
if (prov == provider_type::sia &&
|
||||
config.get_sia_config().bucket.empty()) {
|
||||
config.set_value_by_name("SiaConfig.Bucket", unique_id);
|
||||
}
|
||||
|
||||
config.set_is_remote_mount(false);
|
||||
|
||||
try {
|
||||
|
@ -72,45 +72,54 @@ auto main(int argc, char **argv) -> int {
|
||||
std::string remote_host;
|
||||
std::uint16_t remote_port{};
|
||||
std::string unique_id;
|
||||
if ((res == exit_code::success) && (prov == provider_type::remote)) {
|
||||
std::string data;
|
||||
res = utils::cli::parse_string_option(
|
||||
args, utils::cli::options::remote_mount_option, data);
|
||||
if (res == exit_code::success) {
|
||||
const auto parts = utils::string::split(data, ':', false);
|
||||
if (parts.size() != 2) {
|
||||
std::cerr << "Invalid syntax for host/port '-rm "
|
||||
"host:port,--remote_mount host:port'"
|
||||
<< std::endl;
|
||||
res = exit_code::invalid_syntax;
|
||||
} else {
|
||||
unique_id = parts[0U] + ':' + parts[1U];
|
||||
remote_host = parts[0U];
|
||||
try {
|
||||
remote_port = utils::string::to_uint16(parts[1U]);
|
||||
data_directory = utils::path::combine(
|
||||
data_directory.empty() ? app_config::default_data_directory(prov)
|
||||
: data_directory,
|
||||
{utils::string::replace_copy(unique_id, ':', '_')});
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << (e.what() == nullptr ? "Unable to parse port" : e.what())
|
||||
if (res == exit_code::success) {
|
||||
if (prov == provider_type::remote) {
|
||||
std::string data;
|
||||
res = utils::cli::parse_string_option(
|
||||
args, utils::cli::options::remote_mount_option, data);
|
||||
if (res == exit_code::success) {
|
||||
const auto parts = utils::string::split(data, ':', false);
|
||||
if (parts.size() != 2) {
|
||||
std::cerr << "Invalid syntax for host/port '-rm "
|
||||
"host:port,--remote_mount host:port'"
|
||||
<< std::endl;
|
||||
res = exit_code::invalid_syntax;
|
||||
} else {
|
||||
unique_id = parts.at(0U) + ':' + parts.at(1U);
|
||||
remote_host = parts.at(0U);
|
||||
try {
|
||||
remote_port = utils::string::to_uint16(parts.at(1U));
|
||||
data_directory = utils::path::combine(
|
||||
data_directory.empty()
|
||||
? app_config::default_data_directory(prov)
|
||||
: data_directory,
|
||||
{utils::string::replace_copy(unique_id, ':', '_')});
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << (e.what() == nullptr ? "Unable to parse port"
|
||||
: e.what())
|
||||
<< std::endl;
|
||||
res = exit_code::invalid_syntax;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ((prov == provider_type::s3) || (prov == provider_type::sia)) {
|
||||
std::string data;
|
||||
res = utils::cli::parse_string_option(
|
||||
args, utils::cli::options::name_option, data);
|
||||
if (res == exit_code::success) {
|
||||
unique_id = utils::string::trim(data);
|
||||
if (unique_id.empty()) {
|
||||
std::cerr << "Name of " << app_config::get_provider_name(prov)
|
||||
<< " instance not provided" << std::endl;
|
||||
res = exit_code::invalid_syntax;
|
||||
}
|
||||
} else if (res == exit_code::option_not_found &&
|
||||
prov == provider_type::sia) {
|
||||
unique_id = "default";
|
||||
res = exit_code::success;
|
||||
}
|
||||
|
||||
if ((res == exit_code::success) && (prov == provider_type::s3)) {
|
||||
std::string data;
|
||||
res = utils::cli::parse_string_option(
|
||||
args, utils::cli::options::name_option, data);
|
||||
if (res == exit_code::success) {
|
||||
unique_id = utils::string::trim(data);
|
||||
if (unique_id.empty()) {
|
||||
std::cerr << "Name of S3 instance not provided" << std::endl;
|
||||
res = exit_code::invalid_syntax;
|
||||
} else {
|
||||
if (res == exit_code::success) {
|
||||
data_directory =
|
||||
data_directory.empty()
|
||||
? utils::path::combine(app_config::default_data_directory(prov),
|
||||
|
@ -99,7 +99,7 @@ const auto DEFAULT_SIA_CONFIG = "{\n"
|
||||
" \"RetryReadCount\": 6,\n"
|
||||
" \"RingBufferFileSize\": 512,\n"
|
||||
" \"SiaConfig\": {\n"
|
||||
" \"Bucket\": \"default\"\n"
|
||||
" \"Bucket\": \"\"\n"
|
||||
" },\n"
|
||||
" \"Version\": " +
|
||||
std::to_string(REPERTORY_CONFIG_VERSION) +
|
||||
|
@ -40,10 +40,12 @@
|
||||
#include "utils/time.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
namespace repertory {
|
||||
static std::string file_manager_dir =
|
||||
utils::path::combine(test::get_test_output_dir(), {"file_manager_test"});
|
||||
namespace {
|
||||
const auto file_manager_dir = repertory::utils::path::combine(
|
||||
repertory::test::get_test_output_dir(), {"file_manager_test"});
|
||||
}
|
||||
|
||||
namespace repertory {
|
||||
auto file_manager::open(std::shared_ptr<i_closeable_open_file> of,
|
||||
const open_file_data &ofd, std::uint64_t &handle,
|
||||
std::shared_ptr<i_open_file> &f) -> api_error {
|
||||
@ -81,10 +83,11 @@ TEST(file_manager, can_start_and_stop) {
|
||||
fm.stop();
|
||||
|
||||
ec.wait_for_empty();
|
||||
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
event_system::instance().stop();
|
||||
// EXPECT_TRUE(utils::file::remove_directory(file_manager_dir, true));
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
TEST(file_manager, can_create_and_close_file) {
|
||||
@ -197,10 +200,11 @@ TEST(file_manager, can_create_and_close_file) {
|
||||
EXPECT_EQ(std::size_t(0u), fm.get_open_file_count());
|
||||
|
||||
fm.stop();
|
||||
|
||||
polling::instance().stop();
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
polling::instance().stop();
|
||||
event_system::instance().stop();
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
@ -313,10 +317,11 @@ TEST(file_manager, can_open_and_close_file) {
|
||||
EXPECT_EQ(std::size_t(0u), fm.get_open_file_count());
|
||||
|
||||
fm.stop();
|
||||
|
||||
polling::instance().stop();
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
polling::instance().stop();
|
||||
event_system::instance().stop();
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
@ -386,10 +391,11 @@ TEST(file_manager, can_open_and_close_multiple_handles_for_same_file) {
|
||||
|
||||
EXPECT_EQ(std::size_t(0u), fm.get_open_file_count());
|
||||
EXPECT_EQ(std::size_t(0u), fm.get_open_handle_count());
|
||||
|
||||
polling::instance().stop();
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
polling::instance().stop();
|
||||
event_system::instance().stop();
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
@ -540,9 +546,10 @@ TEST(file_manager, download_is_stored_after_write_if_partially_downloaded) {
|
||||
EXPECT_EQ(std::size_t(0u), fm.get_open_handle_count());
|
||||
|
||||
nf.close();
|
||||
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
event_system::instance().stop();
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
@ -656,15 +663,15 @@ TEST(file_manager, upload_occurs_after_write_if_fully_downloaded) {
|
||||
fm.stop();
|
||||
|
||||
nf.close();
|
||||
|
||||
polling::instance().stop();
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
polling::instance().stop();
|
||||
event_system::instance().stop();
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
TEST(file_manager, can_evict_file) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
{
|
||||
console_consumer c;
|
||||
event_system::instance().start();
|
||||
@ -762,14 +769,14 @@ TEST(file_manager, can_evict_file) {
|
||||
EXPECT_FALSE(utils::file::file(source_path).exists());
|
||||
|
||||
fm.stop();
|
||||
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
event_system::instance().stop();
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
TEST(file_manager, evict_file_fails_if_file_is_pinned) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -788,15 +795,14 @@ TEST(file_manager, evict_file_fails_if_file_is_pinned) {
|
||||
});
|
||||
|
||||
EXPECT_FALSE(fm.evict_file("/test_open.txt"));
|
||||
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
event_system::instance().stop();
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
TEST(file_manager, evict_file_fails_if_provider_is_direct_only) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -811,8 +817,6 @@ TEST(file_manager, evict_file_fails_if_provider_is_direct_only) {
|
||||
}
|
||||
|
||||
TEST(file_manager, evict_file_fails_if_file_is_open) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -862,8 +866,6 @@ TEST(file_manager, evict_file_fails_if_file_is_open) {
|
||||
|
||||
TEST(file_manager,
|
||||
evict_file_fails_if_unable_to_get_source_path_from_item_meta) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -896,8 +898,6 @@ TEST(file_manager,
|
||||
}
|
||||
|
||||
TEST(file_manager, evict_file_fails_if_source_path_is_empty) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -930,7 +930,6 @@ TEST(file_manager, evict_file_fails_if_source_path_is_empty) {
|
||||
}
|
||||
|
||||
TEST(file_manager, evict_file_fails_if_file_is_uploading) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
{
|
||||
console_consumer c;
|
||||
event_system::instance().start();
|
||||
@ -1019,15 +1018,14 @@ TEST(file_manager, evict_file_fails_if_file_is_uploading) {
|
||||
EXPECT_TRUE(utils::file::file(source_path).exists());
|
||||
|
||||
fm.stop();
|
||||
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
event_system::instance().stop();
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
TEST(file_manager, evict_file_fails_if_file_is_in_upload_queue) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1051,8 +1049,6 @@ TEST(file_manager, evict_file_fails_if_file_is_in_upload_queue) {
|
||||
}
|
||||
|
||||
TEST(file_manager, evict_file_fails_if_file_is_modified) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1097,8 +1093,6 @@ TEST(file_manager, evict_file_fails_if_file_is_modified) {
|
||||
}
|
||||
|
||||
TEST(file_manager, evict_file_fails_if_file_is_not_complete) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1145,8 +1139,6 @@ TEST(file_manager, evict_file_fails_if_file_is_not_complete) {
|
||||
}
|
||||
|
||||
TEST(file_manager, can_get_directory_items) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1179,8 +1171,6 @@ TEST(file_manager, can_get_directory_items) {
|
||||
}
|
||||
|
||||
TEST(file_manager, file_is_not_opened_if_provider_create_file_fails) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1215,8 +1205,6 @@ TEST(file_manager, file_is_not_opened_if_provider_create_file_fails) {
|
||||
}
|
||||
|
||||
TEST(file_manager, create_fails_if_provider_create_is_unsuccessful) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1246,9 +1234,6 @@ TEST(file_manager, create_fails_if_provider_create_is_unsuccessful) {
|
||||
}
|
||||
|
||||
TEST(file_manager, get_open_file_fails_if_file_is_not_open) {
|
||||
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1271,8 +1256,6 @@ TEST(file_manager, get_open_file_fails_if_file_is_not_open) {
|
||||
|
||||
TEST(file_manager,
|
||||
get_open_file_promotes_non_writeable_file_if_writeable_is_specified) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1359,8 +1342,6 @@ TEST(file_manager,
|
||||
}
|
||||
|
||||
TEST(file_manager, open_file_fails_if_file_is_not_found) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1384,8 +1365,6 @@ TEST(file_manager, open_file_fails_if_file_is_not_found) {
|
||||
}
|
||||
|
||||
TEST(file_manager, open_file_fails_if_provider_get_filesystem_item_fails) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1428,8 +1407,6 @@ TEST(file_manager, open_file_fails_if_provider_get_filesystem_item_fails) {
|
||||
}
|
||||
|
||||
TEST(file_manager, open_file_fails_if_provider_set_item_meta_fails) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1479,8 +1456,6 @@ TEST(file_manager, open_file_fails_if_provider_set_item_meta_fails) {
|
||||
}
|
||||
|
||||
TEST(file_manager, open_file_creates_source_path_if_empty) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1542,8 +1517,6 @@ TEST(file_manager, open_file_creates_source_path_if_empty) {
|
||||
}
|
||||
|
||||
TEST(file_manager, open_file_first_file_handle_is_not_zero) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1590,8 +1563,6 @@ TEST(file_manager, open_file_first_file_handle_is_not_zero) {
|
||||
}
|
||||
|
||||
TEST(file_manager, can_remove_file) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1631,12 +1602,9 @@ TEST(file_manager, can_remove_file) {
|
||||
}
|
||||
|
||||
TEST(file_manager, can_queue_and_remove_upload) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
console_consumer c;
|
||||
event_system::instance().start();
|
||||
|
||||
{
|
||||
console_consumer c;
|
||||
event_system::instance().start();
|
||||
event_capture ec({"file_upload_queued", "download_resume_removed"});
|
||||
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
@ -1659,9 +1627,10 @@ TEST(file_manager, can_queue_and_remove_upload) {
|
||||
EXPECT_FALSE(fm.is_processing("/test_queue.txt"));
|
||||
|
||||
ec.wait_for_empty();
|
||||
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
event_system::instance().stop();
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
@ -1757,14 +1726,13 @@ TEST(file_manager, file_is_closed_after_download_timeout) {
|
||||
fm.stop();
|
||||
|
||||
polling::instance().stop();
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
event_system::instance().stop();
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
}
|
||||
|
||||
TEST(file_manager, remove_file_fails_if_file_does_not_exist) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
@ -1789,8 +1757,6 @@ TEST(file_manager, remove_file_fails_if_file_does_not_exist) {
|
||||
}
|
||||
|
||||
TEST(file_manager, remove_file_fails_if_provider_remove_file_fails) {
|
||||
EXPECT_TRUE(utils::file::directory(file_manager_dir).remove_recursively());
|
||||
|
||||
{
|
||||
app_config cfg(provider_type::sia, file_manager_dir);
|
||||
cfg.set_enable_chunk_downloader_timeout(false);
|
||||
|
@ -19,6 +19,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#if 0
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include "fixtures/fuse_fixture.hpp"
|
||||
@ -560,3 +561,4 @@ TYPED_TEST(fuse_test, chown) {
|
||||
} // namespace repertory
|
||||
|
||||
#endif // !defined(_WIN32)
|
||||
#endif // 0
|
||||
|
@ -19,6 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#if 0
|
||||
|
||||
#include "test_common.hpp"
|
||||
|
||||
#include "comm/curl/curl_comm.hpp"
|
||||
@ -42,7 +44,7 @@ using gid_t = std::uint32_t;
|
||||
using uid_t = std::uint32_t;
|
||||
static constexpr auto getgid() -> gid_t { return 0U; }
|
||||
static constexpr auto getuid() -> uid_t { return 0U; }
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
const auto check_forced_dirs = [](const repertory::directory_item_list &list) {
|
||||
static auto forced_dirs = std::array<std::string, 2>{".", ".."};
|
||||
@ -747,3 +749,5 @@ TEST(providers, sia_provider) {
|
||||
event_system::instance().stop();
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
#endif // 0
|
||||
|
@ -19,6 +19,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#if 0
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "test_common.hpp"
|
||||
@ -380,4 +381,5 @@ TEST_F(winfsp_test, all_tests) {
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
#endif // 0
|
||||
|
@ -18,6 +18,10 @@ if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_STATIC_LINK}" == "OFF" ]; th
|
||||
/mingw64/bin/zlib1.dll
|
||||
)
|
||||
|
||||
if [ "${PROJECT_ENABLE_BACKWARD_CPP}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/msvcr90.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_BOOST}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libboost*.dll)
|
||||
fi
|
||||
@ -26,10 +30,18 @@ if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_STATIC_LINK}" == "OFF" ]; th
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libcli11*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_CURL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libcurl*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FLAC}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libFLAC*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FMT}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libfmt*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FONTCONFIG}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(
|
||||
/mingw64/bin/libexpat*.dll
|
||||
@ -93,14 +105,26 @@ if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_STATIC_LINK}" == "OFF" ]; th
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libpugi*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_ROCKSDB}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/librocksdb*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SDL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/SDL2*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SECP256K1}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libsecp256k1*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SFML}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libsfml*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SPDLOG}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libspdlog*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SQLITE}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libsqlite3-*.dll)
|
||||
fi
|
||||
@ -116,14 +140,32 @@ if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_STATIC_LINK}" == "OFF" ]; th
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_TPL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libtiny-process*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_VORBIS}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libvorbis*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_WXWIDGETS}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libLerc.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libsharpyuv-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libdeflate.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libglib-2*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libgraphite2.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libharfbuzz-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libjbig-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libpcre2-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libtiff-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libwebp-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libwxbase*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libwxm*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/wxbase*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/wxm*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/lib/gcc_x64_dll/libwxbase*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/lib/gcc_x64_dll/libwxm*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/lib/gcc_x64_dll/wxbase*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/lib/gcc_x64_dll/wxm*.dll)
|
||||
fi
|
||||
|
||||
@ -132,42 +174,13 @@ if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_STATIC_LINK}" == "OFF" ]; th
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(
|
||||
/mingw64/bin/libOpenCL*.dll
|
||||
/mingw64/bin/libopencl*.dll
|
||||
/mingw64/bin/libgallium_wgl.dll
|
||||
/mingw64/bin/libva*.dll
|
||||
/mingw64/bin/opengl*.dll
|
||||
/mingw64/bin/vulkan*.dll
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_IS_MINGW_UNIX}" == "1" ]; then
|
||||
if [ "${PROJECT_ENABLE_BACKWARD_CPP}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/msvcr90.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FMT}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libfmt*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_CURL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libcurl*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_ROCKSDB}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/librocksdb*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SECP256K1}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libsecp256k1*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SPDLOG}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libspdlog*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_TPL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libtiny-process*.dll)
|
||||
fi
|
||||
fi
|
||||
|
||||
rsync -av --progress ${PROJECT_EXTERNAL_BUILD_ROOT}/bin/*.dll "${PROJECT_DIST_DIR}/"
|
||||
rsync -av --progress ${PROJECT_EXTERNAL_BUILD_ROOT}/lib/*.dll "${PROJECT_DIST_DIR}/"
|
||||
if [ "${PROJECT_ENABLE_WXWIDGETS}" == "ON" ]; then
|
||||
@ -175,7 +188,7 @@ if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_STATIC_LINK}" == "OFF" ]; th
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_ENABLE_WINFSP}" == "ON" ]; then
|
||||
if [ "${PROJECT_ENABLE_WINFSP}" == "ON" ]; then
|
||||
if [ "${PROJECT_BUILD_ARCH}" == "x86_64" ]; then
|
||||
WINFSP_DLL_PART=x64
|
||||
fi
|
||||
@ -185,7 +198,7 @@ if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_ENABLE_WINFSP}" == "ON" ]; t
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_ENABLE_VLC}" == "ON" ]; then
|
||||
if [ "${PROJECT_ENABLE_VLC}" == "ON" ]; then
|
||||
rsync -av --progress ${PROJECT_3RD_PARTY_DIR}/vlc/ "${PROJECT_DIST_DIR}/vlc/"
|
||||
fi
|
||||
|
||||
|
@ -121,6 +121,7 @@ if [ "${PROJECT_ENABLE_VORBIS}" == "ON" ]; then
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FLAC}" == "ON" ]; then
|
||||
PROJECT_ENABLE_LIBICONV=ON
|
||||
PROJECT_ENABLE_OGG=ON
|
||||
PROJECT_ENABLE_VORBIS=ON
|
||||
fi
|
||||
|
@ -73,11 +73,9 @@ inline auto includes(const col_t &collection,
|
||||
template <typename val_t>
|
||||
[[nodiscard]] inline auto from_hex_string_t(std::string_view str,
|
||||
val_t &val) -> bool {
|
||||
static constexpr const auto base16{16};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
static constexpr const auto base16{16};
|
||||
|
||||
try {
|
||||
val.clear();
|
||||
|
@ -26,20 +26,27 @@
|
||||
#include "utils/config.hpp"
|
||||
|
||||
namespace repertory::utils {
|
||||
class com_init_wrapper {
|
||||
public:
|
||||
struct com_init_wrapper final {
|
||||
com_init_wrapper()
|
||||
: uninit_(
|
||||
: initialized_(
|
||||
SUCCEEDED(::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) {}
|
||||
|
||||
com_init_wrapper(const com_init_wrapper &) = delete;
|
||||
com_init_wrapper(com_init_wrapper &&) = delete;
|
||||
|
||||
~com_init_wrapper() {
|
||||
if (uninit_) {
|
||||
if (initialized_) {
|
||||
::CoUninitialize();
|
||||
}
|
||||
}
|
||||
|
||||
auto operator=(const com_init_wrapper &) -> com_init_wrapper & = delete;
|
||||
auto operator=(com_init_wrapper &&) -> com_init_wrapper & = delete;
|
||||
|
||||
[[nodiscard]] auto is_initialized() const -> bool { return initialized_; }
|
||||
|
||||
private:
|
||||
BOOL uninit_;
|
||||
BOOL initialized_;
|
||||
};
|
||||
} // namespace repertory::utils
|
||||
|
||||
|
@ -38,7 +38,9 @@
|
||||
#endif // defined(PROJECT_ENABLE_WINFSP)
|
||||
|
||||
#include <direct.h>
|
||||
#if !defined(__cplusplus)
|
||||
#include <errno.h>
|
||||
#endif // !defined(__cplusplus)
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <iphlpapi.h>
|
||||
@ -49,10 +51,14 @@
|
||||
#include <shellapi.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#if !defined(__cplusplus)
|
||||
#include <stdio.h>
|
||||
#endif // !defined(__cplusplus)
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#if !defined(__cplusplus)
|
||||
#include <time.h>
|
||||
#endif // !defined(__cplusplus)
|
||||
#else // !defined(_WIN32)
|
||||
#include <arpa/inet.h>
|
||||
#include <dirent.h>
|
||||
@ -65,9 +71,9 @@
|
||||
#include <sys/socket.h>
|
||||
#if defined(__LFS64__)
|
||||
#include <sys/stat64.h>
|
||||
#else
|
||||
#else // !defined(__LFS64__)
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#endif // defined(__LFS64__)
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <sys/statfs.h>
|
||||
@ -98,6 +104,7 @@
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <bit>
|
||||
#include <cerrno>
|
||||
#include <chrono>
|
||||
#include <ciso646>
|
||||
#include <climits>
|
||||
@ -105,9 +112,11 @@
|
||||
#include <condition_variable>
|
||||
#include <csignal>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <ctime>
|
||||
#include <deque>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@ -466,4 +475,9 @@ using http_ranges = std::vector<http_range>;
|
||||
} // namespace repertory
|
||||
#endif // defined(__cplusplus)
|
||||
|
||||
#define REPERTORY_USES_FUNCTION_NAME() \
|
||||
static constexpr const std::string_view function_name{ \
|
||||
static_cast<const char *>(__FUNCTION__), \
|
||||
}
|
||||
|
||||
#endif // REPERTORY_INCLUDE_UTILS_CONFIG_HPP_
|
||||
|
@ -31,7 +31,11 @@ using db_types_t = std::variant<std::int64_t, std::string>;
|
||||
struct sqlite3_deleter {
|
||||
void operator()(sqlite3 *db3) const {
|
||||
if (db3 != nullptr) {
|
||||
#if defined(_WIN32)
|
||||
sqlite3_close(db3);
|
||||
#else // !defined(_WIN32)
|
||||
sqlite3_close_v2(db3);
|
||||
#endif // defined(_WIN32)
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -183,8 +187,6 @@ template <typename ctx_t> struct db_result final {
|
||||
}
|
||||
}
|
||||
|
||||
~db_result() { context_->clear(); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<ctx_t> context_;
|
||||
mutable std::int32_t res_;
|
||||
|
@ -43,12 +43,9 @@ public:
|
||||
: db_context_t(db3_, table_name_) {}
|
||||
|
||||
using w_t = db_where_t<context, db_delete_op_t>;
|
||||
using wd_t = where_data_t<w_t>;
|
||||
|
||||
std::optional<w_t> where;
|
||||
std::map<std::size_t, std::vector<w_t::action_t>> where_actions;
|
||||
std::vector<db_types_t> where_values;
|
||||
|
||||
void clear();
|
||||
std::unique_ptr<wd_t> where_data;
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
@ -67,8 +64,8 @@ public:
|
||||
|
||||
[[nodiscard]] auto go() const -> db_result<context>;
|
||||
|
||||
[[nodiscard]] auto
|
||||
group(context::w_t::group_func_t func) -> context::w_t::wn_t;
|
||||
[[nodiscard]] auto group(context::w_t::group_func_t func)
|
||||
-> context::w_t::wn_t;
|
||||
|
||||
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
|
||||
};
|
||||
|
@ -34,8 +34,6 @@ public:
|
||||
|
||||
bool or_replace{false};
|
||||
std::map<std::string, db_types_t> values;
|
||||
|
||||
void clear() { values.clear(); }
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
|
@ -44,14 +44,15 @@ public:
|
||||
|
||||
[[nodiscard]] auto offset(std::int32_t value) -> db_select_op_t;
|
||||
|
||||
[[nodiscard]] auto order_by(std::string column_name,
|
||||
bool ascending) -> db_select_op_t;
|
||||
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
||||
-> db_select_op_t;
|
||||
};
|
||||
|
||||
context(sqlite3 *db3_, std::string table_name_)
|
||||
: db_context_t(db3_, table_name_) {}
|
||||
|
||||
using w_t = db_where_t<context, db_select_op_t>;
|
||||
using wd_t = where_data_t<w_t>;
|
||||
|
||||
std::vector<std::string> columns;
|
||||
std::map<std::string, std::string> count_columns;
|
||||
@ -60,11 +61,8 @@ public:
|
||||
std::optional<std::int32_t> limit;
|
||||
std::optional<std::int32_t> offset;
|
||||
std::optional<std::pair<std::string, bool>> order_by;
|
||||
std::optional<w_t> where;
|
||||
std::map<std::size_t, std::vector<w_t::action_t>> where_actions;
|
||||
std::vector<db_types_t> where_values;
|
||||
|
||||
void clear();
|
||||
std::unique_ptr<wd_t> where_data;
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
@ -81,8 +79,8 @@ private:
|
||||
public:
|
||||
[[nodiscard]] auto column(std::string column_name) -> db_select &;
|
||||
|
||||
[[nodiscard]] auto count(std::string column_name,
|
||||
std::string as_column_name) -> db_select &;
|
||||
[[nodiscard]] auto count(std::string column_name, std::string as_column_name)
|
||||
-> db_select &;
|
||||
|
||||
[[nodiscard]] auto dump() const -> std::string;
|
||||
|
||||
@ -90,15 +88,15 @@ public:
|
||||
|
||||
[[nodiscard]] auto group_by(std::string column_name) -> db_select &;
|
||||
|
||||
[[nodiscard]] auto
|
||||
group(context::w_t::group_func_t func) -> context::w_t::wn_t;
|
||||
[[nodiscard]] auto group(context::w_t::group_func_t func)
|
||||
-> context::w_t::wn_t;
|
||||
|
||||
[[nodiscard]] auto limit(std::int32_t value) -> db_select &;
|
||||
|
||||
[[nodiscard]] auto offset(std::int32_t value) -> db_select &;
|
||||
|
||||
[[nodiscard]] auto order_by(std::string column_name,
|
||||
bool ascending) -> db_select &;
|
||||
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
||||
-> db_select &;
|
||||
|
||||
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
|
||||
};
|
||||
|
@ -43,20 +43,18 @@ public:
|
||||
|
||||
[[nodiscard]] auto limit(std::int32_t value) -> db_update_op_t;
|
||||
|
||||
[[nodiscard]] auto order_by(std::string column_name,
|
||||
bool ascending) -> db_update_op_t;
|
||||
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
||||
-> db_update_op_t;
|
||||
};
|
||||
|
||||
using w_t = db_where_t<context, db_update_op_t>;
|
||||
using wd_t = where_data_t<w_t>;
|
||||
|
||||
std::map<std::string, db_types_t> column_values;
|
||||
std::optional<std::int32_t> limit;
|
||||
std::optional<std::pair<std::string, bool>> order_by;
|
||||
std::optional<w_t> where;
|
||||
std::map<std::size_t, std::vector<w_t::action_t>> where_actions;
|
||||
std::vector<db_types_t> where_values;
|
||||
|
||||
void clear();
|
||||
std::unique_ptr<wd_t> where_data;
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
@ -71,20 +69,20 @@ private:
|
||||
std::shared_ptr<context> context_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto column_value(std::string column_name,
|
||||
db_types_t value) -> db_update &;
|
||||
[[nodiscard]] auto column_value(std::string column_name, db_types_t value)
|
||||
-> db_update &;
|
||||
|
||||
[[nodiscard]] auto dump() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto go() const -> db_result<context>;
|
||||
|
||||
[[nodiscard]] auto
|
||||
group(context::w_t::group_func_t func) -> context::w_t::wn_t;
|
||||
[[nodiscard]] auto group(context::w_t::group_func_t func)
|
||||
-> context::w_t::wn_t;
|
||||
|
||||
[[nodiscard]] auto limit(std::int32_t value) -> db_update &;
|
||||
|
||||
[[nodiscard]] auto order_by(std::string column_name,
|
||||
bool ascending) -> db_update &;
|
||||
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
||||
-> db_update &;
|
||||
|
||||
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
|
||||
};
|
||||
|
@ -26,6 +26,12 @@
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
||||
|
||||
namespace repertory::utils::db::sqlite {
|
||||
template <typename w_t> struct where_data_t final {
|
||||
w_t base;
|
||||
std::map<std::size_t, std::vector<typename w_t::action_t>> actions;
|
||||
std::vector<db_types_t> values;
|
||||
};
|
||||
|
||||
template <typename cn_t, typename ctx_t, typename op_t, typename w_t,
|
||||
typename wn_t>
|
||||
struct db_next_t final {
|
||||
@ -42,7 +48,7 @@ struct db_next_t final {
|
||||
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
|
||||
|
||||
[[nodiscard]] auto dump(std::int32_t &idx) const -> std::string {
|
||||
return ctx->where->dump(idx);
|
||||
return ctx->where_data->base.dump(idx);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto go() const -> auto { return op_t{ctx}.go(); }
|
||||
@ -72,14 +78,14 @@ struct db_where_next_t final {
|
||||
"AND",
|
||||
};
|
||||
|
||||
ctx->where_actions[action_idx].emplace_back(next);
|
||||
ctx->where_data->actions[action_idx].emplace_back(next);
|
||||
return next;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
|
||||
|
||||
[[nodiscard]] auto dump(std::int32_t &idx) const -> std::string {
|
||||
return ctx->where->dump(idx);
|
||||
return ctx->where_data->base.dump(idx);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto go() const -> auto { return op_t{ctx}.go(); }
|
||||
@ -97,7 +103,7 @@ struct db_where_next_t final {
|
||||
"OR",
|
||||
};
|
||||
|
||||
ctx->where_actions[action_idx].emplace_back(next);
|
||||
ctx->where_data->actions[action_idx].emplace_back(next);
|
||||
return next;
|
||||
}
|
||||
};
|
||||
@ -111,12 +117,12 @@ struct db_comp_next_t final {
|
||||
using wn_t = db_where_next_t<db_comp_next_t, ctx_t, op_t, w_t>;
|
||||
|
||||
[[nodiscard]] auto create(std::string operation, db_types_t value) {
|
||||
ctx->where_actions[action_idx].emplace_back(db_comp_data_t{
|
||||
ctx->where_data->actions[action_idx].emplace_back(db_comp_data_t{
|
||||
column_name,
|
||||
operation,
|
||||
});
|
||||
|
||||
ctx->where_values.push_back(value);
|
||||
ctx->where_data->values.push_back(value);
|
||||
|
||||
return wn_t{
|
||||
action_idx,
|
||||
@ -151,8 +157,8 @@ template <typename ctx_t, typename op_t> struct db_where_t final {
|
||||
|
||||
using action_t = std::variant<db_comp_data_t, n_t, db_where_t>;
|
||||
|
||||
[[nodiscard]] static auto dump(std::int32_t &idx,
|
||||
auto &&actions) -> std::string {
|
||||
[[nodiscard]] static auto dump(std::int32_t &idx, auto &&actions)
|
||||
-> std::string {
|
||||
std::stringstream stream;
|
||||
|
||||
for (auto &&action : actions) {
|
||||
@ -177,24 +183,24 @@ template <typename ctx_t, typename op_t> struct db_where_t final {
|
||||
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
|
||||
|
||||
[[nodiscard]] auto dump(std::int32_t &idx) const -> std::string {
|
||||
return dump(idx, ctx->where_actions[action_idx]);
|
||||
return dump(idx, ctx->where_data->actions[action_idx]);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_actions() -> auto & {
|
||||
return ctx->where_actions[action_idx];
|
||||
return ctx->where_data->actions[action_idx];
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_actions() const -> const auto & {
|
||||
return ctx->where_actions[action_idx];
|
||||
return ctx->where_data->actions[action_idx];
|
||||
}
|
||||
|
||||
[[nodiscard]] auto group(group_func_t func) -> wn_t {
|
||||
ctx->where_actions[action_idx];
|
||||
ctx->where_data->actions[action_idx];
|
||||
|
||||
db_where_t where{ctx->where_actions.size(), ctx};
|
||||
db_where_t where{ctx->where_data->actions.size(), ctx};
|
||||
func(where);
|
||||
|
||||
ctx->where_actions[action_idx].emplace_back(where);
|
||||
ctx->where_data->actions[action_idx].emplace_back(where);
|
||||
|
||||
return wn_t{
|
||||
action_idx,
|
||||
@ -203,7 +209,7 @@ template <typename ctx_t, typename op_t> struct db_where_t final {
|
||||
}
|
||||
|
||||
[[nodiscard]] auto where(std::string column_name) -> cn_t {
|
||||
ctx->where_actions[action_idx];
|
||||
ctx->where_data->actions[action_idx];
|
||||
|
||||
return cn_t{
|
||||
action_idx,
|
||||
|
@ -33,6 +33,9 @@ struct i_exception_handler {
|
||||
auto operator=(const i_exception_handler &) noexcept = delete;
|
||||
auto operator=(i_exception_handler &&) noexcept = delete;
|
||||
|
||||
virtual void handle_error(std::string_view function_name,
|
||||
std::string_view msg) const = 0;
|
||||
|
||||
virtual void handle_exception(std::string_view function_name) const = 0;
|
||||
|
||||
virtual void handle_exception(std::string_view function_name,
|
||||
@ -43,6 +46,11 @@ protected:
|
||||
};
|
||||
|
||||
struct iostream_exception_handler final : i_exception_handler {
|
||||
void handle_error(std::string_view function_name,
|
||||
std::string_view msg) const override {
|
||||
std::cerr << function_name << '|' << msg;
|
||||
}
|
||||
|
||||
void handle_exception(std::string_view function_name) const override {
|
||||
std::cerr << function_name << "|exception|unknown" << std::endl;
|
||||
}
|
||||
@ -58,12 +66,18 @@ inline const iostream_exception_handler default_exception_handler{};
|
||||
extern std::atomic<const i_exception_handler *> exception_handler;
|
||||
|
||||
#if defined(PROJECT_ENABLE_TESTING)
|
||||
[[nodiscard]] inline auto
|
||||
get_exception_handler() -> const i_exception_handler * {
|
||||
[[nodiscard]] inline auto get_exception_handler()
|
||||
-> const i_exception_handler * {
|
||||
return exception_handler;
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_TESTING)
|
||||
|
||||
[[nodiscard]] auto create_error_message(std::string_view function_name,
|
||||
std::vector<std::string_view> items)
|
||||
-> std::string;
|
||||
|
||||
void handle_error(std::string_view function_name, std::string_view msg);
|
||||
|
||||
void handle_exception(std::string_view function_name);
|
||||
|
||||
void handle_exception(std::string_view function_name, const std::exception &ex);
|
||||
|
@ -26,6 +26,10 @@
|
||||
#include "utils/config.hpp"
|
||||
|
||||
namespace repertory::utils {
|
||||
void create_console();
|
||||
|
||||
void free_console();
|
||||
|
||||
[[nodiscard]] auto get_local_app_data_directory() -> const std::string &;
|
||||
|
||||
[[nodiscard]] auto get_last_error_code() -> DWORD;
|
||||
|
@ -153,9 +153,7 @@ auto get_next_available_port(std::uint16_t first_port,
|
||||
|
||||
auto retry_action(retryable_action_t action, std::size_t retry_count,
|
||||
std::chrono::milliseconds retry_wait) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
for (std::size_t idx = 0U; idx < retry_count; ++idx) {
|
||||
|
@ -24,11 +24,6 @@
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
|
||||
namespace repertory::utils::db::sqlite {
|
||||
void db_delete::context::clear() {
|
||||
where.reset();
|
||||
where_values.clear();
|
||||
}
|
||||
|
||||
auto db_delete::context::db_delete_op_t::dump() const -> std::string {
|
||||
return db_delete{ctx}.dump();
|
||||
}
|
||||
@ -41,9 +36,9 @@ auto db_delete::dump() const -> std::string {
|
||||
std::stringstream query;
|
||||
query << "DELETE FROM \"" << context_->table_name << "\"";
|
||||
|
||||
if (context_->where.has_value()) {
|
||||
if (context_->where_data) {
|
||||
std::int32_t idx{};
|
||||
query << " WHERE " << context_->where->dump(idx);
|
||||
query << " WHERE " << context_->where_data->base.dump(idx);
|
||||
}
|
||||
|
||||
query << ';';
|
||||
@ -65,8 +60,13 @@ auto db_delete::go() const -> db_result<context> {
|
||||
return {context_, res};
|
||||
}
|
||||
|
||||
if (not context_->where_data) {
|
||||
return {context_, res};
|
||||
}
|
||||
|
||||
for (std::int32_t idx = 0;
|
||||
idx < static_cast<std::int32_t>(context_->where_values.size()); idx++) {
|
||||
idx < static_cast<std::int32_t>(context_->where_data->values.size());
|
||||
idx++) {
|
||||
res = std::visit(
|
||||
overloaded{
|
||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
||||
@ -77,7 +77,7 @@ auto db_delete::go() const -> db_result<context> {
|
||||
data.c_str(), -1, nullptr);
|
||||
},
|
||||
},
|
||||
context_->where_values.at(static_cast<std::size_t>(idx)));
|
||||
context_->where_data->values.at(static_cast<std::size_t>(idx)));
|
||||
if (res != SQLITE_OK) {
|
||||
return {context_, res};
|
||||
}
|
||||
@ -87,19 +87,23 @@ auto db_delete::go() const -> db_result<context> {
|
||||
}
|
||||
|
||||
auto db_delete::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{0U, context_};
|
||||
if (not context_->where_data) {
|
||||
context_->where_data = std::make_unique<context::wd_t>(context::wd_t{
|
||||
context::w_t{0U, context_},
|
||||
});
|
||||
}
|
||||
|
||||
return context_->where->group(std::move(func));
|
||||
return context_->where_data->base.group(std::move(func));
|
||||
}
|
||||
|
||||
auto db_delete::where(std::string column_name) const -> context::w_t::cn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{0U, context_};
|
||||
if (not context_->where_data) {
|
||||
context_->where_data = std::make_unique<context::wd_t>(context::wd_t{
|
||||
context::w_t{0U, context_},
|
||||
});
|
||||
}
|
||||
|
||||
return context_->where->where(column_name);
|
||||
return context_->where_data->base.where(column_name);
|
||||
}
|
||||
} // namespace repertory::utils::db::sqlite
|
||||
|
||||
|
@ -24,16 +24,6 @@
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
|
||||
namespace repertory::utils::db::sqlite {
|
||||
void db_select::context::clear() {
|
||||
columns.clear();
|
||||
count_columns.clear();
|
||||
limit.reset();
|
||||
offset.reset();
|
||||
order_by.reset();
|
||||
where.reset();
|
||||
where_values.clear();
|
||||
}
|
||||
|
||||
auto db_select::context::db_select_op_t::dump() const -> std::string {
|
||||
return db_select{ctx}.dump();
|
||||
}
|
||||
@ -72,8 +62,8 @@ auto db_select::column(std::string column_name) -> db_select & {
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto db_select::count(std::string column_name,
|
||||
std::string as_column_name) -> db_select & {
|
||||
auto db_select::count(std::string column_name, std::string as_column_name)
|
||||
-> db_select & {
|
||||
context_->count_columns[column_name] = as_column_name;
|
||||
return *this;
|
||||
}
|
||||
@ -108,9 +98,9 @@ auto db_select::dump() const -> std::string {
|
||||
}
|
||||
query << " FROM \"" << context_->table_name << "\"";
|
||||
|
||||
if (context_->where.has_value()) {
|
||||
if (context_->where_data) {
|
||||
std::int32_t idx{};
|
||||
query << " WHERE " << context_->where->dump(idx);
|
||||
query << " WHERE " << context_->where_data->base.dump(idx);
|
||||
}
|
||||
|
||||
if (not context_->group_by.empty()) {
|
||||
@ -156,8 +146,13 @@ auto db_select::go() const -> db_result<context> {
|
||||
return {context_, res};
|
||||
}
|
||||
|
||||
if (not context_->where_data) {
|
||||
return {context_, res};
|
||||
}
|
||||
|
||||
for (std::int32_t idx = 0;
|
||||
idx < static_cast<std::int32_t>(context_->where_values.size()); idx++) {
|
||||
idx < static_cast<std::int32_t>(context_->where_data->values.size());
|
||||
idx++) {
|
||||
res = std::visit(
|
||||
overloaded{
|
||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
||||
@ -168,7 +163,7 @@ auto db_select::go() const -> db_result<context> {
|
||||
data.c_str(), -1, nullptr);
|
||||
},
|
||||
},
|
||||
context_->where_values.at(static_cast<std::size_t>(idx)));
|
||||
context_->where_data->values.at(static_cast<std::size_t>(idx)));
|
||||
if (res != SQLITE_OK) {
|
||||
return {context_, res};
|
||||
}
|
||||
@ -178,11 +173,13 @@ auto db_select::go() const -> db_result<context> {
|
||||
}
|
||||
|
||||
auto db_select::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{0U, context_};
|
||||
if (not context_->where_data) {
|
||||
context_->where_data = std::make_unique<context::wd_t>(context::wd_t{
|
||||
context::w_t{0U, context_},
|
||||
});
|
||||
}
|
||||
|
||||
return context_->where->group(std::move(func));
|
||||
return context_->where_data->base.group(std::move(func));
|
||||
}
|
||||
|
||||
auto db_select::group_by(std::string column_name) -> db_select & {
|
||||
@ -200,18 +197,20 @@ auto db_select::offset(std::int32_t value) -> db_select & {
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto db_select::order_by(std::string column_name,
|
||||
bool ascending) -> db_select & {
|
||||
auto db_select::order_by(std::string column_name, bool ascending)
|
||||
-> db_select & {
|
||||
context_->order_by = {column_name, ascending};
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto db_select::where(std::string column_name) const -> context::w_t::cn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{0U, context_};
|
||||
if (not context_->where_data) {
|
||||
context_->where_data = std::make_unique<context::wd_t>(context::wd_t{
|
||||
context::w_t{0U, context_},
|
||||
});
|
||||
}
|
||||
|
||||
return context_->where->where(column_name);
|
||||
return context_->where_data->base.where(column_name);
|
||||
}
|
||||
} // namespace repertory::utils::db::sqlite
|
||||
|
||||
|
@ -24,14 +24,6 @@
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
|
||||
namespace repertory::utils::db::sqlite {
|
||||
void db_update::context::clear() {
|
||||
column_values.clear();
|
||||
limit.reset();
|
||||
order_by.reset();
|
||||
where.reset();
|
||||
where_values.clear();
|
||||
}
|
||||
|
||||
auto db_update::context::db_update_op_t::dump() const -> std::string {
|
||||
return db_update{ctx}.dump();
|
||||
}
|
||||
@ -53,8 +45,8 @@ auto db_update::context::db_update_op_t::order_by(std::string column_name,
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto db_update::column_value(std::string column_name,
|
||||
db_types_t value) -> db_update & {
|
||||
auto db_update::column_value(std::string column_name, db_types_t value)
|
||||
-> db_update & {
|
||||
context_->column_values[column_name] = value;
|
||||
return *this;
|
||||
}
|
||||
@ -73,9 +65,9 @@ auto db_update::dump() const -> std::string {
|
||||
query << '"' << column->first << "\"=?" + std::to_string(idx + 1);
|
||||
}
|
||||
|
||||
if (context_->where.has_value()) {
|
||||
if (context_->where_data) {
|
||||
auto idx{static_cast<std::int32_t>(context_->column_values.size())};
|
||||
query << " WHERE " << context_->where->dump(idx);
|
||||
query << " WHERE " << context_->where_data->base.dump(idx);
|
||||
}
|
||||
|
||||
if (context_->order_by.has_value()) {
|
||||
@ -124,29 +116,34 @@ auto db_update::go() const -> db_result<context> {
|
||||
}
|
||||
}
|
||||
|
||||
if (not context_->where_data) {
|
||||
return {context_, res};
|
||||
}
|
||||
|
||||
for (std::int32_t idx = 0;
|
||||
idx < static_cast<std::int32_t>(context_->where_values.size()); idx++) {
|
||||
res = std::visit(overloaded{
|
||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
||||
return sqlite3_bind_int64(
|
||||
context_->stmt.get(),
|
||||
idx +
|
||||
static_cast<std::int32_t>(
|
||||
context_->column_values.size()) +
|
||||
1,
|
||||
data);
|
||||
},
|
||||
[this, &idx](const std::string &data) -> std::int32_t {
|
||||
return sqlite3_bind_text(
|
||||
context_->stmt.get(),
|
||||
idx +
|
||||
static_cast<std::int32_t>(
|
||||
context_->column_values.size()) +
|
||||
1,
|
||||
data.c_str(), -1, nullptr);
|
||||
},
|
||||
},
|
||||
context_->where_values.at(static_cast<std::size_t>(idx)));
|
||||
idx < static_cast<std::int32_t>(context_->where_data->values.size());
|
||||
idx++) {
|
||||
res = std::visit(
|
||||
overloaded{
|
||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
||||
return sqlite3_bind_int64(
|
||||
context_->stmt.get(),
|
||||
idx +
|
||||
static_cast<std::int32_t>(
|
||||
context_->column_values.size()) +
|
||||
1,
|
||||
data);
|
||||
},
|
||||
[this, &idx](const std::string &data) -> std::int32_t {
|
||||
return sqlite3_bind_text(context_->stmt.get(),
|
||||
idx +
|
||||
static_cast<std::int32_t>(
|
||||
context_->column_values.size()) +
|
||||
1,
|
||||
data.c_str(), -1, nullptr);
|
||||
},
|
||||
},
|
||||
context_->where_data->values.at(static_cast<std::size_t>(idx)));
|
||||
if (res != SQLITE_OK) {
|
||||
return {context_, res};
|
||||
}
|
||||
@ -156,11 +153,13 @@ auto db_update::go() const -> db_result<context> {
|
||||
}
|
||||
|
||||
auto db_update::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{0U, context_};
|
||||
if (not context_->where_data) {
|
||||
context_->where_data = std::make_unique<context::wd_t>(context::wd_t{
|
||||
context::w_t{0U, context_},
|
||||
});
|
||||
}
|
||||
|
||||
return context_->where->group(std::move(func));
|
||||
return context_->where_data->base.group(std::move(func));
|
||||
}
|
||||
|
||||
auto db_update::limit(std::int32_t value) -> db_update & {
|
||||
@ -168,18 +167,20 @@ auto db_update::limit(std::int32_t value) -> db_update & {
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto db_update::order_by(std::string column_name,
|
||||
bool ascending) -> db_update & {
|
||||
auto db_update::order_by(std::string column_name, bool ascending)
|
||||
-> db_update & {
|
||||
context_->order_by = {column_name, ascending};
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto db_update::where(std::string column_name) const -> context::w_t::cn_t {
|
||||
if (not context_->where.has_value()) {
|
||||
context_->where = context::w_t{0U, context_};
|
||||
if (not context_->where_data) {
|
||||
context_->where_data = std::make_unique<context::wd_t>(context::wd_t{
|
||||
context::w_t{0U, context_},
|
||||
});
|
||||
}
|
||||
|
||||
return context_->where->where(column_name);
|
||||
return context_->where_data->base.where(column_name);
|
||||
}
|
||||
} // namespace repertory::utils::db::sqlite
|
||||
|
||||
|
@ -352,9 +352,7 @@ auto encrypting_reader::create_iostream() const
|
||||
|
||||
auto encrypting_reader::reader_function(char *buffer, size_t size,
|
||||
size_t nitems) -> size_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto read_size = static_cast<std::size_t>(std::min(
|
||||
static_cast<std::uint64_t>(size * nitems), total_size_ - read_offset_));
|
||||
|
@ -25,6 +25,27 @@ namespace repertory::utils::error {
|
||||
std::atomic<const i_exception_handler *> exception_handler{
|
||||
&default_exception_handler};
|
||||
|
||||
auto create_error_message(std::string_view function_name,
|
||||
std::vector<std::string_view> items) -> std::string {
|
||||
std::stringstream stream{};
|
||||
stream << function_name;
|
||||
for (auto &&item : items) {
|
||||
stream << '|' << item;
|
||||
}
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
void handle_error(std::string_view function_name, std::string_view msg) {
|
||||
const i_exception_handler *handler{exception_handler};
|
||||
if (handler != nullptr) {
|
||||
handler->handle_error(function_name, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
default_exception_handler.handle_error(function_name, msg);
|
||||
}
|
||||
|
||||
void handle_exception(std::string_view function_name) {
|
||||
const i_exception_handler *handler{exception_handler};
|
||||
if (handler != nullptr) {
|
||||
|
@ -32,9 +32,7 @@
|
||||
|
||||
namespace repertory::utils::file {
|
||||
auto change_to_process_directory() -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
#if defined(_WIN32)
|
||||
@ -100,9 +98,7 @@ auto create_temp_name(std::wstring_view file_part) -> std::wstring {
|
||||
|
||||
auto get_free_drive_space(std::string_view path)
|
||||
-> std::optional<std::uint64_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
#if defined(_WIN32)
|
||||
@ -168,9 +164,7 @@ auto get_time(std::wstring_view path,
|
||||
}
|
||||
|
||||
auto get_times(std::string_view path) -> std::optional<file_times> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
file_times ret{};
|
||||
@ -244,9 +238,7 @@ auto get_times(std::wstring_view path) -> std::optional<file_times> {
|
||||
|
||||
auto get_total_drive_space(std::string_view path)
|
||||
-> std::optional<std::uint64_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
#if defined(_WIN32)
|
||||
@ -337,9 +329,7 @@ auto read_json_file(std::string_view path, nlohmann::json &data,
|
||||
#else // !defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
|
||||
auto read_json_file(std::string_view path, nlohmann::json &data) -> bool {
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto abs_path = utils::path::absolute(path);
|
||||
@ -395,9 +385,7 @@ auto write_json_file(std::string_view path, const nlohmann::json &data,
|
||||
auto write_json_file(std::string_view path,
|
||||
const nlohmann::json &data) -> bool {
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto file = file::open_or_create_file(path);
|
||||
|
@ -35,7 +35,7 @@ auto traverse_directory(
|
||||
auto res{true};
|
||||
|
||||
const auto is_stop_requested = [&stop_requested]() -> bool {
|
||||
return (stop_requested != nullptr && !*stop_requested);
|
||||
return (stop_requested != nullptr && *stop_requested);
|
||||
};
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -94,11 +94,9 @@ auto traverse_directory(
|
||||
} // namespace
|
||||
|
||||
namespace repertory::utils::file {
|
||||
auto directory::copy_to(std::string_view new_path,
|
||||
bool overwrite) const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto directory::copy_to(std::string_view new_path, bool overwrite) const
|
||||
-> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
throw std::runtime_error("failed to copy directory|" + path_ + '|' +
|
||||
@ -114,9 +112,7 @@ auto directory::copy_to(std::string_view new_path,
|
||||
}
|
||||
|
||||
auto directory::count(bool recursive) const -> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
std::uint64_t ret{0U};
|
||||
@ -149,9 +145,7 @@ auto directory::count(bool recursive) const -> std::uint64_t {
|
||||
|
||||
auto directory::create_directory(std::string_view path) const
|
||||
-> fs_directory_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto abs_path = utils::path::combine(path_, {path});
|
||||
@ -184,7 +178,7 @@ auto directory::create_directory(std::string_view path) const
|
||||
auto status = mkdir(current_path.c_str(), S_IRWXU);
|
||||
ret = ((status == 0) || (errno == EEXIST));
|
||||
}
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
return std::make_unique<directory>(abs_path);
|
||||
} catch (const std::exception &e) {
|
||||
@ -200,7 +194,7 @@ auto directory::exists() const -> bool {
|
||||
#if defined(_WIN32)
|
||||
return ::PathIsDirectoryA(path_.c_str()) != 0;
|
||||
#else // !defined(_WIN32)
|
||||
struct stat64 st {};
|
||||
struct stat64 st{};
|
||||
return (stat64(path_.c_str(), &st) == 0 && S_ISDIR(st.st_mode));
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
@ -208,9 +202,7 @@ auto directory::exists() const -> bool {
|
||||
}
|
||||
|
||||
auto directory::get_directory(std::string_view path) const -> fs_directory_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto dir_path = utils::path::combine(path_, {path});
|
||||
@ -229,9 +221,7 @@ auto directory::get_directory(std::string_view path) const -> fs_directory_t {
|
||||
}
|
||||
|
||||
auto directory::get_directories() const -> std::vector<fs_directory_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
std::vector<fs_directory_t> ret{};
|
||||
@ -257,11 +247,9 @@ auto directory::get_directories() const -> std::vector<fs_directory_t> {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto directory::create_file(std::string_view file_name,
|
||||
bool read_only) const -> fs_file_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
auto directory::create_file(std::string_view file_name, bool read_only) const
|
||||
-> fs_file_t {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto file_path = utils::path::combine(path_, {file_name});
|
||||
@ -276,9 +264,7 @@ auto directory::create_file(std::string_view file_name,
|
||||
}
|
||||
|
||||
auto directory::get_file(std::string_view path) const -> fs_file_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto file_path = utils::path::combine(path_, {path});
|
||||
@ -295,9 +281,7 @@ auto directory::get_file(std::string_view path) const -> fs_file_t {
|
||||
}
|
||||
|
||||
auto directory::get_files() const -> std::vector<fs_file_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
std::vector<fs_file_t> ret{};
|
||||
@ -323,9 +307,7 @@ auto directory::get_files() const -> std::vector<fs_file_t> {
|
||||
}
|
||||
|
||||
auto directory::get_items() const -> std::vector<fs_item_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
std::vector<fs_item_t> ret{};
|
||||
@ -361,9 +343,7 @@ auto directory::is_stop_requested() const -> bool {
|
||||
}
|
||||
|
||||
auto directory::is_symlink() const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
return std::filesystem::is_symlink(path_);
|
||||
@ -377,9 +357,7 @@ auto directory::is_symlink() const -> bool {
|
||||
}
|
||||
|
||||
auto directory::move_to(std::string_view new_path) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
throw std::runtime_error("failed to move directory|" + path_ + '|' +
|
||||
@ -394,20 +372,14 @@ auto directory::move_to(std::string_view new_path) -> bool {
|
||||
}
|
||||
|
||||
auto directory::remove() -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
|
||||
if (not exists()) {
|
||||
return true;
|
||||
}
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return utils::retry_action([this]() -> bool {
|
||||
try {
|
||||
#if defined(_WIN32)
|
||||
return ::RemoveDirectoryA(path_.c_str());
|
||||
return not exists() || (::RemoveDirectoryA(path_.c_str()) != 0);
|
||||
#else // !defined(_WIN32)
|
||||
return (rmdir(path_.c_str()) == 0);
|
||||
return not exists() || (rmdir(path_.c_str()) == 0);
|
||||
#endif // defined(_WIN32)
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::handle_exception(function_name, e);
|
||||
@ -420,9 +392,7 @@ auto directory::remove() -> bool {
|
||||
}
|
||||
|
||||
auto directory::remove_recursively() -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not exists()) {
|
||||
@ -448,9 +418,7 @@ auto directory::remove_recursively() -> bool {
|
||||
}
|
||||
|
||||
auto directory::size(bool recursive) const -> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
std::uint64_t ret{0U};
|
||||
|
@ -33,7 +33,7 @@ namespace {
|
||||
file_size = 0U;
|
||||
|
||||
#if defined(_WIN32)
|
||||
struct _stat64 st {};
|
||||
struct _stat64 st{};
|
||||
auto res = _stat64(std::string{path}.c_str(), &st);
|
||||
if (res != 0) {
|
||||
return false;
|
||||
@ -52,10 +52,10 @@ namespace {
|
||||
auto abs_path = repertory::utils::path::absolute(path);
|
||||
|
||||
#if defined(_WIN32)
|
||||
return (::PathFileExistsA(abs_path.c_str()) &&
|
||||
not ::PathIsDirectoryA(abs_path.c_str()));
|
||||
return ((::PathFileExistsA(abs_path.c_str()) != 0) &&
|
||||
(::PathIsDirectoryA(abs_path.c_str()) == 0));
|
||||
#else // !defined(_WIN32)
|
||||
struct stat64 st {};
|
||||
struct stat64 st{};
|
||||
return (stat64(abs_path.c_str(), &st) == 0 && not S_ISDIR(st.st_mode));
|
||||
#endif // defined(_WIN32)
|
||||
}
|
||||
@ -64,9 +64,7 @@ namespace {
|
||||
namespace repertory::utils::file {
|
||||
// auto file::attach_file(native_handle handle,
|
||||
// bool read_only) -> fs_file_t {
|
||||
// static constexpr const std::string_view function_name{
|
||||
// static_cast<const char *>(__FUNCTION__),
|
||||
// };
|
||||
// REPERTORY_USES_FUNCTION_NAME();
|
||||
//
|
||||
// try {
|
||||
// std::string path;
|
||||
@ -119,18 +117,20 @@ void file::open() {
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
file_ = file_t(_fsopen(path_.c_str(), read_only_ ? "rb" : "rb+", _SH_DENYNO),
|
||||
file_deleter());
|
||||
file_ = file_t{
|
||||
_fsopen(path_.c_str(), read_only_ ? "rb" : "rb+", _SH_DENYNO),
|
||||
file_deleter(),
|
||||
};
|
||||
#else // !defined(_WIN32)
|
||||
file_ =
|
||||
file_t(fopen(path_.c_str(), read_only_ ? "rb" : "rb+"), file_deleter());
|
||||
file_ = file_t{
|
||||
fopen(path_.c_str(), read_only_ ? "rb" : "rb+"),
|
||||
file_deleter(),
|
||||
};
|
||||
#endif // defined(_WIN32)
|
||||
}
|
||||
|
||||
auto file::open_file(std::string_view path, bool read_only) -> fs_file_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto *ptr = new file{
|
||||
nullptr,
|
||||
@ -150,8 +150,8 @@ auto file::open_file(std::string_view path, bool read_only) -> fs_file_t {
|
||||
return new_file;
|
||||
}
|
||||
|
||||
auto file::open_or_create_file(std::string_view path,
|
||||
bool read_only) -> fs_file_t {
|
||||
auto file::open_or_create_file(std::string_view path, bool read_only)
|
||||
-> fs_file_t {
|
||||
auto abs_path = utils::path::absolute(path);
|
||||
if (not is_file(abs_path)) {
|
||||
#if defined(_WIN32)
|
||||
@ -184,9 +184,7 @@ auto file::open_or_create_file(std::string_view path,
|
||||
void file::close() { file_.reset(); }
|
||||
|
||||
auto file::copy_to(std::string_view new_path, bool overwrite) const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
auto to_path = utils::path::absolute(new_path);
|
||||
@ -196,7 +194,7 @@ auto file::copy_to(std::string_view new_path, bool overwrite) const -> bool {
|
||||
|
||||
#if defined(_WIN32)
|
||||
return ::CopyFileA(path_.c_str(), to_path.c_str(),
|
||||
overwrite ? TRUE : FALSE);
|
||||
overwrite ? TRUE : FALSE) != 0;
|
||||
#else // !defined(_WIN32)
|
||||
return std::filesystem::copy_file(
|
||||
path_, to_path,
|
||||
@ -234,9 +232,7 @@ auto file::get_handle() const -> native_handle {
|
||||
}
|
||||
|
||||
auto file::is_symlink() const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
return std::filesystem::is_symlink(path_);
|
||||
@ -250,9 +246,7 @@ auto file::is_symlink() const -> bool {
|
||||
}
|
||||
|
||||
auto file::move_to(std::string_view path) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto abs_path = utils::path::absolute(path);
|
||||
|
||||
@ -264,8 +258,8 @@ auto file::move_to(std::string_view path) -> bool {
|
||||
|
||||
auto success{false};
|
||||
#if defined(_WIN32)
|
||||
success = !!::MoveFileExA(path_.c_str(), abs_path.c_str(),
|
||||
MOVEFILE_REPLACE_EXISTING);
|
||||
success = ::MoveFileExA(path_.c_str(), abs_path.c_str(),
|
||||
MOVEFILE_REPLACE_EXISTING) != 0;
|
||||
#else // !// defined(_WIN32)
|
||||
std::error_code ec{};
|
||||
std::filesystem::rename(path_, abs_path, ec);
|
||||
@ -292,9 +286,7 @@ auto file::move_to(std::string_view path) -> bool {
|
||||
|
||||
auto file::read(unsigned char *data, std::size_t to_read, std::uint64_t offset,
|
||||
std::size_t *total_read) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (total_read != nullptr) {
|
||||
(*total_read) = 0U;
|
||||
@ -341,9 +333,7 @@ auto file::read(unsigned char *data, std::size_t to_read, std::uint64_t offset,
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
auto file::sha256() -> std::optional<std::string> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto should_close{false};
|
||||
auto read_only{read_only_};
|
||||
@ -407,26 +397,20 @@ auto file::sha256() -> std::optional<std::string> {
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
|
||||
auto file::remove() -> bool {
|
||||
if (not exists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
close();
|
||||
|
||||
return utils::retry_action([this]() -> bool {
|
||||
#if defined(_WIN32)
|
||||
return ::DeleteFileA(path_.c_str());
|
||||
return not exists() || (::DeleteFileA(path_.c_str()) != 0);
|
||||
#else // !defined(_WIN32)
|
||||
std::error_code ec{};
|
||||
return std::filesystem::remove(path_, ec);
|
||||
return not exists() || std::filesystem::remove(path_, ec);
|
||||
#endif // defined(_WIN32)
|
||||
});
|
||||
}
|
||||
|
||||
auto file::truncate(std::size_t size) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto reopen{false};
|
||||
if (file_) {
|
||||
@ -456,9 +440,7 @@ auto file::truncate(std::size_t size) -> bool {
|
||||
|
||||
auto file::write(const unsigned char *data, std::size_t to_write,
|
||||
std::size_t offset, std::size_t *total_written) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (total_written != nullptr) {
|
||||
(*total_written) = 0U;
|
||||
@ -506,9 +488,7 @@ auto file::write(const unsigned char *data, std::size_t to_write,
|
||||
}
|
||||
|
||||
auto file::size() const -> std::optional<std::uint64_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (file_) {
|
||||
|
@ -30,9 +30,7 @@ namespace repertory::utils::file {
|
||||
auto smb_directory::open(std::string_view host, std::string_view user,
|
||||
std::string_view password, std::string_view path,
|
||||
stop_type *stop_requested) -> smb_directory_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
smb_session_t session{
|
||||
@ -113,9 +111,7 @@ auto smb_directory::open(std::wstring_view host, std::wstring_view user,
|
||||
|
||||
auto smb_directory::copy_to(std::string_view new_path,
|
||||
bool overwrite) const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -136,9 +132,7 @@ auto smb_directory::copy_to(std::string_view new_path,
|
||||
}
|
||||
|
||||
auto smb_directory::count(bool recursive) const -> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -168,9 +162,7 @@ auto smb_directory::count(bool recursive) const -> std::uint64_t {
|
||||
|
||||
auto smb_directory::create_directory(std::string_view path) const
|
||||
-> fs_directory_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -202,9 +194,7 @@ auto smb_directory::create_directory(std::string_view path) const
|
||||
|
||||
auto smb_directory::create_file(std::string_view file_name,
|
||||
bool read_only) const -> fs_file_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -249,9 +239,7 @@ auto smb_directory::create_file(std::string_view file_name,
|
||||
return nullptr;
|
||||
}
|
||||
auto smb_directory::exists() const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -279,9 +267,7 @@ auto smb_directory::exists() const -> bool {
|
||||
|
||||
auto smb_directory::get_directory(std::string_view path) const
|
||||
-> fs_directory_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -321,9 +307,7 @@ auto smb_directory::get_directory(std::string_view path) const
|
||||
}
|
||||
|
||||
auto smb_directory::get_directories() const -> std::vector<fs_directory_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -382,9 +366,7 @@ auto smb_directory::get_directories() const -> std::vector<fs_directory_t> {
|
||||
}
|
||||
|
||||
auto smb_directory::get_file(std::string_view path) const -> fs_file_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -418,9 +400,7 @@ auto smb_directory::get_file(std::string_view path) const -> fs_file_t {
|
||||
}
|
||||
|
||||
auto smb_directory::get_files() const -> std::vector<fs_file_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -469,9 +449,7 @@ auto smb_directory::get_files() const -> std::vector<fs_file_t> {
|
||||
}
|
||||
|
||||
auto smb_directory::get_items() const -> std::vector<fs_item_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -548,9 +526,7 @@ auto smb_directory::is_stop_requested() const -> bool {
|
||||
}
|
||||
|
||||
auto smb_directory::is_symlink() const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -567,9 +543,7 @@ auto smb_directory::is_symlink() const -> bool {
|
||||
}
|
||||
|
||||
auto smb_directory::move_to(std::string_view new_path) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -588,20 +562,18 @@ auto smb_directory::move_to(std::string_view new_path) -> bool {
|
||||
}
|
||||
|
||||
auto smb_directory::remove() -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
throw std::runtime_error("session not found|" + path_);
|
||||
}
|
||||
|
||||
if (not exists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return utils::retry_action([this]() -> bool {
|
||||
if (not exists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
auto res = smb_directory_rm(session_.get(), tid_,
|
||||
smb_create_relative_path(path_).c_str());
|
||||
@ -629,9 +601,7 @@ auto smb_directory::remove() -> bool {
|
||||
}
|
||||
|
||||
auto smb_directory::remove_recursively() -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -654,9 +624,7 @@ auto smb_directory::remove_recursively() -> bool {
|
||||
}
|
||||
|
||||
auto smb_directory::size(bool /* recursive */) const -> std::uint64_t {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
|
@ -37,9 +37,7 @@ void smb_file::close() {
|
||||
|
||||
auto smb_file::copy_to(std::string_view new_path,
|
||||
bool overwrite) const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -61,9 +59,7 @@ auto smb_file::copy_to(std::string_view new_path,
|
||||
}
|
||||
|
||||
auto smb_file::exists() const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -90,9 +86,7 @@ auto smb_file::exists() const -> bool {
|
||||
}
|
||||
|
||||
void smb_file::flush() const {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
throw std::runtime_error("failed to flush file|" + path_ +
|
||||
@ -106,9 +100,7 @@ void smb_file::flush() const {
|
||||
|
||||
auto smb_file::get_time(smb_session *session, smb_tid tid, std::string path,
|
||||
time_type type) -> std::optional<std::uint64_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (session == nullptr) {
|
||||
@ -147,9 +139,7 @@ auto smb_file::get_time(smb_session *session, smb_tid tid, std::string path,
|
||||
}
|
||||
|
||||
auto smb_file::is_symlink() const -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -166,9 +156,7 @@ auto smb_file::is_symlink() const -> bool {
|
||||
}
|
||||
|
||||
auto smb_file::move_to(std::string_view new_path) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (utils::string::begins_with(new_path, "//")) {
|
||||
@ -218,9 +206,7 @@ auto smb_file::move_to(std::string_view new_path) -> bool {
|
||||
}
|
||||
|
||||
auto smb_file::open(bool read_only) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (fd_.has_value()) {
|
||||
@ -263,9 +249,7 @@ auto smb_file::open(bool read_only) -> bool {
|
||||
|
||||
auto smb_file::read(unsigned char *data, std::size_t to_read,
|
||||
std::uint64_t offset, std::size_t *total_read) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (total_read != nullptr) {
|
||||
@ -317,18 +301,16 @@ auto smb_file::read(unsigned char *data, std::size_t to_read,
|
||||
}
|
||||
|
||||
auto smb_file::remove() -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not exists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
close();
|
||||
|
||||
return utils::retry_action([this]() -> bool {
|
||||
if (not exists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
auto res = smb_tree_connect(session_.get(), share_name_.c_str(), &tid_);
|
||||
if (res != DSM_SUCCESS) {
|
||||
@ -364,9 +346,7 @@ auto smb_file::remove() -> bool {
|
||||
}
|
||||
|
||||
auto smb_file::size() const -> std::optional<std::uint64_t> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (not session_) {
|
||||
@ -393,9 +373,7 @@ auto smb_file::size() const -> std::optional<std::uint64_t> {
|
||||
}
|
||||
|
||||
auto smb_file::truncate(std::size_t size) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
throw std::runtime_error("failed to truncate file|" + path_ + '|' +
|
||||
@ -411,9 +389,7 @@ auto smb_file::truncate(std::size_t size) -> bool {
|
||||
|
||||
auto smb_file::write(const unsigned char *data, std::size_t to_write,
|
||||
std::size_t offset, std::size_t *total_written) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
if (total_written != nullptr) {
|
||||
|
@ -56,9 +56,7 @@ auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool {
|
||||
}
|
||||
|
||||
auto use_getpwuid(uid_t uid, passwd_callback_t callback) -> result {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
static std::mutex mtx{};
|
||||
mutex_lock lock{mtx};
|
||||
|
@ -26,6 +26,39 @@
|
||||
#include "utils/string.hpp"
|
||||
|
||||
namespace repertory::utils {
|
||||
void create_console() {
|
||||
if (AllocConsole() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *dummy{nullptr};
|
||||
freopen_s(&dummy, "CONOUT$", "w", stdout);
|
||||
freopen_s(&dummy, "CONOUT$", "w", stderr);
|
||||
freopen_s(&dummy, "CONIN$", "r", stdin);
|
||||
std::cout.clear();
|
||||
std::clog.clear();
|
||||
std::cerr.clear();
|
||||
std::cin.clear();
|
||||
|
||||
auto *out_w = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
auto *in_w = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
SetStdHandle(STD_OUTPUT_HANDLE, out_w);
|
||||
SetStdHandle(STD_ERROR_HANDLE, out_w);
|
||||
SetStdHandle(STD_INPUT_HANDLE, in_w);
|
||||
std::wcout.clear();
|
||||
std::wclog.clear();
|
||||
std::wcerr.clear();
|
||||
std::wcin.clear();
|
||||
}
|
||||
|
||||
void free_console() {
|
||||
FreeConsole();
|
||||
}
|
||||
|
||||
auto get_last_error_code() -> DWORD { return ::GetLastError(); }
|
||||
|
||||
auto get_local_app_data_directory() -> const std::string & {
|
||||
|
@ -29,19 +29,16 @@ static std::vector<std::unique_ptr<repertory::utils::file::i_fs_item>>
|
||||
|
||||
static void delete_generated_files() {
|
||||
repertory::recur_mutex_lock lock{file_mtx};
|
||||
std::optional<std::string> parent_path;
|
||||
std::map<std::string, bool> parent_paths;
|
||||
for (auto &&path : generated_files) {
|
||||
if (parent_path->empty()) {
|
||||
parent_path = repertory::utils::path::get_parent_path(path->get_path());
|
||||
}
|
||||
|
||||
[[maybe_unused]] auto removed = path->remove();
|
||||
parent_paths[repertory::utils::path::get_parent_path(path->get_path())] =
|
||||
true;
|
||||
}
|
||||
generated_files.clear();
|
||||
|
||||
if (parent_path.has_value()) {
|
||||
for (auto &&entry : parent_paths) {
|
||||
EXPECT_TRUE(
|
||||
repertory::utils::file::directory(*parent_path).remove_recursively());
|
||||
repertory::utils::file::directory(entry.first).remove_recursively());
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +46,9 @@ struct file_deleter final {
|
||||
~file_deleter() { delete_generated_files(); }
|
||||
};
|
||||
|
||||
static auto deleter{std::make_unique<file_deleter>()};
|
||||
static auto deleter{
|
||||
std::make_unique<file_deleter>(),
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace repertory::test {
|
||||
|
@ -37,7 +37,11 @@ TEST(utils_error, check_default_exception_handler) {
|
||||
}
|
||||
|
||||
TEST(utils_error, can_override_exception_handler) {
|
||||
struct my_exc_handler : public utils::error::i_exception_handler {
|
||||
struct my_exc_handler final : public utils::error::i_exception_handler {
|
||||
MOCK_METHOD(void, handle_error,
|
||||
(std::string_view function_name, std::string_view msg),
|
||||
(const, override));
|
||||
|
||||
MOCK_METHOD(void, handle_exception, (std::string_view function_name),
|
||||
(const, override));
|
||||
|
||||
@ -49,6 +53,9 @@ TEST(utils_error, can_override_exception_handler) {
|
||||
my_exc_handler handler{};
|
||||
utils::error::set_exception_handler(&handler);
|
||||
|
||||
EXPECT_CALL(handler, handle_error("test_func", "error")).WillOnce(Return());
|
||||
utils::error::handle_error("test_func", "error");
|
||||
|
||||
EXPECT_CALL(handler, handle_exception("test_func")).WillOnce(Return());
|
||||
utils::error::handle_exception("test_func");
|
||||
|
||||
|
@ -26,7 +26,7 @@ static constexpr const auto file_type_count{1U};
|
||||
}
|
||||
|
||||
namespace repertory {
|
||||
TEST(utils_file, can_create_file) {
|
||||
TEST(utils_file, can_create_and_remove_file) {
|
||||
for (auto idx = 0U; idx < file_type_count; ++idx) {
|
||||
auto path = test::generate_test_file_name("utils_file");
|
||||
EXPECT_FALSE(utils::file::file(path).exists() ||
|
||||
@ -37,6 +37,12 @@ TEST(utils_file, can_create_file) {
|
||||
EXPECT_TRUE(*file);
|
||||
|
||||
EXPECT_TRUE(utils::file::file(path).exists());
|
||||
EXPECT_TRUE(file->exists());
|
||||
|
||||
EXPECT_TRUE(file->remove());
|
||||
|
||||
EXPECT_FALSE(utils::file::file(path).exists());
|
||||
EXPECT_FALSE(file->exists());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,21 +391,12 @@ TEST(utils_path, absolute) {
|
||||
}
|
||||
|
||||
TEST(utils_path, absolute_can_resolve_path_variables) {
|
||||
std::string home{};
|
||||
|
||||
#if defined(_WIN32)
|
||||
home.resize(repertory::max_path_length + 1U);
|
||||
auto size = ::GetEnvironmentVariableA("USERPROFILE", home.data(), 0U);
|
||||
|
||||
home.resize(size);
|
||||
::GetEnvironmentVariableA("USERPROFILE", home.data(),
|
||||
static_cast<DWORD>(home.size()));
|
||||
home = utils::path::absolute(home);
|
||||
|
||||
auto home =
|
||||
utils::path::absolute(utils::get_environment_variable("USERPROFILE"));
|
||||
EXPECT_STREQ(home.c_str(), utils::path::absolute("%USERPROFILE%").c_str());
|
||||
#else // !defined(_WIN32)
|
||||
home = std::getenv("HOME");
|
||||
home = utils::path::absolute(home);
|
||||
auto home = utils::path::absolute(utils::get_environment_variable("HOME"));
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
auto expanded_str = utils::path::absolute("~\\");
|
||||
|
Reference in New Issue
Block a user