refactor proprocessor directives

This commit is contained in:
Scott E. Graves 2024-07-15 12:20:15 -05:00
parent c1eb6b94ed
commit 6a984ac84c
73 changed files with 1450 additions and 1583 deletions

View File

@ -30,29 +30,29 @@
namespace repertory { namespace repertory {
class app_config final { class app_config final {
public: public:
[[nodiscard]] static auto default_agent_name(const provider_type &prov) [[nodiscard]] static auto
-> std::string; default_agent_name(const provider_type &prov) -> std::string;
[[nodiscard]] static auto default_api_port(const provider_type &prov) [[nodiscard]] static auto
-> std::uint16_t; default_api_port(const provider_type &prov) -> std::uint16_t;
[[nodiscard]] static auto default_data_directory(const provider_type &prov) [[nodiscard]] static auto
-> std::string; default_data_directory(const provider_type &prov) -> std::string;
[[nodiscard]] static auto default_remote_port(const provider_type &prov) [[nodiscard]] static auto
-> std::uint16_t; default_remote_port(const provider_type &prov) -> std::uint16_t;
[[nodiscard]] static auto default_rpc_port(const provider_type &prov) [[nodiscard]] static auto
-> std::uint16_t; default_rpc_port(const provider_type &prov) -> std::uint16_t;
[[nodiscard]] static auto get_provider_api_password(const provider_type &prov) [[nodiscard]] static auto
-> std::string; get_provider_api_password(const provider_type &prov) -> std::string;
[[nodiscard]] static auto get_provider_display_name(const provider_type &prov) [[nodiscard]] static auto
-> std::string; get_provider_display_name(const provider_type &prov) -> std::string;
[[nodiscard]] static auto get_provider_name(const provider_type &prov) [[nodiscard]] static auto
-> std::string; get_provider_name(const provider_type &prov) -> std::string;
public: public:
app_config(const provider_type &prov, const std::string &data_directory = ""); app_config(const provider_type &prov, const std::string &data_directory = "");
@ -71,7 +71,7 @@ private:
bool enable_comm_duration_events_; bool enable_comm_duration_events_;
bool enable_drive_events_; bool enable_drive_events_;
bool enable_max_cache_size_; bool enable_max_cache_size_;
#ifdef _WIN32 #if defined(_WIN32)
bool enable_mount_manager_; bool enable_mount_manager_;
#endif #endif
bool enable_remote_mount_; bool enable_remote_mount_;
@ -183,7 +183,7 @@ public:
return encrypt_config_; return encrypt_config_;
} }
#ifdef _WIN32 #if defined(_WIN32)
[[nodiscard]] auto get_enable_mount_manager() const -> bool { [[nodiscard]] auto get_enable_mount_manager() const -> bool {
return enable_mount_manager_; return enable_mount_manager_;
} }
@ -337,7 +337,7 @@ public:
set_value(enable_max_cache_size_, enable_max_cache_size); set_value(enable_max_cache_size_, enable_max_cache_size);
} }
#ifdef _WIN32 #if defined(_WIN32)
void set_enable_mount_manager(bool enable_mount_manager) { void set_enable_mount_manager(bool enable_mount_manager) {
set_value(enable_mount_manager_, enable_mount_manager); set_value(enable_mount_manager_, enable_mount_manager);
} }
@ -365,7 +365,7 @@ public:
set_value(high_freq_interval_secs_, high_frequency_interval_secs); set_value(high_freq_interval_secs_, high_frequency_interval_secs);
} }
#ifdef PROJECT_TESTING #if defined(PROJECT_TESTING)
void set_host_config(host_config hc) { void set_host_config(host_config hc) {
config_changed_ = true; config_changed_ = true;
hc_ = std::move(hc); hc_ = std::move(hc);

View File

@ -46,10 +46,14 @@
#endif // defined(__GNUC__) #endif // defined(__GNUC__)
// clang-format on // clang-format on
#ifdef __cplusplus #if defined(__cplusplus)
REPERTORY_IGNORE_WARNINGS_ENABLE() REPERTORY_IGNORE_WARNINGS_ENABLE()
#ifdef _WIN32 #if defined(_WIN32)
#define WINVER 0x0602
#define _WIN32_WINNT WINVER
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#include <windows.h> #include <windows.h>
@ -69,20 +73,20 @@ REPERTORY_IGNORE_WARNINGS_ENABLE()
#include <pwd.h> #include <pwd.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef __linux__ #if defined(__linux__)
#include <sys/statfs.h> #include <sys/statfs.h>
#endif #endif
#include <unistd.h> #include <unistd.h>
#ifdef HAS_SETXATTR #if defined(HAS_SETXATTR)
#include <sys/types.h> #include <sys/types.h>
#include <sys/xattr.h> #include <sys/xattr.h>
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
#include <libproc.h> #include <libproc.h>
#include <sys/attr.h> #include <sys/attr.h>
#include <sys/vnode.h> #include <sys/vnode.h>
#endif #endif
#if __APPLE__ #if defined(__APPLE__)
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/statvfs.h> #include <sys/statvfs.h>
#endif #endif
@ -134,7 +138,7 @@ template <typename data_type>
#include "sqlite3.h" #include "sqlite3.h"
#include "uuid.h" #include "uuid.h"
#ifdef _WIN32 #if defined(_WIN32)
#include <sddl.h> #include <sddl.h>
#include "winfsp/winfsp.hpp" #include "winfsp/winfsp.hpp"
#else #else
@ -161,7 +165,7 @@ using json = nlohmann::json;
#define REPERTORY_MIN_REMOTE_VERSION "2.0.0" #define REPERTORY_MIN_REMOTE_VERSION "2.0.0"
#define REPERTORY_W L"repertory" #define REPERTORY_W L"repertory"
#ifdef _WIN32 #if defined(_WIN32)
#define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE #define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE
#define REPERTORY_API_INVALID_HANDLE static_cast<std::uint64_t>(-1) #define REPERTORY_API_INVALID_HANDLE static_cast<std::uint64_t>(-1)
using native_handle = HANDLE; using native_handle = HANDLE;
@ -173,20 +177,20 @@ using native_handle = int;
constexpr const auto NANOS_PER_SECOND = 1000000000L; constexpr const auto NANOS_PER_SECOND = 1000000000L;
#ifdef _WIN32 #if defined(_WIN32)
#ifdef CreateDirectory #if defined(CreateDirectory)
#undef CreateDirectory #undef CreateDirectory
#endif #endif
#ifdef CreateFile #if defined(CreateFile)
#undef CreateFile #undef CreateFile
#endif #endif
#ifdef DeleteFile #if defined(DeleteFile)
#undef DeleteFile #undef DeleteFile
#endif #endif
#ifdef RemoveDirectory #if defined(RemoveDirectory)
#undef RemoveDirectory #undef RemoveDirectory
#endif #endif
@ -255,8 +259,8 @@ constexpr const auto NANOS_PER_SECOND = 1000000000L;
#define SETATTR_WANTS_FLAGS(attr) ((attr)->valid & (1 << 31)) #define SETATTR_WANTS_FLAGS(attr) ((attr)->valid & (1 << 31))
#endif // SETATTR_WANTS_FLAGS #endif // SETATTR_WANTS_FLAGS
#ifndef _WIN32 #if !defined(_WIN32)
#ifdef __APPLE__ #if defined(__APPLE__)
#define G_PREFIX "org" #define G_PREFIX "org"
#define G_KAUTH_FILESEC_XATTR G_PREFIX ".apple.system.Security" #define G_KAUTH_FILESEC_XATTR G_PREFIX ".apple.system.Security"
#define A_PREFIX "com" #define A_PREFIX "com"
@ -295,7 +299,7 @@ constexpr const auto NANOS_PER_SECOND = 1000000000L;
#define WINFSP_ALLOCATION_UNIT UINT64(4096U) #define WINFSP_ALLOCATION_UNIT UINT64(4096U)
#ifdef _WIN32 #if defined(_WIN32)
#define UTIME_NOW ((1l << 30) - 1l) #define UTIME_NOW ((1l << 30) - 1l)
#define UTIME_OMIT ((1l << 30) - 2l) #define UTIME_OMIT ((1l << 30) - 2l)
#define CONVERT_STATUS_NOT_IMPLEMENTED(e) e #define CONVERT_STATUS_NOT_IMPLEMENTED(e) e
@ -346,7 +350,7 @@ using WCHAR = wchar_t;
#define GENERIC_EXECUTE (0x20000000L) #define GENERIC_EXECUTE (0x20000000L)
#define GENERIC_ALL (0x10000000L) #define GENERIC_ALL (0x10000000L)
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1) #define INVALID_FILE_ATTRIBUTES ((DWORD) - 1)
#define MAX_PATH 260 #define MAX_PATH 260

View File

@ -28,7 +28,7 @@
namespace repertory { namespace repertory {
class directory_iterator final { class directory_iterator final {
public: public:
#ifndef _WIN32 #if !defined(_WIN32)
using populate_stat_callback = using populate_stat_callback =
std::function<void(const std::string &, std::uint64_t, std::function<void(const std::string &, std::uint64_t,
const api_meta_map &, bool, struct stat *)>; const api_meta_map &, bool, struct stat *)>;
@ -46,7 +46,7 @@ private:
directory_item_list items_; directory_item_list items_;
public: public:
#ifndef _WIN32 #if !defined(_WIN32)
[[nodiscard]] auto fill_buffer(const remote::file_offset &offset, [[nodiscard]] auto fill_buffer(const remote::file_offset &offset,
fuse_fill_dir_t filler_function, void *buffer, fuse_fill_dir_t filler_function, void *buffer,
populate_stat_callback populate_stat) -> int; populate_stat_callback populate_stat) -> int;
@ -56,8 +56,8 @@ public:
[[nodiscard]] auto get_count() const -> std::size_t { return items_.size(); } [[nodiscard]] auto get_count() const -> std::size_t { return items_.size(); }
[[nodiscard]] auto get_directory_item(std::size_t offset, directory_item &di) [[nodiscard]] auto get_directory_item(std::size_t offset,
-> api_error; directory_item &di) -> api_error;
[[nodiscard]] auto get_directory_item(const std::string &api_path, [[nodiscard]] auto get_directory_item(const std::string &api_path,
directory_item &di) -> api_error; directory_item &di) -> api_error;
@ -71,8 +71,8 @@ public:
auto operator=(const directory_iterator &iterator) noexcept auto operator=(const directory_iterator &iterator) noexcept
-> directory_iterator &; -> directory_iterator &;
auto operator=(directory_iterator &&iterator) noexcept auto
-> directory_iterator &; operator=(directory_iterator &&iterator) noexcept -> directory_iterator &;
auto operator=(directory_item_list list) noexcept -> directory_iterator &; auto operator=(directory_item_list list) noexcept -> directory_iterator &;
}; };

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_ #ifndef INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
#define INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_ #define INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
#ifndef _WIN32 #if !defined(_WIN32)
#include "events/event_system.hpp" #include "events/event_system.hpp"
#include "utils/path_utils.hpp" #include "utils/path_utils.hpp"
@ -78,9 +78,9 @@ private:
static void execute_void_callback(const std::string &function_name, static void execute_void_callback(const std::string &function_name,
const std::function<void()> &cb); const std::function<void()> &cb);
static auto execute_void_pointer_callback(const std::string &function_name, static auto
const std::function<void *()> &cb) execute_void_pointer_callback(const std::string &function_name,
-> void *; const std::function<void *()> &cb) -> void *;
void raise_fuse_event(std::string function_name, const std::string &api_path, void raise_fuse_event(std::string function_name, const std::string &api_path,
int ret, bool disable_logging); int ret, bool disable_logging);
@ -88,7 +88,7 @@ private:
private: private:
[[nodiscard]] static auto access_(const char *path, int mask) -> int; [[nodiscard]] static auto access_(const char *path, int mask) -> int;
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] static auto chflags_(const char *path, uint32_t flags) -> int; [[nodiscard]] static auto chflags_(const char *path, uint32_t flags) -> int;
#endif // __APPLE__ #endif // __APPLE__
@ -103,8 +103,8 @@ private:
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid, [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid,
struct fuse_file_info *fi) -> int; struct fuse_file_info *fi) -> int;
#else #else
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid) [[nodiscard]] static auto chown_(const char *path, uid_t uid,
-> int; gid_t gid) -> int;
#endif #endif
[[nodiscard]] static auto create_(const char *path, mode_t mode, [[nodiscard]] static auto create_(const char *path, mode_t mode,
@ -113,15 +113,15 @@ private:
static void destroy_(void *ptr); static void destroy_(void *ptr);
[[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset, [[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset,
off_t length, struct fuse_file_info *fi) off_t length,
-> int; struct fuse_file_info *fi) -> int;
#if FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION < 30
[[nodiscard]] static auto fgetattr_(const char *path, struct stat *st, [[nodiscard]] static auto fgetattr_(const char *path, struct stat *st,
struct fuse_file_info *fi) -> int; struct fuse_file_info *fi) -> int;
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] static auto fsetattr_x_(const char *path, [[nodiscard]] static auto fsetattr_x_(const char *path,
struct setattr_x *attr, struct setattr_x *attr,
struct fuse_file_info *fi) -> int; struct fuse_file_info *fi) -> int;
@ -140,7 +140,7 @@ private:
[[nodiscard]] static auto getattr_(const char *path, struct stat *st) -> int; [[nodiscard]] static auto getattr_(const char *path, struct stat *st) -> int;
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] static auto getxtimes_(const char *path, [[nodiscard]] static auto getxtimes_(const char *path,
struct timespec *bkuptime, struct timespec *bkuptime,
struct timespec *crtime) -> int; struct timespec *crtime) -> int;
@ -155,8 +155,8 @@ private:
[[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int; [[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int;
[[nodiscard]] static auto open_(const char *path, struct fuse_file_info *fi) [[nodiscard]] static auto open_(const char *path,
-> int; struct fuse_file_info *fi) -> int;
[[nodiscard]] static auto opendir_(const char *path, [[nodiscard]] static auto opendir_(const char *path,
struct fuse_file_info *fi) -> int; struct fuse_file_info *fi) -> int;
@ -173,8 +173,8 @@ private:
#else #else
[[nodiscard]] static auto readdir_(const char *path, void *buf, [[nodiscard]] static auto readdir_(const char *path, void *buf,
fuse_fill_dir_t fuse_fill_dir, fuse_fill_dir_t fuse_fill_dir,
off_t offset, struct fuse_file_info *fi) off_t offset,
-> int; struct fuse_file_info *fi) -> int;
#endif #endif
[[nodiscard]] static auto release_(const char *path, [[nodiscard]] static auto release_(const char *path,
@ -192,8 +192,8 @@ private:
[[nodiscard]] static auto rmdir_(const char *path) -> int; [[nodiscard]] static auto rmdir_(const char *path) -> int;
#ifdef HAS_SETXATTR #if defined(HAS_SETXATTR)
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] static auto getxattr_(const char *path, const char *name, [[nodiscard]] static auto getxattr_(const char *path, const char *name,
char *value, size_t size, char *value, size_t size,
uint32_t position) -> int; uint32_t position) -> int;
@ -206,28 +206,27 @@ private:
[[nodiscard]] static auto listxattr_(const char *path, char *buffer, [[nodiscard]] static auto listxattr_(const char *path, char *buffer,
size_t size) -> int; size_t size) -> int;
[[nodiscard]] static auto removexattr_(const char *path, const char *name) [[nodiscard]] static auto removexattr_(const char *path,
-> int; const char *name) -> int;
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] static auto setxattr_(const char *path, const char *name, [[nodiscard]] static auto setxattr_(const char *path, const char *name,
const char *value, size_t size, int flags, const char *value, size_t size, int flags,
uint32_t position) -> int; uint32_t position) -> int;
#else // __APPLE__ #else // __APPLE__
[[nodiscard]] static auto setxattr_(const char *path, const char *name, [[nodiscard]] static auto setxattr_(const char *path, const char *name,
const char *value, size_t size, int flags) const char *value, size_t size,
-> int; int flags) -> int;
#endif // __APPLE__ #endif // __APPLE__
#endif // HAS_SETXATTR #endif // HAS_SETXATTR
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] static auto setattr_x_(const char *path, struct setattr_x *attr) [[nodiscard]] static auto setattr_x_(const char *path,
-> int; struct setattr_x *attr) -> int;
[[nodiscard]] static auto setbkuptime_(const char *path, [[nodiscard]] static auto
const struct timespec *bkuptime) setbkuptime_(const char *path, const struct timespec *bkuptime) -> int;
-> int;
[[nodiscard]] static auto setchgtime_(const char *path, [[nodiscard]] static auto setchgtime_(const char *path,
const struct timespec *chgtime) -> int; const struct timespec *chgtime) -> int;
@ -237,12 +236,12 @@ private:
[[nodiscard]] static auto setvolname_(const char *volname) -> int; [[nodiscard]] static auto setvolname_(const char *volname) -> int;
[[nodiscard]] static auto statfs_x_(const char *path, struct statfs *stbuf) [[nodiscard]] static auto statfs_x_(const char *path,
-> int; struct statfs *stbuf) -> int;
#else // __APPLE__ #else // __APPLE__
[[nodiscard]] static auto statfs_(const char *path, struct statvfs *stbuf) [[nodiscard]] static auto statfs_(const char *path,
-> int; struct statvfs *stbuf) -> int;
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
@ -268,12 +267,12 @@ private:
struct fuse_file_info *fi) -> int; struct fuse_file_info *fi) -> int;
protected: protected:
[[nodiscard]] virtual auto access_impl(std::string /*api_path*/, int /*mask*/) [[nodiscard]] virtual auto access_impl(std::string /*api_path*/,
-> api_error { int /*mask*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] virtual auto chflags_impl(std::string /*api_path*/, [[nodiscard]] virtual auto chflags_impl(std::string /*api_path*/,
uint32_t /*flags*/) -> api_error { uint32_t /*flags*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
@ -281,10 +280,9 @@ protected:
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
mode_t /*mode*/, chmod_impl(std::string /*api_path*/, mode_t /*mode*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*fi*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else #else
@ -295,10 +293,9 @@ protected:
#endif #endif
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/, [[nodiscard]] virtual auto
gid_t /*gid*/, chown_impl(std::string /*api_path*/, uid_t /*uid*/, gid_t /*gid*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*fi*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else #else
@ -308,10 +305,9 @@ protected:
} }
#endif #endif
[[nodiscard]] virtual auto create_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
mode_t /*mode*/, create_impl(std::string /*api_path*/, mode_t /*mode*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*fi*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@ -319,48 +315,43 @@ protected:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/, fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/,
off_t /*length*/, struct fuse_file_info * /*fi*/) off_t /*length*/,
-> api_error { struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto fgetattr_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct stat * /*st*/, fgetattr_impl(std::string /*api_path*/, struct stat * /*st*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*fi*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] virtual auto fsetattr_x_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct setattr_x * /*attr*/, fsetattr_x_impl(std::string /*api_path*/, struct setattr_x * /*attr*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*fi*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#endif // __APPLE__ #endif // __APPLE__
[[nodiscard]] virtual auto fsync_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
int /*datasync*/, fsync_impl(std::string /*api_path*/, int /*datasync*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*fi*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#if FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION < 30
[[nodiscard]] virtual auto ftruncate_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
off_t /*size*/, ftruncate_impl(std::string /*api_path*/, off_t /*size*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*fi*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#endif #endif
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct stat * /*st*/, getattr_impl(std::string /*api_path*/, struct stat * /*st*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*fi*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else #else
@ -370,18 +361,17 @@ protected:
} }
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] virtual auto getxtimes_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct timespec * /*bkuptime*/, getxtimes_impl(std::string /*api_path*/, struct timespec * /*bkuptime*/,
struct timespec * /*crtime*/) struct timespec * /*crtime*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) virtual auto init_impl(struct fuse_conn_info *conn,
-> void *; struct fuse_config *cfg) -> void *;
#else #else
virtual auto init_impl(struct fuse_conn_info *conn) -> void *; virtual auto init_impl(struct fuse_conn_info *conn) -> void *;
#endif #endif
@ -391,15 +381,15 @@ protected:
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto open_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct fuse_file_info * /*fi*/) open_impl(std::string /*api_path*/,
-> api_error { struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto opendir_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct fuse_file_info * /*fi*/) opendir_impl(std::string /*api_path*/,
-> api_error { struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@ -414,8 +404,8 @@ protected:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
readdir_impl(std::string /*api_path*/, void * /*buf*/, readdir_impl(std::string /*api_path*/, void * /*buf*/,
fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/, fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/,
struct fuse_file_info * /*fi*/, fuse_readdir_flags /*flags*/) struct fuse_file_info * /*fi*/,
-> api_error { fuse_readdir_flags /*flags*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else #else
@ -427,15 +417,15 @@ protected:
} }
#endif #endif
[[nodiscard]] virtual auto release_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct fuse_file_info * /*fi*/) release_impl(std::string /*api_path*/,
-> api_error { struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto releasedir_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct fuse_file_info * /*fi*/) releasedir_impl(std::string /*api_path*/,
-> api_error { struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@ -446,9 +436,9 @@ protected:
return api_error::not_implemented; return api_error::not_implemented;
} }
#else #else
[[nodiscard]] virtual auto rename_impl(std::string /*from_api_path*/, [[nodiscard]] virtual auto
std::string /*to_api_path*/) rename_impl(std::string /*from_api_path*/,
-> api_error { std::string /*to_api_path*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#endif #endif
@ -457,8 +447,8 @@ protected:
return api_error::not_implemented; return api_error::not_implemented;
} }
#ifdef HAS_SETXATTR #if defined(HAS_SETXATTR)
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
getxattr_impl(std::string /*api_path*/, const char * /*name*/, getxattr_impl(std::string /*api_path*/, const char * /*name*/,
char * /*value*/, size_t /*size*/, uint32_t /*position*/, char * /*value*/, size_t /*size*/, uint32_t /*position*/,
@ -468,8 +458,8 @@ protected:
#else // __APPLE__ #else // __APPLE__
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
getxattr_impl(std::string /*api_path*/, const char * /*name*/, getxattr_impl(std::string /*api_path*/, const char * /*name*/,
char * /*value*/, size_t /*size*/, int & /*attribute_size*/) char * /*value*/, size_t /*size*/,
-> api_error { int & /*attribute_size*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#endif // __APPLE__ #endif // __APPLE__
@ -480,13 +470,13 @@ protected:
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto removexattr_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
const char * /*name*/) removexattr_impl(std::string /*api_path*/,
-> api_error { const char * /*name*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] virtual auto setxattr_impl(std::string /*api_path*/, [[nodiscard]] virtual auto setxattr_impl(std::string /*api_path*/,
const char * /*name*/, const char * /*name*/,
const char * /*value*/, const char * /*value*/,
@ -495,19 +485,20 @@ protected:
return api_error::not_implemented; return api_error::not_implemented;
} }
#else // __APPLE__ #else // __APPLE__
[[nodiscard]] virtual auto [[nodiscard]] virtual auto setxattr_impl(std::string /*api_path*/,
setxattr_impl(std::string /*api_path*/, const char * /*name*/, const char * /*name*/,
const char * /*value*/, size_t /*size*/, int /*flags*/) const char * /*value*/,
-> api_error { size_t /*size*/,
int /*flags*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#endif // __APPLE__ #endif // __APPLE__
#endif // HAS_SETXATTR #endif // HAS_SETXATTR
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] virtual auto setattr_x_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct setattr_x * /*attr*/) setattr_x_impl(std::string /*api_path*/,
-> api_error { struct setattr_x * /*attr*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@ -518,40 +509,39 @@ protected:
} }
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
setchgtime_impl(std::string /*api_path*/, const struct timespec * /*chgtime*/) setchgtime_impl(std::string /*api_path*/,
-> api_error { const struct timespec * /*chgtime*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto setcrtime_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
const struct timespec * /*crtime*/) setcrtime_impl(std::string /*api_path*/,
-> api_error { const struct timespec * /*crtime*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto setvolname_impl(const char * /*volname*/) [[nodiscard]] virtual auto
-> api_error { setvolname_impl(const char * /*volname*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto statfs_x_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct statfs * /*stbuf*/) statfs_x_impl(std::string /*api_path*/,
-> api_error { struct statfs * /*stbuf*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else // __APPLE__ #else // __APPLE__
[[nodiscard]] virtual auto statfs_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
struct statvfs * /*stbuf*/) statfs_impl(std::string /*api_path*/,
-> api_error { struct statvfs * /*stbuf*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
off_t /*size*/, truncate_impl(std::string /*api_path*/, off_t /*size*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*fi*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else #else
@ -561,22 +551,21 @@ protected:
} }
#endif #endif
[[nodiscard]] virtual auto unlink_impl(std::string /*api_path*/) [[nodiscard]] virtual auto
-> api_error { unlink_impl(std::string /*api_path*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
const struct timespec /*tv*/[2], utimens_impl(std::string /*api_path*/, const struct timespec /*tv*/[2],
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*fi*/) -> api_error {
-> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else #else
[[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, [[nodiscard]] virtual auto
const struct timespec /*tv*/[2]) utimens_impl(std::string /*api_path*/,
-> api_error { const struct timespec /*tv*/[2]) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#endif #endif
@ -584,8 +573,8 @@ protected:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
write_impl(std::string /*api_path*/, const char * /*buffer*/, write_impl(std::string /*api_path*/, const char * /*buffer*/,
size_t /*write_size*/, off_t /*write_offset*/, size_t /*write_size*/, off_t /*write_offset*/,
struct fuse_file_info * /*fi*/, std::size_t & /*bytes_written*/) struct fuse_file_info * /*fi*/,
-> api_error { std::size_t & /*bytes_written*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_ #ifndef INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
#define INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_ #define INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_
#ifndef _WIN32 #if !defined(_WIN32)
#include "drives/fuse/fuse_drive_base.hpp" #include "drives/fuse/fuse_drive_base.hpp"
#include "file_manager/file_manager.hpp" #include "file_manager/file_manager.hpp"
@ -69,96 +69,93 @@ private:
void update_accessed_time(const std::string &api_path); void update_accessed_time(const std::string &api_path);
protected: protected:
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto chflags_impl(std::string api_path, uint32_t flags) [[nodiscard]] auto chflags_impl(std::string api_path,
-> api_error override; uint32_t flags) -> api_error override;
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode, [[nodiscard]] auto
struct fuse_file_info *file_info) chmod_impl(std::string api_path, mode_t mode,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
#else #else
[[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode) [[nodiscard]] auto chmod_impl(std::string api_path,
-> api_error override; mode_t mode) -> api_error override;
#endif #endif
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid, [[nodiscard]] auto
struct fuse_file_info *file_info) chown_impl(std::string api_path, uid_t uid, gid_t gid,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
#else #else
[[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid) [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid,
-> api_error override; gid_t gid) -> api_error override;
#endif #endif
[[nodiscard]] auto create_impl(std::string api_path, mode_t mode, [[nodiscard]] auto
struct fuse_file_info *file_info) create_impl(std::string api_path, mode_t mode,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
void destroy_impl(void *ptr) override; void destroy_impl(void *ptr) override;
[[nodiscard]] auto fallocate_impl(std::string api_path, int mode, [[nodiscard]] auto
off_t offset, off_t length, fallocate_impl(std::string api_path, int mode, off_t offset, off_t length,
struct fuse_file_info *file_info) struct fuse_file_info *file_info) -> api_error override;
-> api_error override;
[[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *st, [[nodiscard]] auto
struct fuse_file_info *file_info) fgetattr_impl(std::string api_path, struct stat *st,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto fsetattr_x_impl(std::string api_path, [[nodiscard]] auto
struct setattr_x *attr, fsetattr_x_impl(std::string api_path, struct setattr_x *attr,
struct fuse_file_info *file_info) struct fuse_file_info *file_info) -> api_error override;
-> api_error override;
#endif // __APPLE__ #endif // __APPLE__
[[nodiscard]] auto fsync_impl(std::string api_path, int datasync, [[nodiscard]] auto
struct fuse_file_info *file_info) fsync_impl(std::string api_path, int datasync,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
#if FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION < 30
[[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size, [[nodiscard]] auto
struct fuse_file_info *file_info) ftruncate_impl(std::string api_path, off_t size,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
#endif #endif
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto getattr_impl(std::string api_path, struct stat *st, [[nodiscard]] auto
struct fuse_file_info *file_info) getattr_impl(std::string api_path, struct stat *st,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
#else #else
[[nodiscard]] auto getattr_impl(std::string api_path, struct stat *st) [[nodiscard]] auto getattr_impl(std::string api_path,
-> api_error override; struct stat *st) -> api_error override;
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto getxtimes_impl(std::string api_path, [[nodiscard]] auto
struct timespec *bkuptime, getxtimes_impl(std::string api_path, struct timespec *bkuptime,
struct timespec *crtime) struct timespec *crtime) -> api_error override;
-> api_error override;
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) auto init_impl(struct fuse_conn_info *conn,
-> void * override; struct fuse_config *cfg) -> void * override;
#else #else
auto init_impl(struct fuse_conn_info *conn) -> void * override; auto init_impl(struct fuse_conn_info *conn) -> void * override;
#endif #endif
[[nodiscard]] auto mkdir_impl(std::string api_path, mode_t mode) [[nodiscard]] auto mkdir_impl(std::string api_path,
-> api_error override; mode_t mode) -> api_error override;
void notify_fuse_main_exit(int &ret) override; void notify_fuse_main_exit(int &ret) override;
[[nodiscard]] auto open_impl(std::string api_path, [[nodiscard]] auto
struct fuse_file_info *file_info) open_impl(std::string api_path,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
[[nodiscard]] auto opendir_impl(std::string api_path, [[nodiscard]] auto
struct fuse_file_info *file_info) opendir_impl(std::string api_path,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
[[nodiscard]] auto read_impl(std::string api_path, char *buffer, [[nodiscard]] auto read_impl(std::string api_path, char *buffer,
size_t read_size, off_t read_offset, size_t read_size, off_t read_offset,
@ -166,30 +163,29 @@ protected:
std::size_t &bytes_read) -> api_error override; std::size_t &bytes_read) -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto readdir_impl(std::string api_path, void *buf, [[nodiscard]] auto
fuse_fill_dir_t fuse_fill_dir, off_t offset, readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
struct fuse_file_info *file_info, off_t offset, struct fuse_file_info *file_info,
fuse_readdir_flags flags) fuse_readdir_flags flags) -> api_error override;
-> api_error override;
#else #else
[[nodiscard]] auto readdir_impl(std::string api_path, void *buf, [[nodiscard]] auto
fuse_fill_dir_t fuse_fill_dir, off_t offset, readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
struct fuse_file_info *file_info) off_t offset,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
#endif #endif
[[nodiscard]] auto release_impl(std::string api_path, [[nodiscard]] auto
struct fuse_file_info *file_info) release_impl(std::string api_path,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
[[nodiscard]] auto releasedir_impl(std::string api_path, [[nodiscard]] auto
struct fuse_file_info *file_info) releasedir_impl(std::string api_path,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto rename_impl(std::string from_api_path, [[nodiscard]] auto rename_impl(std::string from_api_path,
std::string to_api_path, unsigned int flags) std::string to_api_path,
-> api_error override; unsigned int flags) -> api_error override;
#else #else
[[nodiscard]] auto rename_impl(std::string from_api_path, [[nodiscard]] auto rename_impl(std::string from_api_path,
std::string to_api_path) -> api_error override; std::string to_api_path) -> api_error override;
@ -197,13 +193,13 @@ protected:
[[nodiscard]] auto rmdir_impl(std::string api_path) -> api_error override; [[nodiscard]] auto rmdir_impl(std::string api_path) -> api_error override;
#ifdef HAS_SETXATTR #if defined(HAS_SETXATTR)
[[nodiscard]] auto getxattr_common(std::string api_path, const char *name, [[nodiscard]] auto getxattr_common(std::string api_path, const char *name,
char *value, size_t size, char *value, size_t size,
int &attribute_size, uint32_t *position) int &attribute_size,
-> api_error; uint32_t *position) -> api_error;
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto getxattr_impl(std::string api_path, const char *name, [[nodiscard]] auto getxattr_impl(std::string api_path, const char *name,
char *value, size_t size, uint32_t position, char *value, size_t size, uint32_t position,
int &attribute_size) -> api_error override; int &attribute_size) -> api_error override;
@ -217,73 +213,71 @@ protected:
size_t size, int &required_size, size_t size, int &required_size,
bool &return_size) -> api_error override; bool &return_size) -> api_error override;
[[nodiscard]] auto removexattr_impl(std::string api_path, const char *name) [[nodiscard]] auto removexattr_impl(std::string api_path,
-> api_error override; const char *name) -> api_error override;
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto setxattr_impl(std::string api_path, const char *name, [[nodiscard]] auto setxattr_impl(std::string api_path, const char *name,
const char *value, size_t size, int flags, const char *value, size_t size, int flags,
uint32_t position) -> api_error override; uint32_t position) -> api_error override;
#else // __APPLE__ #else // __APPLE__
[[nodiscard]] auto setxattr_impl(std::string api_path, const char *name, [[nodiscard]] auto setxattr_impl(std::string api_path, const char *name,
const char *value, size_t size, int flags) const char *value, size_t size,
-> api_error override; int flags) -> api_error override;
#endif // __APPLE__ #endif // __APPLE__
#endif // HAS_SETXATTR #endif // HAS_SETXATTR
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto setattr_x_impl(std::string api_path, [[nodiscard]] auto
struct setattr_x *attr) setattr_x_impl(std::string api_path,
-> api_error override; struct setattr_x *attr) -> api_error override;
[[nodiscard]] auto setbkuptime_impl(std::string api_path, [[nodiscard]] auto
const struct timespec *bkuptime) setbkuptime_impl(std::string api_path,
-> api_error override; const struct timespec *bkuptime) -> api_error override;
[[nodiscard]] auto setchgtime_impl(std::string api_path, [[nodiscard]] auto
const struct timespec *chgtime) setchgtime_impl(std::string api_path,
-> api_error override; const struct timespec *chgtime) -> api_error override;
[[nodiscard]] auto setcrtime_impl(std::string api_path, [[nodiscard]] auto
const struct timespec *crtime) setcrtime_impl(std::string api_path,
-> api_error override; const struct timespec *crtime) -> api_error override;
[[nodiscard]] auto setvolname_impl(const char *volname) -> api_error override; [[nodiscard]] auto setvolname_impl(const char *volname) -> api_error override;
[[nodiscard]] auto statfs_x_impl(std::string api_path, struct statfs *stbuf) [[nodiscard]] auto statfs_x_impl(std::string api_path,
-> api_error override; struct statfs *stbuf) -> api_error override;
#else // __APPLE__ #else // __APPLE__
[[nodiscard]] auto statfs_impl(std::string api_path, struct statvfs *stbuf) [[nodiscard]] auto statfs_impl(std::string api_path,
-> api_error override; struct statvfs *stbuf) -> api_error override;
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto truncate_impl(std::string api_path, off_t size, [[nodiscard]] auto
struct fuse_file_info *file_info) truncate_impl(std::string api_path, off_t size,
-> api_error override; struct fuse_file_info *file_info) -> api_error override;
#else #else
[[nodiscard]] auto truncate_impl(std::string api_path, off_t size) [[nodiscard]] auto truncate_impl(std::string api_path,
-> api_error override; off_t size) -> api_error override;
#endif #endif
[[nodiscard]] auto unlink_impl(std::string api_path) -> api_error override; [[nodiscard]] auto unlink_impl(std::string api_path) -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto utimens_impl(std::string api_path, [[nodiscard]] auto
const struct timespec tv[2], utimens_impl(std::string api_path, const struct timespec tv[2],
struct fuse_file_info *file_info) struct fuse_file_info *file_info) -> api_error override;
-> api_error override;
#else #else
[[nodiscard]] auto utimens_impl(std::string api_path, [[nodiscard]] auto
const struct timespec tv[2]) utimens_impl(std::string api_path,
-> api_error override; const struct timespec tv[2]) -> api_error override;
#endif #endif
[[nodiscard]] auto write_impl(std::string api_path, const char *buffer, [[nodiscard]] auto
size_t write_size, off_t write_offset, write_impl(std::string api_path, const char *buffer, size_t write_size,
struct fuse_file_info *file_info, off_t write_offset, struct fuse_file_info *file_info,
std::size_t &bytes_written) std::size_t &bytes_written) -> api_error override;
-> api_error override;
public: public:
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const [[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
@ -292,17 +286,16 @@ public:
[[nodiscard]] auto get_directory_items(const std::string &api_path) const [[nodiscard]] auto get_directory_items(const std::string &api_path) const
-> directory_item_list override; -> directory_item_list override;
[[nodiscard]] auto get_file_size(const std::string &api_path) const [[nodiscard]] auto
-> std::uint64_t override; get_file_size(const std::string &api_path) const -> std::uint64_t override;
[[nodiscard]] auto get_item_meta(const std::string &api_path, [[nodiscard]] auto
api_meta_map &meta) const get_item_meta(const std::string &api_path,
-> api_error override; api_meta_map &meta) const -> api_error override;
[[nodiscard]] auto get_item_meta(const std::string &api_path, [[nodiscard]] auto
const std::string &name, get_item_meta(const std::string &api_path, const std::string &name,
std::string &value) const std::string &value) const -> api_error override;
-> api_error override;
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override; [[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
@ -313,16 +306,16 @@ public:
void get_volume_info(UINT64 &total_size, UINT64 &free_size, void get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) const override; std::string &volume_label) const override;
[[nodiscard]] auto is_processing(const std::string &api_path) const [[nodiscard]] auto
-> bool override; is_processing(const std::string &api_path) const -> bool override;
[[nodiscard]] auto rename_directory(const std::string &from_api_path, [[nodiscard]] auto
const std::string &to_api_path) rename_directory(const std::string &from_api_path,
-> int override; const std::string &to_api_path) -> int override;
[[nodiscard]] auto rename_file(const std::string &from_api_path, [[nodiscard]] auto rename_file(const std::string &from_api_path,
const std::string &to_api_path, bool overwrite) const std::string &to_api_path,
-> int override; bool overwrite) -> int override;
void set_item_meta(const std::string &api_path, const std::string &key, void set_item_meta(const std::string &api_path, const std::string &key,
const std::string &value) override; const std::string &value) override;

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_ #ifndef INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
#define INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_ #define INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_
#ifndef _WIN32 #if !defined(_WIN32)
#include "drives/fuse/fuse_base.hpp" #include "drives/fuse/fuse_base.hpp"
#include "drives/fuse/i_fuse_drive.hpp" #include "drives/fuse/i_fuse_drive.hpp"
@ -43,17 +43,16 @@ public:
auto operator=(fuse_drive_base &&) -> fuse_drive_base & = delete; auto operator=(fuse_drive_base &&) -> fuse_drive_base & = delete;
protected: protected:
[[nodiscard]] auto access_impl(std::string api_path, int mask) [[nodiscard]] auto access_impl(std::string api_path,
-> api_error override; int mask) -> api_error override;
protected: protected:
[[nodiscard]] auto check_access(const std::string &api_path, int mask) const [[nodiscard]] auto check_access(const std::string &api_path,
-> api_error; int mask) const -> api_error;
[[nodiscard]] auto [[nodiscard]] auto check_and_perform(
check_and_perform(const std::string &api_path, int parent_mask, const std::string &api_path, int parent_mask,
const std::function<api_error(api_meta_map &meta)> &action) const std::function<api_error(api_meta_map &meta)> &action) -> api_error;
-> api_error;
[[nodiscard]] auto get_current_gid() const -> gid_t; [[nodiscard]] auto get_current_gid() const -> gid_t;
@ -63,62 +62,57 @@ protected:
[[nodiscard]] auto get_effective_uid() const -> uid_t; [[nodiscard]] auto get_effective_uid() const -> uid_t;
[[nodiscard]] static auto check_open_flags(int flags, int mask, [[nodiscard]] static auto
const api_error &fail_error) check_open_flags(int flags, int mask,
-> api_error; const api_error &fail_error) -> api_error;
[[nodiscard]] auto check_owner(const api_meta_map &meta) const -> api_error; [[nodiscard]] auto check_owner(const api_meta_map &meta) const -> api_error;
[[nodiscard]] static auto check_readable(int flags, [[nodiscard]] static auto
const api_error &fail_error) check_readable(int flags, const api_error &fail_error) -> api_error;
-> api_error;
[[nodiscard]] static auto check_writeable(int flags, [[nodiscard]] static auto
const api_error &fail_error) check_writeable(int flags, const api_error &fail_error) -> api_error;
-> api_error;
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] static auto get_flags_from_meta(const api_meta_map &meta) [[nodiscard]] static auto
-> __uint32_t; get_flags_from_meta(const api_meta_map &meta) -> __uint32_t;
#endif // __APPLE__ #endif // __APPLE__
[[nodiscard]] static auto get_gid_from_meta(const api_meta_map &meta) [[nodiscard]] static auto
-> gid_t; get_gid_from_meta(const api_meta_map &meta) -> gid_t;
[[nodiscard]] static auto get_mode_from_meta(const api_meta_map &meta) [[nodiscard]] static auto
-> mode_t; get_mode_from_meta(const api_meta_map &meta) -> mode_t;
static void get_timespec_from_meta(const api_meta_map &meta, static void get_timespec_from_meta(const api_meta_map &meta,
const std::string &name, const std::string &name,
struct timespec &ts); struct timespec &ts);
[[nodiscard]] static auto get_uid_from_meta(const api_meta_map &meta) [[nodiscard]] static auto
-> uid_t; get_uid_from_meta(const api_meta_map &meta) -> uid_t;
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto parse_xattr_parameters(const char *name, [[nodiscard]] auto
const uint32_t &position, parse_xattr_parameters(const char *name, const uint32_t &position,
std::string &attribute_name, std::string &attribute_name,
const std::string &api_path) const std::string &api_path) -> api_error;
-> api_error;
#else #else
[[nodiscard]] auto parse_xattr_parameters(const char *name, [[nodiscard]] auto
std::string &attribute_name, parse_xattr_parameters(const char *name, std::string &attribute_name,
const std::string &api_path) const std::string &api_path) -> api_error;
-> api_error;
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto [[nodiscard]] auto
parse_xattr_parameters(const char *name, const char *value, size_t size, parse_xattr_parameters(const char *name, const char *value, size_t size,
const uint32_t &position, std::string &attribute_name, const uint32_t &position, std::string &attribute_name,
const std::string &api_path) -> api_error; const std::string &api_path) -> api_error;
#else #else
[[nodiscard]] auto parse_xattr_parameters(const char *name, const char *value, [[nodiscard]] auto
size_t size, parse_xattr_parameters(const char *name, const char *value, size_t size,
std::string &attribute_name, std::string &attribute_name,
const std::string &api_path) const std::string &api_path) -> api_error;
-> api_error;
#endif #endif
static void populate_stat(const std::string &api_path, static void populate_stat(const std::string &api_path,
@ -131,8 +125,8 @@ protected:
struct timespec &ts); struct timespec &ts);
public: public:
[[nodiscard]] auto check_owner(const std::string &api_path) const [[nodiscard]] auto
-> api_error override; check_owner(const std::string &api_path) const -> api_error override;
[[nodiscard]] auto check_parent_access(const std::string &api_path, [[nodiscard]] auto check_parent_access(const std::string &api_path,
int mask) const -> api_error override; int mask) const -> api_error override;

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_ #ifndef INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
#define INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_ #define INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_
#ifndef _WIN32 #if !defined(_WIN32)
#include "types/repertory.hpp" #include "types/repertory.hpp"
@ -30,32 +30,29 @@ class i_fuse_drive {
INTERFACE_SETUP(i_fuse_drive); INTERFACE_SETUP(i_fuse_drive);
public: public:
[[nodiscard]] virtual auto check_owner(const std::string &api_path) const [[nodiscard]] virtual auto
-> api_error = 0; check_owner(const std::string &api_path) const -> api_error = 0;
[[nodiscard]] virtual auto check_parent_access(const std::string &api_path,
int mask) const
-> api_error = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
get_directory_item_count(const std::string &api_path) const check_parent_access(const std::string &api_path,
-> std::uint64_t = 0; int mask) const -> api_error = 0;
[[nodiscard]] virtual auto get_directory_item_count(
const std::string &api_path) const -> std::uint64_t = 0;
[[nodiscard]] virtual auto get_directory_items(
const std::string &api_path) const -> directory_item_list = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
get_directory_items(const std::string &api_path) const get_file_size(const std::string &api_path) const -> std::uint64_t = 0;
-> directory_item_list = 0;
[[nodiscard]] virtual auto get_file_size(const std::string &api_path) const [[nodiscard]] virtual auto
-> std::uint64_t = 0; get_item_meta(const std::string &api_path,
api_meta_map &meta) const -> api_error = 0;
[[nodiscard]] virtual auto get_item_meta(const std::string &api_path, [[nodiscard]] virtual auto
api_meta_map &meta) const get_item_meta(const std::string &api_path, const std::string &name,
-> api_error = 0; std::string &value) const -> api_error = 0;
[[nodiscard]] virtual auto get_item_meta(const std::string &api_path,
const std::string &name,
std::string &value) const
-> api_error = 0;
[[nodiscard]] virtual auto get_total_drive_space() const -> std::uint64_t = 0; [[nodiscard]] virtual auto get_total_drive_space() const -> std::uint64_t = 0;
@ -66,12 +63,12 @@ public:
virtual void get_volume_info(UINT64 &total_size, UINT64 &free_size, virtual void get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) const = 0; std::string &volume_label) const = 0;
[[nodiscard]] virtual auto is_processing(const std::string &api_path) const [[nodiscard]] virtual auto
-> bool = 0; is_processing(const std::string &api_path) const -> bool = 0;
[[nodiscard]] virtual auto rename_directory(const std::string &from_api_path, [[nodiscard]] virtual auto
const std::string &to_api_path) rename_directory(const std::string &from_api_path,
-> int = 0; const std::string &to_api_path) -> int = 0;
[[nodiscard]] virtual auto rename_file(const std::string &from_api_path, [[nodiscard]] virtual auto rename_file(const std::string &from_api_path,
const std::string &to_api_path, const std::string &to_api_path,

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_ #ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
#define INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_ #define INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_FUSE_DRIVE_HPP_
#ifndef _WIN32 #if !defined(_WIN32)
#include "drives/fuse/fuse_base.hpp" #include "drives/fuse/fuse_base.hpp"
#include "drives/fuse/remotefuse/i_remote_instance.hpp" #include "drives/fuse/remotefuse/i_remote_instance.hpp"
@ -57,94 +57,92 @@ private:
struct stat &unix_st); struct stat &unix_st);
protected: protected:
[[nodiscard]] auto access_impl(std::string api_path, int mask) [[nodiscard]] auto access_impl(std::string api_path,
-> api_error override; int mask) -> api_error override;
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto chflags_impl(std::string api_path, uint32_t flags) [[nodiscard]] auto chflags_impl(std::string api_path,
-> api_error override; uint32_t flags) -> api_error override;
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode, [[nodiscard]] auto
struct fuse_file_info *f_info) chmod_impl(std::string api_path, mode_t mode,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
#else #else
[[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode) [[nodiscard]] auto chmod_impl(std::string api_path,
-> api_error override; mode_t mode) -> api_error override;
#endif #endif
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid, [[nodiscard]] auto
struct fuse_file_info *f_info) chown_impl(std::string api_path, uid_t uid, gid_t gid,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
#else #else
[[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid) [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid,
-> api_error override; gid_t gid) -> api_error override;
#endif #endif
[[nodiscard]] auto create_impl(std::string api_path, mode_t mode, [[nodiscard]] auto
struct fuse_file_info *f_info) create_impl(std::string api_path, mode_t mode,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
void destroy_impl(void * /*ptr*/) override; void destroy_impl(void * /*ptr*/) override;
[[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *unix_st, [[nodiscard]] auto
struct fuse_file_info *f_info) fgetattr_impl(std::string api_path, struct stat *unix_st,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto fsetattr_x_impl(std::string api_path, [[nodiscard]] auto
struct setattr_x *attr, fsetattr_x_impl(std::string api_path, struct setattr_x *attr,
struct fuse_file_info *f_info) struct fuse_file_info *f_info) -> api_error override;
-> api_error override;
#endif // __APPLE__ #endif // __APPLE__
[[nodiscard]] auto fsync_impl(std::string api_path, int datasync, [[nodiscard]] auto
struct fuse_file_info *f_info) fsync_impl(std::string api_path, int datasync,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
#if FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION < 30
[[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size, [[nodiscard]] auto
struct fuse_file_info *f_info) ftruncate_impl(std::string api_path, off_t size,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
#endif #endif
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto getattr_impl(std::string api_path, struct stat *unix_st, [[nodiscard]] auto
struct fuse_file_info *f_info) getattr_impl(std::string api_path, struct stat *unix_st,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
#else #else
[[nodiscard]] auto getattr_impl(std::string api_path, struct stat *unix_st) [[nodiscard]] auto getattr_impl(std::string api_path,
-> api_error override; struct stat *unix_st) -> api_error override;
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto getxtimes_impl(std::string api_path, [[nodiscard]] auto
struct timespec *bkuptime, getxtimes_impl(std::string api_path, struct timespec *bkuptime,
struct timespec *crtime) struct timespec *crtime) -> api_error override;
-> api_error override;
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) auto init_impl(struct fuse_conn_info *conn,
-> void * override; struct fuse_config *cfg) -> void * override;
#else #else
auto init_impl(struct fuse_conn_info *conn) -> void * override; auto init_impl(struct fuse_conn_info *conn) -> void * override;
#endif #endif
[[nodiscard]] auto mkdir_impl(std::string api_path, mode_t mode) [[nodiscard]] auto mkdir_impl(std::string api_path,
-> api_error override; mode_t mode) -> api_error override;
void notify_fuse_main_exit(int &ret) override; void notify_fuse_main_exit(int &ret) override;
[[nodiscard]] auto open_impl(std::string api_path, [[nodiscard]] auto
struct fuse_file_info *f_info) open_impl(std::string api_path,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
[[nodiscard]] auto opendir_impl(std::string api_path, [[nodiscard]] auto
struct fuse_file_info *f_info) opendir_impl(std::string api_path,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
[[nodiscard]] auto read_impl(std::string api_path, char *buffer, [[nodiscard]] auto read_impl(std::string api_path, char *buffer,
size_t read_size, off_t read_offset, size_t read_size, off_t read_offset,
@ -152,30 +150,29 @@ protected:
std::size_t &bytes_read) -> api_error override; std::size_t &bytes_read) -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto readdir_impl(std::string api_path, void *buf, [[nodiscard]] auto
fuse_fill_dir_t fuse_fill_dir, off_t offset, readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
struct fuse_file_info *f_info, off_t offset, struct fuse_file_info *f_info,
fuse_readdir_flags flags) fuse_readdir_flags flags) -> api_error override;
-> api_error override;
#else #else
[[nodiscard]] auto readdir_impl(std::string api_path, void *buf, [[nodiscard]] auto
fuse_fill_dir_t fuse_fill_dir, off_t offset, readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
struct fuse_file_info *f_info) off_t offset,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
#endif #endif
[[nodiscard]] auto release_impl(std::string api_path, [[nodiscard]] auto
struct fuse_file_info *f_info) release_impl(std::string api_path,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
[[nodiscard]] auto releasedir_impl(std::string api_path, [[nodiscard]] auto
struct fuse_file_info *f_info) releasedir_impl(std::string api_path,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto rename_impl(std::string from_api_path, [[nodiscard]] auto rename_impl(std::string from_api_path,
std::string to_api_path, unsigned int flags) std::string to_api_path,
-> api_error override; unsigned int flags) -> api_error override;
#else #else
[[nodiscard]] auto rename_impl(std::string from_api_path, [[nodiscard]] auto rename_impl(std::string from_api_path,
std::string to_api_path) -> api_error override; std::string to_api_path) -> api_error override;
@ -183,61 +180,59 @@ protected:
[[nodiscard]] auto rmdir_impl(std::string api_path) -> api_error override; [[nodiscard]] auto rmdir_impl(std::string api_path) -> api_error override;
#ifdef __APPLE__ #if defined(__APPLE__)
[[nodiscard]] auto setattr_x_impl(std::string api_path, [[nodiscard]] auto
struct setattr_x *attr) setattr_x_impl(std::string api_path,
-> api_error override; struct setattr_x *attr) -> api_error override;
[[nodiscard]] auto setbkuptime_impl(std::string api_path, [[nodiscard]] auto
const struct timespec *bkuptime) setbkuptime_impl(std::string api_path,
-> api_error override; const struct timespec *bkuptime) -> api_error override;
[[nodiscard]] auto setchgtime_impl(std::string api_path, [[nodiscard]] auto
const struct timespec *chgtime) setchgtime_impl(std::string api_path,
-> api_error override; const struct timespec *chgtime) -> api_error override;
[[nodiscard]] auto setcrtime_impl(std::string api_path, [[nodiscard]] auto
const struct timespec *crtime) setcrtime_impl(std::string api_path,
-> api_error override; const struct timespec *crtime) -> api_error override;
[[nodiscard]] virtual auto setvolname_impl(const char *volname) [[nodiscard]] virtual auto
-> api_error override; setvolname_impl(const char *volname) -> api_error override;
[[nodiscard]] auto statfs_x_impl(std::string api_path, struct statfs *stbuf) [[nodiscard]] auto statfs_x_impl(std::string api_path,
-> api_error override; struct statfs *stbuf) -> api_error override;
#else // __APPLE__ #else // __APPLE__
[[nodiscard]] auto statfs_impl(std::string api_path, struct statvfs *stbuf) [[nodiscard]] auto statfs_impl(std::string api_path,
-> api_error override; struct statvfs *stbuf) -> api_error override;
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto truncate_impl(std::string api_path, off_t size, [[nodiscard]] auto
struct fuse_file_info *f_info) truncate_impl(std::string api_path, off_t size,
-> api_error override; struct fuse_file_info *f_info) -> api_error override;
#else #else
[[nodiscard]] auto truncate_impl(std::string api_path, off_t size) [[nodiscard]] auto truncate_impl(std::string api_path,
-> api_error override; off_t size) -> api_error override;
#endif #endif
[[nodiscard]] auto unlink_impl(std::string api_path) -> api_error override; [[nodiscard]] auto unlink_impl(std::string api_path) -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto utimens_impl(std::string api_path, [[nodiscard]] auto
const struct timespec tv[2], utimens_impl(std::string api_path, const struct timespec tv[2],
struct fuse_file_info *f_info) struct fuse_file_info *f_info) -> api_error override;
-> api_error override;
#else #else
[[nodiscard]] auto utimens_impl(std::string api_path, [[nodiscard]] auto
const struct timespec tv[2]) utimens_impl(std::string api_path,
-> api_error override; const struct timespec tv[2]) -> api_error override;
#endif #endif
[[nodiscard]] auto write_impl(std::string api_path, const char *buffer, [[nodiscard]] auto
size_t write_size, off_t write_offset, write_impl(std::string api_path, const char *buffer, size_t write_size,
struct fuse_file_info *f_info, off_t write_offset, struct fuse_file_info *f_info,
std::size_t &bytes_written) std::size_t &bytes_written) -> api_error override;
-> api_error override;
}; };
} // namespace remote_fuse } // namespace remote_fuse
} // namespace repertory } // namespace repertory

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_ #ifndef INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
#define INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_ #define INCLUDE_DRIVES_FUSE_REMOTEFUSE_REMOTE_SERVER_HPP_
#ifndef _WIN32 #if !defined(_WIN32)
#include "drives/directory_cache.hpp" #include "drives/directory_cache.hpp"
#include "drives/fuse/i_fuse_drive.hpp" #include "drives/fuse/i_fuse_drive.hpp"
@ -46,9 +46,9 @@ private:
[[nodiscard]] static auto empty_as_zero(const json &data) -> std::string; [[nodiscard]] static auto empty_as_zero(const json &data) -> std::string;
[[nodiscard]] auto populate_file_info(const std::string &api_path, [[nodiscard]] auto
remote::file_info &file_info) populate_file_info(const std::string &api_path,
-> packet::error_type; remote::file_info &file_info) -> packet::error_type;
void populate_file_info(const std::string &api_path, const UINT64 &file_size, void populate_file_info(const std::string &api_path, const UINT64 &file_size,
const UINT32 &attributes, const UINT32 &attributes,
@ -72,14 +72,14 @@ public:
[[nodiscard]] auto fuse_chmod(const char *path, const remote::file_mode &mode) [[nodiscard]] auto fuse_chmod(const char *path, const remote::file_mode &mode)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto fuse_chown(const char *path, const remote::user_id &uid, [[nodiscard]] auto
const remote::group_id &gid) fuse_chown(const char *path, const remote::user_id &uid,
-> packet::error_type override; const remote::group_id &gid) -> packet::error_type override;
[[nodiscard]] auto [[nodiscard]] auto
fuse_create(const char *path, const remote::file_mode &mode, fuse_create(const char *path, const remote::file_mode &mode,
const remote::open_flags &flags, remote::file_handle &handle) const remote::open_flags &flags,
-> packet::error_type override; remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_destroy() -> packet::error_type override; [[nodiscard]] auto fuse_destroy() -> packet::error_type override;
@ -88,28 +88,25 @@ public:
remote::file_offset &length, const remote::file_handle &handle) override remote::file_offset &length, const remote::file_handle &handle) override
;*/ ;*/
[[nodiscard]] auto fuse_fgetattr(const char *path, remote::stat &r_stat, [[nodiscard]] auto fuse_fgetattr(
bool &directory, const char *path, remote::stat &r_stat, bool &directory,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type override;
-> packet::error_type override;
[[nodiscard]] auto fuse_fsetattr_x(const char *path, [[nodiscard]] auto fuse_fsetattr_x(
const remote::setattr_x &attr, const char *path, const remote::setattr_x &attr,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type override;
-> packet::error_type override;
[[nodiscard]] auto fuse_fsync(const char *path, const std::int32_t &datasync, [[nodiscard]] auto
const remote::file_handle &handle) fuse_fsync(const char *path, const std::int32_t &datasync,
-> packet::error_type override; const remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_ftruncate(const char *path, [[nodiscard]] auto fuse_ftruncate(
const remote::file_offset &size, const char *path, const remote::file_offset &size,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type override;
-> packet::error_type override;
[[nodiscard]] auto fuse_getattr(const char *path, remote::stat &r_stat, [[nodiscard]] auto
bool &directory) fuse_getattr(const char *path, remote::stat &r_stat,
-> packet::error_type override; bool &directory) -> packet::error_type override;
/*[[nodiscard]] packet::error_type fuse_getxattr(const char *path, const char /*[[nodiscard]] packet::error_type fuse_getxattr(const char *path, const char
*name, char *value, const remote::file_size &size) override ; *name, char *value, const remote::file_size &size) override ;
@ -118,10 +115,9 @@ public:
*name, char *value, const remote::file_size &size, std::uint32_t position) *name, char *value, const remote::file_size &size, std::uint32_t position)
override ;*/ override ;*/
[[nodiscard]] auto fuse_getxtimes(const char *path, [[nodiscard]] auto
remote::file_time &bkuptime, fuse_getxtimes(const char *path, remote::file_time &bkuptime,
remote::file_time &crtime) remote::file_time &crtime) -> packet::error_type override;
-> packet::error_type override;
[[nodiscard]] auto fuse_init() -> packet::error_type override; [[nodiscard]] auto fuse_init() -> packet::error_type override;
@ -129,30 +125,28 @@ public:
*buffer, const remote::file_size &size) override ;*/ *buffer, const remote::file_size &size) override ;*/
[[nodiscard]] auto [[nodiscard]] auto
fuse_mkdir(const char *path, const remote::file_mode &mode) fuse_mkdir(const char *path,
-> packet::error_type override; const remote::file_mode &mode) -> packet::error_type override;
[[nodiscard]] auto fuse_open(const char *path, [[nodiscard]] auto
const remote::open_flags &flags, fuse_open(const char *path, const remote::open_flags &flags,
remote::file_handle &handle) remote::file_handle &handle) -> packet::error_type override;
-> packet::error_type override;
[[nodiscard]] auto fuse_opendir(const char *path, remote::file_handle &handle) [[nodiscard]] auto fuse_opendir(const char *path, remote::file_handle &handle)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto fuse_read(const char *path, char *buffer, [[nodiscard]] auto
const remote::file_size &read_size, fuse_read(const char *path, char *buffer, const remote::file_size &read_size,
const remote::file_offset &read_offset, const remote::file_offset &read_offset,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type override;
-> packet::error_type override;
[[nodiscard]] auto fuse_rename(const char *from, const char *to) [[nodiscard]] auto fuse_rename(const char *from,
-> packet::error_type override; const char *to) -> packet::error_type override;
[[nodiscard]] auto [[nodiscard]] auto
fuse_readdir(const char *path, const remote::file_offset &offset, fuse_readdir(const char *path, const remote::file_offset &offset,
const remote::file_handle &handle, std::string &item_path) const remote::file_handle &handle,
-> packet::error_type override; std::string &item_path) -> packet::error_type override;
[[nodiscard]] auto fuse_release(const char *path, [[nodiscard]] auto fuse_release(const char *path,
const remote::file_handle &handle) const remote::file_handle &handle)
@ -166,8 +160,8 @@ public:
* char *name) override * char *name) override
* ;*/ * ;*/
[[nodiscard]] auto fuse_rmdir(const char *path) [[nodiscard]] auto
-> packet::error_type override; fuse_rmdir(const char *path) -> packet::error_type override;
[[nodiscard]] auto fuse_setattr_x(const char *path, remote::setattr_x &attr) [[nodiscard]] auto fuse_setattr_x(const char *path, remote::setattr_x &attr)
-> packet::error_type override; -> packet::error_type override;
@ -184,8 +178,8 @@ public:
const remote::file_time &crtime) const remote::file_time &crtime)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto fuse_setvolname(const char *volname) [[nodiscard]] auto
-> packet::error_type override; fuse_setvolname(const char *volname) -> packet::error_type override;
/*[[nodiscard]] packet::error_type fuse_setxattr(const char *path, const char /*[[nodiscard]] packet::error_type fuse_setxattr(const char *path, const char
*name, const char *value, const remote::file_size &size, const std::int32_t *name, const char *value, const remote::file_size &size, const std::int32_t
@ -195,70 +189,67 @@ public:
char *name, const char *value, const remote::file_size &size, const char *name, const char *value, const remote::file_size &size, const
std::int32_t &flags, std::uint32_t position) override ;*/ std::int32_t &flags, std::uint32_t position) override ;*/
[[nodiscard]] auto fuse_statfs(const char *path, std::uint64_t frsize, [[nodiscard]] auto
remote::statfs &r_stat) fuse_statfs(const char *path, std::uint64_t frsize,
-> packet::error_type override; remote::statfs &r_stat) -> packet::error_type override;
[[nodiscard]] auto fuse_statfs_x(const char *path, std::uint64_t bsize, [[nodiscard]] auto
remote::statfs_x &r_stat) fuse_statfs_x(const char *path, std::uint64_t bsize,
-> packet::error_type override; remote::statfs_x &r_stat) -> packet::error_type override;
[[nodiscard]] auto fuse_truncate(const char *path, [[nodiscard]] auto
const remote::file_offset &size) fuse_truncate(const char *path,
-> packet::error_type override; const remote::file_offset &size) -> packet::error_type override;
[[nodiscard]] auto fuse_unlink(const char *path) [[nodiscard]] auto
-> packet::error_type override; fuse_unlink(const char *path) -> packet::error_type override;
[[nodiscard]] auto fuse_utimens(const char *path, const remote::file_time *tv, [[nodiscard]] auto
std::uint64_t op0, std::uint64_t op1) fuse_utimens(const char *path, const remote::file_time *tv, std::uint64_t op0,
-> packet::error_type override; std::uint64_t op1) -> packet::error_type override;
[[nodiscard]] auto fuse_write(const char *path, const char *buffer, [[nodiscard]] auto
const remote::file_size &write_size, fuse_write(const char *path, const char *buffer,
const remote::file_offset &write_offset, const remote::file_size &write_size,
const remote::file_handle &handle) const remote::file_offset &write_offset,
-> packet::error_type override; const remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_write_base64(const char *path, const char *buffer, [[nodiscard]] auto fuse_write_base64(
const remote::file_size &write_size, const char *path, const char *buffer, const remote::file_size &write_size,
const remote::file_offset &write_offset, const remote::file_offset &write_offset,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type override;
-> packet::error_type override;
void set_fuse_uid_gid(const remote::user_id &, void set_fuse_uid_gid(const remote::user_id &,
const remote::group_id &) override {} const remote::group_id &) override {}
// JSON Layer // JSON Layer
[[nodiscard]] auto winfsp_get_dir_buffer(PVOID /*file_desc*/, [[nodiscard]] auto
PVOID *& /*ptr*/) winfsp_get_dir_buffer(PVOID /*file_desc*/,
-> packet::error_type override { PVOID *& /*ptr*/) -> packet::error_type override {
return STATUS_INVALID_HANDLE; return STATUS_INVALID_HANDLE;
} }
[[nodiscard]] auto json_create_directory_snapshot(const std::string &path, [[nodiscard]] auto json_create_directory_snapshot(
json &json_data) const std::string &path, json &json_data) -> packet::error_type override;
-> packet::error_type override;
[[nodiscard]] auto json_read_directory_snapshot( [[nodiscard]] auto json_read_directory_snapshot(
const std::string &path, const remote::file_handle &handle, const std::string &path, const remote::file_handle &handle,
std::uint32_t page, json &json_data) -> packet::error_type override; std::uint32_t page, json &json_data) -> packet::error_type override;
[[nodiscard]] auto [[nodiscard]] auto json_release_directory_snapshot(
json_release_directory_snapshot(const std::string &path, const std::string &path,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type override;
-> packet::error_type override;
// WinFSP Layer // WinFSP Layer
[[nodiscard]] auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) [[nodiscard]] auto winfsp_can_delete(PVOID file_desc, PWSTR file_name)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, [[nodiscard]] auto
UINT32 flags, BOOLEAN &was_closed) winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
-> packet::error_type override; BOOLEAN &was_closed) -> packet::error_type override;
[[nodiscard]] auto winfsp_close(PVOID file_desc) [[nodiscard]] auto
-> packet::error_type override; winfsp_close(PVOID file_desc) -> packet::error_type override;
[[nodiscard]] auto [[nodiscard]] auto
winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
@ -273,63 +264,57 @@ public:
remote::file_info *file_info) remote::file_info *file_info)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_get_security_by_name(
PWSTR file_name, PUINT32 attributes,
std::uint64_t * /*security_descriptor_size*/,
std::wstring & /*str_descriptor*/) -> packet::error_type override;
[[nodiscard]] auto winfsp_get_volume_info(
UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) -> packet::error_type override;
[[nodiscard]] auto [[nodiscard]] auto
winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes, winfsp_mounted(const std::wstring &location) -> packet::error_type override;
std::uint64_t * /*security_descriptor_size*/,
std::wstring & /*str_descriptor*/)
-> packet::error_type override;
[[nodiscard]] auto winfsp_get_volume_info(UINT64 &total_size, [[nodiscard]] auto
UINT64 &free_size, winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
std::string &volume_label) PVOID *file_desc, remote::file_info *file_info,
-> packet::error_type override; std::string &normalized_name) -> packet::error_type override;
[[nodiscard]] auto winfsp_mounted(const std::wstring &location) [[nodiscard]] auto
-> packet::error_type override; winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 /*allocation_size*/,
remote::file_info *file_info) -> packet::error_type override;
[[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options, [[nodiscard]] auto
UINT32 granted_access, PVOID *file_desc, winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
remote::file_info *file_info, PUINT32 bytes_transferred) -> packet::error_type override;
std::string &normalized_name)
-> packet::error_type override;
[[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, [[nodiscard]] auto
BOOLEAN replace_attributes, winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/, PWSTR marker,
UINT64 /*allocation_size*/, json &itemList) -> packet::error_type override;
remote::file_info *file_info)
-> packet::error_type override;
[[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, [[nodiscard]] auto
UINT32 length, PUINT32 bytes_transferred) winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name,
-> packet::error_type override; BOOLEAN replace_if_exists) -> packet::error_type override;
[[nodiscard]] auto winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
PWSTR marker, json &itemList)
-> packet::error_type override;
[[nodiscard]] auto winfsp_rename(PVOID /*file_desc*/, PWSTR file_name,
PWSTR new_file_name,
BOOLEAN replace_if_exists)
-> packet::error_type override;
[[nodiscard]] auto winfsp_set_basic_info( [[nodiscard]] auto winfsp_set_basic_info(
PVOID file_desc, UINT32 attributes, UINT64 creation_time, PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info) -> packet::error_type override; remote::file_info *file_info) -> packet::error_type override;
[[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, [[nodiscard]] auto winfsp_set_file_size(
BOOLEAN set_allocation_size, PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type override;
-> packet::error_type override;
[[nodiscard]] auto winfsp_unmounted(const std::wstring &location) [[nodiscard]] auto
-> packet::error_type override; winfsp_unmounted(const std::wstring &location) -> packet::error_type override;
[[nodiscard]] auto [[nodiscard]] auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN write_to_end, BOOLEAN constrained_io, BOOLEAN write_to_end, BOOLEAN constrained_io,
PUINT32 bytes_transferred, remote::file_info *file_info) PUINT32 bytes_transferred,
-> packet::error_type override; remote::file_info *file_info) -> packet::error_type override;
}; };
} // namespace remote_fuse } // namespace remote_fuse
} // namespace repertory } // namespace repertory

View File

@ -61,27 +61,27 @@ protected:
virtual void delete_open_directory(void *dir) = 0; virtual void delete_open_directory(void *dir) = 0;
#ifdef _WIN32 #if defined(_WIN32)
[[nodiscard]] auto get_directory_buffer(const native_handle &handle, [[nodiscard]] auto get_directory_buffer(const native_handle &handle,
PVOID *&buffer) -> bool; PVOID *&buffer) -> bool;
#endif // _WIN32 #endif // _WIN32
[[nodiscard]] auto get_open_file_path(const native_handle &handle) [[nodiscard]] auto
-> std::string; get_open_file_path(const native_handle &handle) -> std::string;
[[nodiscard]] auto get_open_info(const native_handle &handle, open_info &oi) [[nodiscard]] auto get_open_info(const native_handle &handle,
-> bool; open_info &oi) -> bool;
[[nodiscard]] auto has_open_directory(const std::string &client_id, void *dir) [[nodiscard]] auto has_open_directory(const std::string &client_id,
-> bool; void *dir) -> bool;
[[nodiscard]] auto has_compat_open_info(const remote::file_handle &handle, [[nodiscard]] auto has_compat_open_info(const remote::file_handle &handle,
int error_return) -> int; int error_return) -> int;
template <typename error_type> template <typename error_type>
[[nodiscard]] auto has_open_info(const native_handle &handle, [[nodiscard]] auto
const error_type &error_return) has_open_info(const native_handle &handle,
-> error_type { const error_type &error_return) -> error_type {
recur_mutex_lock file_lock(file_mutex_); recur_mutex_lock file_lock(file_mutex_);
return ((file_lookup_.find(handle) == file_lookup_.end()) ? error_return return ((file_lookup_.find(handle) == file_lookup_.end()) ? error_return
: 0); : 0);
@ -106,8 +106,8 @@ protected:
void set_open_info(const native_handle &handle, open_info oi); void set_open_info(const native_handle &handle, open_info oi);
public: public:
[[nodiscard]] auto get_open_file_count(const std::string &file_path) const [[nodiscard]] auto
-> std::size_t; get_open_file_count(const std::string &file_path) const -> std::size_t;
}; };
} // namespace repertory } // namespace repertory

View File

@ -137,7 +137,7 @@ public:
allocation_size, &file_desc, &file_info, allocation_size, &file_desc, &file_info,
normalized_name, exists); normalized_name, exists);
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
#ifdef _WIN32 #if defined(_WIN32)
this->set_client_id(file_desc, client_id); this->set_client_id(file_desc, client_id);
#else #else
this->set_client_id( this->set_client_id(
@ -277,7 +277,7 @@ public:
granted_access, &file_desc, &file_info, granted_access, &file_desc, &file_info,
normalized_name); normalized_name);
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
#ifdef _WIN32 #if defined(_WIN32)
this->set_client_id(file_desc, client_id); this->set_client_id(file_desc, client_id);
#else #else
this->set_client_id( this->set_client_id(
@ -585,7 +585,7 @@ public:
remote::file_handle handle{}; remote::file_handle handle{};
if ((ret = this->fuse_create(path.data(), mode, flags, handle)) >= if ((ret = this->fuse_create(path.data(), mode, flags, handle)) >=
0) { 0) {
#ifdef _WIN32 #if defined(_WIN32)
this->set_compat_client_id(handle, client_id); this->set_compat_client_id(handle, client_id);
#else #else
this->set_client_id(static_cast<native_handle>(handle), client_id); this->set_client_id(static_cast<native_handle>(handle), client_id);
@ -840,7 +840,7 @@ public:
remote::file_handle handle; remote::file_handle handle;
if ((ret = this->fuse_open(&path[0], flags, handle)) >= 0) { if ((ret = this->fuse_open(&path[0], flags, handle)) >= 0) {
#ifdef _WIN32 #if defined(_WIN32)
this->set_compat_client_id(handle, client_id); this->set_compat_client_id(handle, client_id);
#else #else
this->set_client_id(static_cast<native_handle>(handle), client_id); this->set_client_id(static_cast<native_handle>(handle), client_id);

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_ #ifndef INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
#define INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_ #define INCLUDE_DRIVES_WINFSP_I_WINFSP_DRIVE_HPP_
#ifdef _WIN32 #if defined(_WIN32)
#include "types/remote.hpp" #include "types/remote.hpp"
#include "types/repertory.hpp" #include "types/repertory.hpp"
@ -31,25 +31,22 @@ class i_winfsp_drive {
INTERFACE_SETUP(i_winfsp_drive); INTERFACE_SETUP(i_winfsp_drive);
public: public:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto get_directory_item_count(
get_directory_item_count(const std::string &api_path) const const std::string &api_path) const -> std::uint64_t = 0;
-> std::uint64_t = 0;
[[nodiscard]] virtual auto get_directory_items(
const std::string &api_path) const -> directory_item_list = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
get_directory_items(const std::string &api_path) const get_file_size(const std::string &api_path) const -> std::uint64_t = 0;
-> directory_item_list = 0;
[[nodiscard]] virtual auto get_file_size(const std::string &api_path) const [[nodiscard]] virtual auto
-> std::uint64_t = 0; get_item_meta(const std::string &api_path, const std::string &name,
std::string &value) const -> api_error = 0;
[[nodiscard]] virtual auto get_item_meta(const std::string &api_path, [[nodiscard]] virtual auto
const std::string &name, get_item_meta(const std::string &api_path,
std::string &value) const api_meta_map &meta) const -> api_error = 0;
-> api_error = 0;
[[nodiscard]] virtual auto get_item_meta(const std::string &api_path,
api_meta_map &meta) const
-> api_error = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
get_security_by_name(PWSTR file_name, PUINT32 attributes, get_security_by_name(PWSTR file_name, PUINT32 attributes,
@ -65,9 +62,9 @@ public:
virtual void get_volume_info(UINT64 &total_size, UINT64 &free_size, virtual void get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) const = 0; std::string &volume_label) const = 0;
[[nodiscard]] virtual auto populate_file_info(const std::string &api_path, [[nodiscard]] virtual auto
remote::file_info &fi) populate_file_info(const std::string &api_path,
-> api_error = 0; remote::file_info &fi) -> api_error = 0;
}; };
} // namespace repertory } // namespace repertory

View File

@ -40,7 +40,7 @@ private:
packet_client packet_client_; packet_client packet_client_;
private: private:
#ifdef _WIN32 #if defined(_WIN32)
#define to_handle(x) (x) #define to_handle(x) (x)
#else #else
static auto to_handle(PVOID file_desc) -> native_handle; static auto to_handle(PVOID file_desc) -> native_handle;
@ -53,17 +53,16 @@ public:
auto json_create_directory_snapshot(const std::string &path, json &json_data) auto json_create_directory_snapshot(const std::string &path, json &json_data)
-> packet::error_type override; -> packet::error_type override;
auto json_read_directory_snapshot(const std::string &path, auto json_read_directory_snapshot(
const remote::file_handle &handle, const std::string &path, const remote::file_handle &handle,
std::uint32_t page, json &json_data) std::uint32_t page, json &json_data) -> packet::error_type override;
-> packet::error_type override;
auto json_release_directory_snapshot(const std::string &path, auto json_release_directory_snapshot(const std::string &path,
const remote::file_handle &handle) const remote::file_handle &handle)
-> packet::error_type override; -> packet::error_type override;
auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) auto winfsp_can_delete(PVOID file_desc,
-> packet::error_type override; PWSTR file_name) -> packet::error_type override;
auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags, auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
BOOLEAN &was_closed) -> packet::error_type override; BOOLEAN &was_closed) -> packet::error_type override;
@ -79,33 +78,32 @@ public:
auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) auto winfsp_flush(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override; -> packet::error_type override;
auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) auto winfsp_get_dir_buffer(PVOID file_desc,
-> packet::error_type override; PVOID *&ptr) -> packet::error_type override;
auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info) auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override; -> packet::error_type override;
auto winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes, auto winfsp_get_security_by_name(
std::uint64_t *descriptor_size, PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size,
std::wstring &string_descriptor) std::wstring &string_descriptor) -> packet::error_type override;
-> packet::error_type override;
auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size, auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) std::string &volume_label)
-> packet::error_type override; -> packet::error_type override;
auto winfsp_mounted(const std::wstring &location) auto
-> packet::error_type override; winfsp_mounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_open(PWSTR file_name, UINT32 create_options, auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc, UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info, std::string &normalized_name) remote::file_info *file_info,
-> packet::error_type override; std::string &normalized_name) -> packet::error_type override;
auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, auto
BOOLEAN replace_attributes, UINT64 allocation_size, winfsp_overwrite(PVOID file_desc, UINT32 attributes,
remote::file_info *file_info) BOOLEAN replace_attributes, UINT64 allocation_size,
-> packet::error_type override; remote::file_info *file_info) -> packet::error_type override;
auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
PUINT32 bytes_transferred) -> packet::error_type override; PUINT32 bytes_transferred) -> packet::error_type override;
@ -116,24 +114,23 @@ public:
auto winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name, auto winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) -> packet::error_type override; BOOLEAN replace_if_exists) -> packet::error_type override;
auto winfsp_set_basic_info(PVOID file_desc, UINT32 attributes, auto winfsp_set_basic_info(
UINT64 creation_time, UINT64 last_access_time, PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_write_time, UINT64 change_time, UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type override;
-> packet::error_type override;
auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, auto winfsp_set_file_size(
BOOLEAN set_allocation_size, PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type override;
-> packet::error_type override;
auto winfsp_unmounted(const std::wstring &location) auto
-> packet::error_type override; winfsp_unmounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, auto
BOOLEAN write_to_end, BOOLEAN constrained_io, winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
PUINT32 bytes_transferred, remote::file_info *file_info) BOOLEAN write_to_end, BOOLEAN constrained_io,
-> packet::error_type override; PUINT32 bytes_transferred,
remote::file_info *file_info) -> packet::error_type override;
}; };
} // namespace remote_winfsp } // namespace remote_winfsp
} // namespace repertory } // namespace repertory

View File

@ -23,7 +23,7 @@
// https://github.com/billziss-gh/winfsp/blob/master/tst/passthrough-cpp/passthrough-cpp.cpp // https://github.com/billziss-gh/winfsp/blob/master/tst/passthrough-cpp/passthrough-cpp.cpp
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_ #ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
#define INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_ #define INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_SERVER_HPP_
#ifdef _WIN32 #if defined(_WIN32)
#include "comm/packet/packet.hpp" #include "comm/packet/packet.hpp"
#include "drives/remote/remote_server_base.hpp" #include "drives/remote/remote_server_base.hpp"
@ -42,23 +42,23 @@ public:
private: private:
[[nodiscard]] auto construct_path(std::string path) -> std::string; [[nodiscard]] auto construct_path(std::string path) -> std::string;
[[nodiscard]] auto populate_file_info(const std::string &api_path, [[nodiscard]] auto
remote::file_info &file_info) populate_file_info(const std::string &api_path,
-> packet::error_type; remote::file_info &file_info) -> packet::error_type;
void populate_stat(const char *path, bool directory, remote::stat &r_stat, void populate_stat(const char *path, bool directory, remote::stat &r_stat,
const struct _stat64 &unix_st); const struct _stat64 &unix_st);
public: public:
// FUSE Layer // FUSE Layer
auto fuse_access(const char *path, const std::int32_t &mask) auto fuse_access(const char *path,
-> packet::error_type override; const std::int32_t &mask) -> packet::error_type override;
auto fuse_chflags(const char *path, std::uint32_t flags) auto fuse_chflags(const char *path,
-> packet::error_type override; std::uint32_t flags) -> packet::error_type override;
auto fuse_chmod(const char *path, const remote::file_mode &mode) auto fuse_chmod(const char *path,
-> packet::error_type override; const remote::file_mode &mode) -> packet::error_type override;
auto fuse_chown(const char *path, const remote::user_id &uid, auto fuse_chown(const char *path, const remote::user_id &uid,
const remote::group_id &gid) -> packet::error_type override; const remote::group_id &gid) -> packet::error_type override;
@ -77,16 +77,16 @@ public:
const remote::file_handle &handle) const remote::file_handle &handle)
-> packet::error_type override; -> packet::error_type override;
auto fuse_fsync(const char *path, const std::int32_t &datasync, auto
const remote::file_handle &handle) fuse_fsync(const char *path, const std::int32_t &datasync,
-> packet::error_type override; const remote::file_handle &handle) -> packet::error_type override;
auto fuse_ftruncate(const char *path, const remote::file_offset &size, auto fuse_ftruncate(const char *path, const remote::file_offset &size,
const remote::file_handle &handle) const remote::file_handle &handle)
-> packet::error_type override; -> packet::error_type override;
auto fuse_getattr(const char *path, remote::stat &r_stat, bool &directory) auto fuse_getattr(const char *path, remote::stat &r_stat,
-> packet::error_type override; bool &directory) -> packet::error_type override;
/*packet::error_type fuse_getxattr(const char *path, const char *name, char /*packet::error_type fuse_getxattr(const char *path, const char *name, char
*value, const remote::file_size &size) override ; *value, const remote::file_size &size) override ;
@ -103,43 +103,41 @@ public:
const remote::file_size &size) override const remote::file_size &size) override
;*/ ;*/
auto fuse_mkdir(const char *path, const remote::file_mode &mode) auto fuse_mkdir(const char *path,
-> packet::error_type override; const remote::file_mode &mode) -> packet::error_type override;
auto fuse_opendir(const char *path, remote::file_handle &handle) auto fuse_opendir(const char *path,
-> packet::error_type override; remote::file_handle &handle) -> packet::error_type override;
auto fuse_create(const char *path, const remote::file_mode &mode, auto fuse_create(const char *path, const remote::file_mode &mode,
const remote::open_flags &flags, remote::file_handle &handle) const remote::open_flags &flags,
-> packet::error_type override; remote::file_handle &handle) -> packet::error_type override;
auto fuse_open(const char *path, const remote::open_flags &flags, auto fuse_open(const char *path, const remote::open_flags &flags,
remote::file_handle &handle) -> packet::error_type override; remote::file_handle &handle) -> packet::error_type override;
auto fuse_read(const char *path, char *buffer, auto
const remote::file_size &read_size, fuse_read(const char *path, char *buffer, const remote::file_size &read_size,
const remote::file_offset &read_offset, const remote::file_offset &read_offset,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type override;
-> packet::error_type override;
auto fuse_rename(const char *from, const char *to) auto fuse_rename(const char *from,
-> packet::error_type override; const char *to) -> packet::error_type override;
auto fuse_write(const char *path, const char *buffer, auto
const remote::file_size &write_size, fuse_write(const char *path, const char *buffer,
const remote::file_offset &write_offset, const remote::file_size &write_size,
const remote::file_handle &handle) const remote::file_offset &write_offset,
-> packet::error_type override; const remote::file_handle &handle) -> packet::error_type override;
auto fuse_write_base64(const char *path, const char *buffer, auto fuse_write_base64(
const remote::file_size &write_size, const char *path, const char *buffer, const remote::file_size &write_size,
const remote::file_offset &write_offset, const remote::file_offset &write_offset,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type override;
-> packet::error_type override;
auto fuse_readdir(const char *path, const remote::file_offset &offset, auto fuse_readdir(const char *path, const remote::file_offset &offset,
const remote::file_handle &handle, std::string &item_path) const remote::file_handle &handle,
-> packet::error_type override; std::string &item_path) -> packet::error_type override;
auto fuse_release(const char *path, const remote::file_handle &handle) auto fuse_release(const char *path, const remote::file_handle &handle)
-> packet::error_type override; -> packet::error_type override;
@ -152,8 +150,8 @@ public:
auto fuse_rmdir(const char *path) -> packet::error_type override; auto fuse_rmdir(const char *path) -> packet::error_type override;
auto fuse_setattr_x(const char *path, remote::setattr_x &attr) auto fuse_setattr_x(const char *path,
-> packet::error_type override; remote::setattr_x &attr) -> packet::error_type override;
auto fuse_setbkuptime(const char *path, const remote::file_time &bkuptime) auto fuse_setbkuptime(const char *path, const remote::file_time &bkuptime)
-> packet::error_type override; -> packet::error_type override;
@ -186,8 +184,8 @@ public:
auto fuse_unlink(const char *path) -> packet::error_type override; auto fuse_unlink(const char *path) -> packet::error_type override;
auto fuse_utimens(const char *path, const remote::file_time *tv, auto fuse_utimens(const char *path, const remote::file_time *tv,
std::uint64_t op0, std::uint64_t op1) std::uint64_t op0,
-> packet::error_type override; std::uint64_t op1) -> packet::error_type override;
void set_fuse_uid_gid(const remote::user_id & /* uid */, void set_fuse_uid_gid(const remote::user_id & /* uid */,
const remote::group_id & /* gid */) override {} const remote::group_id & /* gid */) override {}
@ -196,18 +194,17 @@ public:
auto json_create_directory_snapshot(const std::string &path, json &json_data) auto json_create_directory_snapshot(const std::string &path, json &json_data)
-> packet::error_type override; -> packet::error_type override;
auto json_read_directory_snapshot(const std::string &path, auto json_read_directory_snapshot(
const remote::file_handle &handle, const std::string &path, const remote::file_handle &handle,
std::uint32_t page, json &json_data) std::uint32_t page, json &json_data) -> packet::error_type override;
-> packet::error_type override;
auto json_release_directory_snapshot(const std::string &path, auto json_release_directory_snapshot(const std::string &path,
const remote::file_handle &handle) const remote::file_handle &handle)
-> packet::error_type override; -> packet::error_type override;
// WinFSP Layer // WinFSP Layer
auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) auto winfsp_can_delete(PVOID file_desc,
-> packet::error_type override; PWSTR file_name) -> packet::error_type override;
auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags, auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
BOOLEAN &was_closed) -> packet::error_type override; BOOLEAN &was_closed) -> packet::error_type override;
@ -223,33 +220,32 @@ public:
auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) auto winfsp_flush(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override; -> packet::error_type override;
auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) auto winfsp_get_dir_buffer(PVOID file_desc,
-> packet::error_type override; PVOID *&ptr) -> packet::error_type override;
auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info) auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override; -> packet::error_type override;
auto winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes, auto winfsp_get_security_by_name(
std::uint64_t *descriptor_size, PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size,
std::wstring &string_descriptor) std::wstring &string_descriptor) -> packet::error_type override;
-> packet::error_type override;
auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size, auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) std::string &volume_label)
-> packet::error_type override; -> packet::error_type override;
auto winfsp_mounted(const std::wstring &location) auto
-> packet::error_type override; winfsp_mounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_open(PWSTR file_name, UINT32 create_options, auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc, UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info, std::string &normalized_name) remote::file_info *file_info,
-> packet::error_type override; std::string &normalized_name) -> packet::error_type override;
auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, auto
BOOLEAN replace_attributes, UINT64 allocation_size, winfsp_overwrite(PVOID file_desc, UINT32 attributes,
remote::file_info *file_info) BOOLEAN replace_attributes, UINT64 allocation_size,
-> packet::error_type override; remote::file_info *file_info) -> packet::error_type override;
auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
PUINT32 bytes_transferred) -> packet::error_type override; PUINT32 bytes_transferred) -> packet::error_type override;
@ -260,24 +256,23 @@ public:
auto winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name, auto winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) -> packet::error_type override; BOOLEAN replace_if_exists) -> packet::error_type override;
auto winfsp_set_basic_info(PVOID file_desc, UINT32 attributes, auto winfsp_set_basic_info(
UINT64 creation_time, UINT64 last_access_time, PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_write_time, UINT64 change_time, UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type override;
-> packet::error_type override;
auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, auto winfsp_set_file_size(
BOOLEAN set_allocation_size, PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type override;
-> packet::error_type override;
auto winfsp_unmounted(const std::wstring &location) auto
-> packet::error_type override; winfsp_unmounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, auto
BOOLEAN write_to_end, BOOLEAN constrained_io, winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
PUINT32 bytes_transferred, remote::file_info *file_info) BOOLEAN write_to_end, BOOLEAN constrained_io,
-> packet::error_type override; PUINT32 bytes_transferred,
remote::file_info *file_info) -> packet::error_type override;
}; };
} // namespace remote_winfsp } // namespace remote_winfsp
} // namespace repertory } // namespace repertory

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_ #ifndef INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
#define INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_ #define INCLUDE_DRIVES_WINFSP_REMOTEWINFSP_REMOTE_WINFSP_DRIVE_HPP_
#ifdef _WIN32 #if defined(_WIN32)
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp" #include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
#include "events/event_system.hpp" #include "events/event_system.hpp"
@ -75,8 +75,8 @@ private:
static void set_file_info(FileInfo &dest, const remote::file_info &src); static void set_file_info(FileInfo &dest, const remote::file_info &src);
public: public:
auto CanDelete(PVOID file_node, PVOID file_desc, PWSTR file_name) auto CanDelete(PVOID file_node, PVOID file_desc,
-> NTSTATUS override; PWSTR file_name) -> NTSTATUS override;
VOID Cleanup(PVOID file_node, PVOID file_desc, PWSTR file_name, VOID Cleanup(PVOID file_node, PVOID file_desc, PWSTR file_name,
ULONG flags) override; ULONG flags) override;
@ -88,11 +88,11 @@ public:
UINT64 allocation_size, PVOID *file_node, PVOID *file_desc, UINT64 allocation_size, PVOID *file_node, PVOID *file_desc,
OpenFileInfo *ofi) -> NTSTATUS override; OpenFileInfo *ofi) -> NTSTATUS override;
auto Flush(PVOID file_node, PVOID file_desc, FileInfo *file_info) auto Flush(PVOID file_node, PVOID file_desc,
-> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *file_info) auto GetFileInfo(PVOID file_node, PVOID file_desc,
-> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
auto GetSecurityByName(PWSTR file_name, PUINT32 attributes, auto GetSecurityByName(PWSTR file_name, PUINT32 attributes,
PSECURITY_DESCRIPTOR descriptor, PSECURITY_DESCRIPTOR descriptor,
@ -107,8 +107,8 @@ public:
auto Mounted(PVOID host) -> NTSTATUS override; auto Mounted(PVOID host) -> NTSTATUS override;
auto Open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, auto Open(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
PVOID *file_node, PVOID *file_desc, OpenFileInfo *ofi) PVOID *file_node, PVOID *file_desc,
-> NTSTATUS override; OpenFileInfo *ofi) -> NTSTATUS override;
auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes, auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 allocation_size, BOOLEAN replace_attributes, UINT64 allocation_size,
@ -122,8 +122,8 @@ public:
PULONG bytes_transferred) -> NTSTATUS override; PULONG bytes_transferred) -> NTSTATUS override;
auto Rename(PVOID file_node, PVOID file_desc, PWSTR file_name, auto Rename(PVOID file_node, PVOID file_desc, PWSTR file_name,
PWSTR new_file_name, BOOLEAN replace_if_exists) PWSTR new_file_name,
-> NTSTATUS override; BOOLEAN replace_if_exists) -> NTSTATUS override;
auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes, auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes,
UINT64 creation_time, UINT64 last_access_time, UINT64 creation_time, UINT64 last_access_time,
@ -131,15 +131,15 @@ public:
FileInfo *file_info) -> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size, auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size, FileInfo *file_info) BOOLEAN set_allocation_size,
-> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
VOID Unmounted(PVOID host) override; VOID Unmounted(PVOID host) override;
auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset,
ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io,
PULONG bytes_transferred, FileInfo *file_info) PULONG bytes_transferred,
-> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
void shutdown() { ::GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); } void shutdown() { ::GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); }

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_ #ifndef INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
#define INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_ #define INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_
#ifdef _WIN32 #if defined(_WIN32)
#include "drives/eviction.hpp" #include "drives/eviction.hpp"
#include "drives/winfsp/i_winfsp_drive.hpp" #include "drives/winfsp/i_winfsp_drive.hpp"
@ -75,8 +75,8 @@ private:
std::unique_ptr<remote_winfsp::remote_server> remote_server_; std::unique_ptr<remote_winfsp::remote_server> remote_server_;
private: private:
static auto parse_mount_location(const std::wstring &mount_location) static auto
-> std::string; parse_mount_location(const std::wstring &mount_location) -> std::string;
void populate_file_info(const std::string &api_path, std::uint64_t file_size, void populate_file_info(const std::string &api_path, std::uint64_t file_size,
const api_meta_map &meta, const api_meta_map &meta,
@ -89,8 +89,8 @@ private:
const FSP_FSCTL_FILE_INFO &src); const FSP_FSCTL_FILE_INFO &src);
public: public:
auto CanDelete(PVOID file_node, PVOID file_desc, PWSTR file_name) auto CanDelete(PVOID file_node, PVOID file_desc,
-> NTSTATUS override; PWSTR file_name) -> NTSTATUS override;
VOID Cleanup(PVOID file_node, PVOID file_desc, PWSTR file_name, VOID Cleanup(PVOID file_node, PVOID file_desc, PWSTR file_name,
ULONG flags) override; ULONG flags) override;
@ -102,8 +102,8 @@ public:
UINT64 allocation_size, PVOID *file_node, PVOID *file_desc, UINT64 allocation_size, PVOID *file_node, PVOID *file_desc,
OpenFileInfo *ofi) -> NTSTATUS override; OpenFileInfo *ofi) -> NTSTATUS override;
auto Flush(PVOID file_node, PVOID file_desc, FileInfo *file_info) auto Flush(PVOID file_node, PVOID file_desc,
-> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const [[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
-> std::uint64_t override; -> std::uint64_t override;
@ -111,25 +111,24 @@ public:
[[nodiscard]] auto get_directory_items(const std::string &api_path) const [[nodiscard]] auto get_directory_items(const std::string &api_path) const
-> directory_item_list override; -> directory_item_list override;
auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *file_info) auto GetFileInfo(PVOID file_node, PVOID file_desc,
-> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
[[nodiscard]] auto get_file_size(const std::string &api_path) const [[nodiscard]] auto
-> std::uint64_t override; get_file_size(const std::string &api_path) const -> std::uint64_t override;
[[nodiscard]] auto get_item_meta(const std::string &api_path, [[nodiscard]] auto
api_meta_map &meta) const get_item_meta(const std::string &api_path,
-> api_error override; api_meta_map &meta) const -> api_error override;
[[nodiscard]] auto get_item_meta(const std::string &api_path, [[nodiscard]] auto
const std::string &name, get_item_meta(const std::string &api_path, const std::string &name,
std::string &value) const std::string &value) const -> api_error override;
-> api_error override;
[[nodiscard]] auto get_security_by_name(PWSTR file_name, PUINT32 attributes, [[nodiscard]] auto
PSECURITY_DESCRIPTOR descriptor, get_security_by_name(PWSTR file_name, PUINT32 attributes,
std::uint64_t *descriptor_size) PSECURITY_DESCRIPTOR descriptor,
-> NTSTATUS override; std::uint64_t *descriptor_size) -> NTSTATUS override;
auto GetSecurityByName(PWSTR file_name, PUINT32 attributes, auto GetSecurityByName(PWSTR file_name, PUINT32 attributes,
PSECURITY_DESCRIPTOR descriptor, PSECURITY_DESCRIPTOR descriptor,
@ -153,16 +152,16 @@ public:
auto Mounted(PVOID host) -> NTSTATUS override; auto Mounted(PVOID host) -> NTSTATUS override;
auto Open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, auto Open(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
PVOID *file_node, PVOID *file_desc, OpenFileInfo *ofi) PVOID *file_node, PVOID *file_desc,
-> NTSTATUS override; OpenFileInfo *ofi) -> NTSTATUS override;
auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes, auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 allocation_size, BOOLEAN replace_attributes, UINT64 allocation_size,
FileInfo *file_info) -> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
[[nodiscard]] auto populate_file_info(const std::string &api_path, [[nodiscard]] auto
remote::file_info &file_info) populate_file_info(const std::string &api_path,
-> api_error override; remote::file_info &file_info) -> api_error override;
auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset,
ULONG length, PULONG bytes_transferred) -> NTSTATUS override; ULONG length, PULONG bytes_transferred) -> NTSTATUS override;
@ -172,8 +171,8 @@ public:
PULONG bytes_transferred) -> NTSTATUS override; PULONG bytes_transferred) -> NTSTATUS override;
auto Rename(PVOID file_node, PVOID file_desc, PWSTR file_name, auto Rename(PVOID file_node, PVOID file_desc, PWSTR file_name,
PWSTR new_file_name, BOOLEAN replace_if_exists) PWSTR new_file_name,
-> NTSTATUS override; BOOLEAN replace_if_exists) -> NTSTATUS override;
auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes, auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes,
UINT64 creation_time, UINT64 last_access_time, UINT64 creation_time, UINT64 last_access_time,
@ -181,15 +180,15 @@ public:
FileInfo *file_info) -> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size, auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size, FileInfo *file_info) BOOLEAN set_allocation_size,
-> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
VOID Unmounted(PVOID host) override; VOID Unmounted(PVOID host) override;
auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset,
ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io,
PULONG bytes_transferred, FileInfo *file_info) PULONG bytes_transferred,
-> NTSTATUS override; FileInfo *file_info) -> NTSTATUS override;
void shutdown(); void shutdown();

View File

@ -36,8 +36,8 @@ public:
private: private:
void process_event(const event &e) { void process_event(const event &e) {
#ifdef _WIN32 #if defined(_WIN32)
#ifdef _DEBUG #if defined(_DEBUG)
OutputDebugString((e.get_single_line() + "\n").c_str()); OutputDebugString((e.get_single_line() + "\n").c_str());
#endif #endif
#endif #endif

View File

@ -289,7 +289,7 @@ E_SIMPLE1(service_started, debug, true,
); );
E_SIMPLE(unmount_requested, normal, true); E_SIMPLE(unmount_requested, normal, true);
#ifndef _WIN32 #if !defined(_WIN32)
E_SIMPLE2(unmount_result, normal, true, E_SIMPLE2(unmount_result, normal, true,
std::string, location, loc, E_STRING, std::string, location, loc, E_STRING,
std::string, result, res, E_STRING std::string, result, res, E_STRING

View File

@ -57,8 +57,8 @@ public:
open_file_base(const open_file_base &) noexcept = delete; open_file_base(const open_file_base &) noexcept = delete;
open_file_base(open_file_base &&) noexcept = delete; open_file_base(open_file_base &&) noexcept = delete;
auto operator=(open_file_base &&) noexcept -> open_file_base & = delete; auto operator=(open_file_base &&) noexcept -> open_file_base & = delete;
auto operator=(const open_file_base &) noexcept auto
-> open_file_base & = delete; operator=(const open_file_base &) noexcept -> open_file_base & = delete;
public: public:
class download final { class download final {
@ -168,14 +168,14 @@ public:
[[nodiscard]] auto get_filesystem_item() const -> filesystem_item override; [[nodiscard]] auto get_filesystem_item() const -> filesystem_item override;
[[nodiscard]] auto get_handles() const [[nodiscard]] auto
-> std::vector<std::uint64_t> override; get_handles() const -> std::vector<std::uint64_t> override;
[[nodiscard]] auto get_open_data() const [[nodiscard]] auto
-> std::map<std::uint64_t, open_file_data> override; get_open_data() const -> std::map<std::uint64_t, open_file_data> override;
[[nodiscard]] auto get_open_data(std::uint64_t handle) const [[nodiscard]] auto
-> open_file_data override; get_open_data(std::uint64_t handle) const -> open_file_data override;
[[nodiscard]] auto get_open_file_count() const -> std::size_t override; [[nodiscard]] auto get_open_file_count() const -> std::size_t override;
@ -261,8 +261,8 @@ public:
public: public:
auto close() -> bool override; auto close() -> bool override;
[[nodiscard]] auto get_read_state() const [[nodiscard]] auto
-> boost::dynamic_bitset<> override; get_read_state() const -> boost::dynamic_bitset<> override;
[[nodiscard]] auto get_read_state(std::size_t chunk) const -> bool override; [[nodiscard]] auto get_read_state(std::size_t chunk) const -> bool override;
@ -270,20 +270,20 @@ public:
auto is_write_supported() const -> bool override { return true; } auto is_write_supported() const -> bool override { return true; }
[[nodiscard]] auto native_operation(native_operation_callback callback) [[nodiscard]] auto
-> api_error override; native_operation(native_operation_callback callback) -> api_error override;
[[nodiscard]] auto native_operation(std::uint64_t new_file_size, [[nodiscard]] auto
native_operation_callback callback) native_operation(std::uint64_t new_file_size,
-> api_error override; native_operation_callback callback) -> api_error override;
void remove(std::uint64_t handle) override; void remove(std::uint64_t handle) override;
[[nodiscard]] auto read(std::size_t read_size, std::uint64_t read_offset, [[nodiscard]] auto read(std::size_t read_size, std::uint64_t read_offset,
data_buffer &data) -> api_error override; data_buffer &data) -> api_error override;
[[nodiscard]] auto resize(std::uint64_t new_file_size) [[nodiscard]] auto
-> api_error override; resize(std::uint64_t new_file_size) -> api_error override;
[[nodiscard]] auto write(std::uint64_t write_offset, [[nodiscard]] auto write(std::uint64_t write_offset,
const data_buffer &data, const data_buffer &data,
@ -350,8 +350,8 @@ public:
return last_chunk_; return last_chunk_;
} }
[[nodiscard]] auto get_read_state() const [[nodiscard]] auto
-> boost::dynamic_bitset<> override; get_read_state() const -> boost::dynamic_bitset<> override;
[[nodiscard]] auto get_read_state(std::size_t chunk) const -> bool override; [[nodiscard]] auto get_read_state(std::size_t chunk) const -> bool override;
@ -363,12 +363,12 @@ public:
auto is_write_supported() const -> bool override { return false; } auto is_write_supported() const -> bool override { return false; }
[[nodiscard]] auto native_operation(native_operation_callback callback) [[nodiscard]] auto
-> api_error override; native_operation(native_operation_callback callback) -> api_error override;
[[nodiscard]] auto native_operation(std::uint64_t, [[nodiscard]] auto
native_operation_callback) native_operation(std::uint64_t,
-> api_error override { native_operation_callback) -> api_error override {
return api_error::not_supported; return api_error::not_supported;
} }
@ -385,8 +385,8 @@ public:
void set_api_path(const std::string &api_path) override; void set_api_path(const std::string &api_path) override;
[[nodiscard]] auto write(std::uint64_t, const data_buffer &, std::size_t &) [[nodiscard]] auto write(std::uint64_t, const data_buffer &,
-> api_error override { std::size_t &) -> api_error override {
return api_error::not_supported; return api_error::not_supported;
} }
}; };
@ -530,10 +530,10 @@ public:
[[nodiscard]] auto has_no_open_file_handles() const -> bool override; [[nodiscard]] auto has_no_open_file_handles() const -> bool override;
[[nodiscard]] auto is_processing(const std::string &api_path) const [[nodiscard]] auto
-> bool override; is_processing(const std::string &api_path) const -> bool override;
#ifdef PROJECT_TESTING #if defined(PROJECT_TESTING)
[[nodiscard]] auto open(std::shared_ptr<i_closeable_open_file> of, [[nodiscard]] auto open(std::shared_ptr<i_closeable_open_file> of,
const open_file_data &ofd, std::uint64_t &handle, const open_file_data &ofd, std::uint64_t &handle,
std::shared_ptr<i_open_file> &file) -> api_error; std::shared_ptr<i_open_file> &file) -> api_error;
@ -544,13 +544,13 @@ public:
[[nodiscard]] auto remove_file(const std::string &api_path) -> api_error; [[nodiscard]] auto remove_file(const std::string &api_path) -> api_error;
[[nodiscard]] auto rename_directory(const std::string &from_api_path, [[nodiscard]] auto
const std::string &to_api_path) rename_directory(const std::string &from_api_path,
-> api_error; const std::string &to_api_path) -> api_error;
[[nodiscard]] auto rename_file(const std::string &from_api_path, [[nodiscard]] auto rename_file(const std::string &from_api_path,
const std::string &to_api_path, bool overwrite) const std::string &to_api_path,
-> api_error; bool overwrite) -> api_error;
void start(); void start();

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_PLATFORM_UNIXPLATFORM_HPP_ #ifndef INCLUDE_PLATFORM_UNIXPLATFORM_HPP_
#define INCLUDE_PLATFORM_UNIXPLATFORM_HPP_ #define INCLUDE_PLATFORM_UNIXPLATFORM_HPP_
#ifndef _WIN32 #if !defined(_WIN32)
#include "types/repertory.hpp" #include "types/repertory.hpp"
@ -51,9 +51,8 @@ private:
[[nodiscard]] auto get_lock_file() -> std::string; [[nodiscard]] auto get_lock_file() -> std::string;
private: private:
[[nodiscard]] static auto wait_for_lock(int fd, [[nodiscard]] static auto
std::uint8_t retry_count = 30u) wait_for_lock(int fd, std::uint8_t retry_count = 30u) -> int;
-> int;
public: public:
[[nodiscard]] auto get_mount_state(json &mount_state) -> bool; [[nodiscard]] auto get_mount_state(json &mount_state) -> bool;
@ -61,8 +60,8 @@ public:
[[nodiscard]] auto grab_lock(std::uint8_t retry_count = 30u) -> lock_result; [[nodiscard]] auto grab_lock(std::uint8_t retry_count = 30u) -> lock_result;
[[nodiscard]] auto set_mount_state(bool active, [[nodiscard]] auto set_mount_state(bool active,
const std::string &mount_location, int pid) const std::string &mount_location,
-> bool; int pid) -> bool;
}; };
[[nodiscard]] auto create_meta_attributes( [[nodiscard]] auto create_meta_attributes(

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_PLATFORM_WINPLATFORM_HPP_ #ifndef INCLUDE_PLATFORM_WINPLATFORM_HPP_
#define INCLUDE_PLATFORM_WINPLATFORM_HPP_ #define INCLUDE_PLATFORM_WINPLATFORM_HPP_
#ifdef _WIN32 #if defined(_WIN32)
#include "app_config.hpp" #include "app_config.hpp"
#include "types/repertory.hpp" #include "types/repertory.hpp"
@ -54,8 +54,8 @@ private:
DWORD mutex_state_ = WAIT_FAILED; DWORD mutex_state_ = WAIT_FAILED;
public: public:
[[nodiscard]] auto get_mount_state(const provider_type &pt, json &mount_state) [[nodiscard]] auto get_mount_state(const provider_type &pt,
-> bool; json &mount_state) -> bool;
[[nodiscard]] auto get_mount_state(json &mount_state) -> bool; [[nodiscard]] auto get_mount_state(json &mount_state) -> bool;

View File

@ -25,7 +25,7 @@
#define PACKET_SERVICE_FUSE 1U #define PACKET_SERVICE_FUSE 1U
#define PACKET_SERVICE_WINFSP 2U #define PACKET_SERVICE_WINFSP 2U
#ifdef _WIN32 #if defined(_WIN32)
#define PACKET_SERVICE_FLAGS PACKET_SERVICE_WINFSP #define PACKET_SERVICE_FLAGS PACKET_SERVICE_WINFSP
#else #else
#define PACKET_SERVICE_FLAGS PACKET_SERVICE_FUSE #define PACKET_SERVICE_FLAGS PACKET_SERVICE_FUSE
@ -65,14 +65,14 @@ enum class open_flags : std::uint32_t {
dsync = 131072U, dsync = 131072U,
}; };
inline auto operator|(const open_flags &flag_1, const open_flags &flag_2) inline auto operator|(const open_flags &flag_1,
-> open_flags { const open_flags &flag_2) -> open_flags {
using t = std::underlying_type_t<open_flags>; using t = std::underlying_type_t<open_flags>;
return static_cast<open_flags>(static_cast<t>(flag_1) | return static_cast<open_flags>(static_cast<t>(flag_1) |
static_cast<t>(flag_2)); static_cast<t>(flag_2));
} }
#ifdef __GNUG__ #if defined(__GNUG__)
__attribute__((unused)) __attribute__((unused))
#endif #endif
inline auto inline auto
@ -81,7 +81,7 @@ operator|=(open_flags &flag_1, const open_flags &flag_2) -> open_flags & {
return flag_1; return flag_1;
} }
#ifdef __GNUG__ #if defined(__GNUG__)
__attribute__((unused)) __attribute__((unused))
#endif #endif
inline auto inline auto
@ -149,11 +149,11 @@ struct statfs_x : public statfs {
}; };
#pragma pack() #pragma pack()
#ifndef _WIN32 #if !defined(_WIN32)
[[nodiscard]] auto create_open_flags(std::uint32_t flags) -> open_flags; [[nodiscard]] auto create_open_flags(std::uint32_t flags) -> open_flags;
[[nodiscard]] auto create_os_open_flags(const open_flags &flags) [[nodiscard]] auto
-> std::uint32_t; create_os_open_flags(const open_flags &flags) -> std::uint32_t;
#endif #endif
} // namespace repertory::remote } // namespace repertory::remote

View File

@ -98,8 +98,8 @@ enum class api_error {
[[nodiscard]] auto api_error_from_string(std::string_view s) -> api_error; [[nodiscard]] auto api_error_from_string(std::string_view s) -> api_error;
[[nodiscard]] auto api_error_to_string(const api_error &error) [[nodiscard]] auto
-> const std::string &; api_error_to_string(const api_error &error) -> const std::string &;
enum class download_type { direct, fallback, ring_buffer }; enum class download_type { direct, fallback, ring_buffer };
@ -145,7 +145,7 @@ enum class provider_type : std::size_t {
unknown, unknown,
}; };
#ifdef _WIN32 #if defined(_WIN32)
struct open_file_data { struct open_file_data {
void *directory_buffer{}; void *directory_buffer{};
}; };
@ -229,7 +229,7 @@ struct host_config {
} }
}; };
#ifdef __GNUG__ #if defined(__GNUG__)
__attribute__((unused)) __attribute__((unused))
#endif #endif
static void static void
@ -244,7 +244,7 @@ to_json(json &j, const host_config &hc) {
{"TimeoutMs", hc.timeout_ms}}; {"TimeoutMs", hc.timeout_ms}};
} }
#ifdef __GNUG__ #if defined(__GNUG__)
__attribute__((unused)) __attribute__((unused))
#endif #endif
static void static void

View File

@ -29,7 +29,7 @@
namespace repertory { namespace repertory {
namespace utils::aws { namespace utils::aws {
#if _WIN32 #if defined(_WIN32)
[[nodiscard]] inline auto format_time(std::uint64_t t) -> std::uint64_t { [[nodiscard]] inline auto format_time(std::uint64_t t) -> std::uint64_t {
FILETIME ft{}; FILETIME ft{};
utils::unix_time_to_filetime(t, ft); utils::unix_time_to_filetime(t, ft);
@ -75,7 +75,7 @@ struct head_object_result {
if (not date.empty()) { if (not date.empty()) {
struct tm tm1 {}; struct tm tm1 {};
// Mon, 17 Dec 2012 02:14:10 GMT // Mon, 17 Dec 2012 02:14:10 GMT
#ifdef _WIN32 #if defined(_WIN32)
utils::strptime(date.c_str(), "%a, %d %b %Y %H:%M:%S %Z", &tm1); utils::strptime(date.c_str(), "%a, %d %b %Y %H:%M:%S %Z", &tm1);
#else #else
strptime(date.c_str(), "%a, %d %b %Y %H:%M:%S %Z", &tm1); strptime(date.c_str(), "%a, %d %b %Y %H:%M:%S %Z", &tm1);

View File

@ -21,7 +21,7 @@
*/ */
#ifndef INCLUDE_UTILS_COM_INIT_WRAPPER_HPP_ #ifndef INCLUDE_UTILS_COM_INIT_WRAPPER_HPP_
#define INCLUDE_UTILS_COM_INIT_WRAPPER_HPP_ #define INCLUDE_UTILS_COM_INIT_WRAPPER_HPP_
#ifdef _WIN32 #if defined(_WIN32)
namespace repertory { namespace repertory {
class com_init_wrapper { class com_init_wrapper {

View File

@ -39,12 +39,12 @@ public:
return std::shared_ptr<native_file>(new native_file(handle)); return std::shared_ptr<native_file>(new native_file(handle));
} }
[[nodiscard]] static auto clone(const native_file_ptr &ptr) [[nodiscard]] static auto
-> native_file_ptr; clone(const native_file_ptr &ptr) -> native_file_ptr;
[[nodiscard]] static auto create_or_open(const std::string &source_path, [[nodiscard]] static auto create_or_open(const std::string &source_path,
bool read_only, native_file_ptr &ptr) bool read_only,
-> api_error; native_file_ptr &ptr) -> api_error;
[[nodiscard]] static auto create_or_open(const std::string &source_path, [[nodiscard]] static auto create_or_open(const std::string &source_path,
native_file_ptr &ptr) -> api_error; native_file_ptr &ptr) -> api_error;
@ -66,7 +66,7 @@ private:
private: private:
bool auto_close{false}; bool auto_close{false};
#ifdef _WIN32 #if defined(_WIN32)
std::recursive_mutex read_write_mutex_; std::recursive_mutex read_write_mutex_;
#endif #endif
@ -85,7 +85,7 @@ public:
[[nodiscard]] auto get_handle() -> native_handle; [[nodiscard]] auto get_handle() -> native_handle;
#ifdef _WIN32 #if defined(_WIN32)
[[nodiscard]] auto read_bytes(char *buffer, std::size_t read_size, [[nodiscard]] auto read_bytes(char *buffer, std::size_t read_size,
std::uint64_t read_offset, std::uint64_t read_offset,
std::size_t &bytes_read) -> bool; std::size_t &bytes_read) -> bool;
@ -98,7 +98,7 @@ public:
[[nodiscard]] auto truncate(std::uint64_t file_size) -> bool; [[nodiscard]] auto truncate(std::uint64_t file_size) -> bool;
#ifdef _WIN32 #if defined(_WIN32)
[[nodiscard]] auto write_bytes(const char *buffer, std::size_t write_size, [[nodiscard]] auto write_bytes(const char *buffer, std::size_t write_size,
std::uint64_t write_offset, std::uint64_t write_offset,
std::size_t &bytes_written) -> bool; std::size_t &bytes_written) -> bool;

View File

@ -23,7 +23,7 @@
#define INCLUDE_UTILS_PATH_UTILS_HPP_ #define INCLUDE_UTILS_PATH_UTILS_HPP_
namespace repertory::utils::path { namespace repertory::utils::path {
#ifdef _WIN32 #if defined(_WIN32)
static const std::string directory_seperator = "\\"; static const std::string directory_seperator = "\\";
static const std::string not_directory_seperator = "/"; static const std::string not_directory_seperator = "/";
#else #else
@ -34,9 +34,8 @@ static const std::string not_directory_seperator = "\\";
// Prototypes // Prototypes
[[nodiscard]] auto absolute(std::string path) -> std::string; [[nodiscard]] auto absolute(std::string path) -> std::string;
[[nodiscard]] auto combine(std::string path, [[nodiscard]] auto
const std::vector<std::string> &paths) combine(std::string path, const std::vector<std::string> &paths) -> std::string;
-> std::string;
[[nodiscard]] auto create_api_path(std::string path) -> std::string; [[nodiscard]] auto create_api_path(std::string path) -> std::string;
@ -47,7 +46,7 @@ auto format_path(std::string &path, const std::string &sep,
[[nodiscard]] auto get_parent_api_path(const std::string &path) -> std::string; [[nodiscard]] auto get_parent_api_path(const std::string &path) -> std::string;
#ifndef _WIN32 #if !defined(_WIN32)
[[nodiscard]] auto get_parent_directory(std::string path) -> std::string; [[nodiscard]] auto get_parent_directory(std::string path) -> std::string;
#endif #endif
@ -57,7 +56,7 @@ auto format_path(std::string &path, const std::string &sep,
[[nodiscard]] auto remove_file_name(std::string path) -> std::string; [[nodiscard]] auto remove_file_name(std::string path) -> std::string;
#ifndef _WIN32 #if !defined(_WIN32)
[[nodiscard]] auto resolve(std::string path) -> std::string; [[nodiscard]] auto resolve(std::string path) -> std::string;
#endif #endif

View File

@ -21,13 +21,13 @@
*/ */
#ifndef INCLUDE_UTILS_UNIX_UNIX_UTILS_HPP_ #ifndef INCLUDE_UTILS_UNIX_UNIX_UTILS_HPP_
#define INCLUDE_UTILS_UNIX_UNIX_UTILS_HPP_ #define INCLUDE_UTILS_UNIX_UNIX_UTILS_HPP_
#ifndef _WIN32 #if !defined(_WIN32)
#include "types/remote.hpp" #include "types/remote.hpp"
#include "types/repertory.hpp" #include "types/repertory.hpp"
namespace repertory::utils { namespace repertory::utils {
#if __linux__ #if defined(__linux__)
inline const std::array<std::string, 4U> attribute_namespaces = { inline const std::array<std::string, 4U> attribute_namespaces = {
"security", "security",
"system", "system",
@ -36,7 +36,7 @@ inline const std::array<std::string, 4U> attribute_namespaces = {
}; };
#endif #endif
#if __APPLE__ #if defined(__APPLE__)
template <typename t> template <typename t>
[[nodiscard]] auto convert_to_uint64(const t *ptr) -> std::uint64_t; [[nodiscard]] auto convert_to_uint64(const t *ptr) -> std::uint64_t;
#else #else
@ -49,8 +49,8 @@ template <typename t>
[[nodiscard]] auto get_thread_id() -> std::uint64_t; [[nodiscard]] auto get_thread_id() -> std::uint64_t;
[[nodiscard]] auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) [[nodiscard]] auto is_uid_member_of_group(const uid_t &uid,
-> bool; const gid_t &gid) -> bool;
void set_last_error_code(int error_code); void set_last_error_code(int error_code);
@ -58,8 +58,8 @@ void set_last_error_code(int error_code);
[[nodiscard]] auto unix_error_to_windows(int err) -> std::int32_t; [[nodiscard]] auto unix_error_to_windows(int err) -> std::int32_t;
[[nodiscard]] auto unix_time_to_windows_time(const remote::file_time &file_time) [[nodiscard]] auto
-> UINT64; unix_time_to_windows_time(const remote::file_time &file_time) -> UINT64;
void use_getpwuid(uid_t uid, std::function<void(struct passwd *pass)> callback); void use_getpwuid(uid_t uid, std::function<void(struct passwd *pass)> callback);
@ -67,11 +67,11 @@ void windows_create_to_unix(const UINT32 &create_options,
const UINT32 &granted_access, std::uint32_t &flags, const UINT32 &granted_access, std::uint32_t &flags,
remote::file_mode &mode); remote::file_mode &mode);
[[nodiscard]] auto windows_time_to_unix_time(std::uint64_t win_time) [[nodiscard]] auto
-> remote::file_time; windows_time_to_unix_time(std::uint64_t win_time) -> remote::file_time;
// template implementations // template implementations
#if __APPLE__ #if defined(__APPLE__)
template <typename t> template <typename t>
[[nodiscard]] auto convert_to_uint64(const t *v) -> std::uint64_t { [[nodiscard]] auto convert_to_uint64(const t *v) -> std::uint64_t {
return static_cast<std::uint64_t>(reinterpret_cast<std::uintptr_t>(v)); return static_cast<std::uint64_t>(reinterpret_cast<std::uintptr_t>(v));

View File

@ -21,30 +21,30 @@
*/ */
#ifndef INCLUDE_UTILS_WINDOWS_WINDOWS_UTILS_HPP_ #ifndef INCLUDE_UTILS_WINDOWS_WINDOWS_UTILS_HPP_
#define INCLUDE_UTILS_WINDOWS_WINDOWS_UTILS_HPP_ #define INCLUDE_UTILS_WINDOWS_WINDOWS_UTILS_HPP_
#ifdef _WIN32 #if defined(_WIN32)
#include "types/remote.hpp" #include "types/remote.hpp"
#include "types/repertory.hpp" #include "types/repertory.hpp"
namespace repertory::utils { namespace repertory::utils {
[[nodiscard]] auto filetime_to_unix_time(const FILETIME &ft) [[nodiscard]] auto
-> remote::file_time; filetime_to_unix_time(const FILETIME &ft) -> remote::file_time;
[[nodiscard]] auto get_last_error_code() -> DWORD; [[nodiscard]] auto get_last_error_code() -> DWORD;
[[nodiscard]] auto get_local_app_data_directory() -> const std::string &; [[nodiscard]] auto get_local_app_data_directory() -> const std::string &;
[[nodiscard]] auto get_accessed_time_from_meta(const api_meta_map &meta) [[nodiscard]] auto
-> std::uint64_t; get_accessed_time_from_meta(const api_meta_map &meta) -> std::uint64_t;
[[nodiscard]] auto get_changed_time_from_meta(const api_meta_map &meta) [[nodiscard]] auto
-> std::uint64_t; get_changed_time_from_meta(const api_meta_map &meta) -> std::uint64_t;
[[nodiscard]] auto get_creation_time_from_meta(const api_meta_map &meta) [[nodiscard]] auto
-> std::uint64_t; get_creation_time_from_meta(const api_meta_map &meta) -> std::uint64_t;
[[nodiscard]] auto get_written_time_from_meta(const api_meta_map &meta) [[nodiscard]] auto
-> std::uint64_t; get_written_time_from_meta(const api_meta_map &meta) -> std::uint64_t;
[[nodiscard]] auto get_thread_id() -> std::uint64_t; [[nodiscard]] auto get_thread_id() -> std::uint64_t;
@ -67,8 +67,8 @@ unix_open_flags_to_flags_and_perms(const remote::file_mode &mode,
void unix_time_to_filetime(const remote::file_time &ts, FILETIME &ft); void unix_time_to_filetime(const remote::file_time &ts, FILETIME &ft);
[[nodiscard]] auto time64_to_unix_time(const __time64_t &t) [[nodiscard]] auto
-> remote::file_time; time64_to_unix_time(const __time64_t &t) -> remote::file_time;
} // namespace repertory::utils } // namespace repertory::utils
#endif // _WIN32 #endif // _WIN32

View File

@ -68,7 +68,7 @@ app_config::app_config(const provider_type &prov,
enable_comm_duration_events_(false), enable_comm_duration_events_(false),
enable_drive_events_(false), enable_drive_events_(false),
enable_max_cache_size_(false), enable_max_cache_size_(false),
#ifdef _WIN32 #if defined(_WIN32)
enable_mount_manager_(false), enable_mount_manager_(false),
#endif #endif
enable_remote_mount_(false), enable_remote_mount_(false),
@ -150,12 +150,12 @@ auto app_config::default_api_port(const provider_type &prov) -> std::uint16_t {
auto app_config::default_data_directory(const provider_type &prov) auto app_config::default_data_directory(const provider_type &prov)
-> std::string { -> std::string {
#ifdef _WIN32 #if defined(_WIN32)
auto data_directory = utils::path::combine( auto data_directory = utils::path::combine(
utils::get_local_app_data_directory(), utils::get_local_app_data_directory(),
{REPERTORY_DATA_NAME, app_config::get_provider_name(prov)}); {REPERTORY_DATA_NAME, app_config::get_provider_name(prov)});
#else #else
#ifdef __APPLE__ #if defined(__APPLE__)
auto data_directory = utils::path::resolve( auto data_directory = utils::path::resolve(
std::string("~/Library/Application Support/") + REPERTORY_DATA_NAME + std::string("~/Library/Application Support/") + REPERTORY_DATA_NAME +
'/' + app_config::get_provider_name(prov)); '/' + app_config::get_provider_name(prov));
@ -201,7 +201,7 @@ auto app_config::get_json() const -> json {
{"EnableChunkDownloaderTimeout", enable_chunk_downloader_timeout_}, {"EnableChunkDownloaderTimeout", enable_chunk_downloader_timeout_},
{"EnableCommDurationEvents", enable_comm_duration_events_}, {"EnableCommDurationEvents", enable_comm_duration_events_},
{"EnableDriveEvents", enable_drive_events_}, {"EnableDriveEvents", enable_drive_events_},
#ifdef _WIN32 #if defined(_WIN32)
{"EnableMountManager", enable_mount_manager_}, {"EnableMountManager", enable_mount_manager_},
#endif #endif
{"EnableMaxCacheSize", enable_max_cache_size_}, {"EnableMaxCacheSize", enable_max_cache_size_},
@ -316,12 +316,12 @@ auto app_config::get_max_cache_size_bytes() const -> std::uint64_t {
auto app_config::get_provider_api_password(const provider_type &prov) auto app_config::get_provider_api_password(const provider_type &prov)
-> std::string { -> std::string {
#ifdef _WIN32 #if defined(_WIN32)
auto api_file = auto api_file =
utils::path::combine(utils::get_local_app_data_directory(), utils::path::combine(utils::get_local_app_data_directory(),
{get_provider_display_name(prov), "apipassword"}); {get_provider_display_name(prov), "apipassword"});
#else #else
#ifdef __APPLE__ #if defined(__APPLE__)
auto api_file = auto api_file =
utils::path::combine(utils::path::resolve("~"), utils::path::combine(utils::path::resolve("~"),
{"/Library/Application Support", {"/Library/Application Support",
@ -387,7 +387,7 @@ auto app_config::get_value_by_name(const std::string &name) -> std::string {
} }
if (name == "EnableMaxCacheSize") { if (name == "EnableMaxCacheSize") {
return utils::string::from_bool(get_enable_max_cache_size()); return utils::string::from_bool(get_enable_max_cache_size());
#ifdef _WIN32 #if defined(_WIN32)
} }
if (name == "EnableMountManager") { if (name == "EnableMountManager") {
return std::to_string(get_enable_mount_manager()); return std::to_string(get_enable_mount_manager());
@ -617,7 +617,7 @@ auto app_config::load() -> bool {
ret); ret);
get_value(json_document, "EnableMaxCacheSize", enable_max_cache_size_, get_value(json_document, "EnableMaxCacheSize", enable_max_cache_size_,
ret); ret);
#ifdef _WIN32 #if defined(_WIN32)
get_value(json_document, "EnableMountManager", enable_mount_manager_, get_value(json_document, "EnableMountManager", enable_mount_manager_,
ret); ret);
#endif #endif
@ -765,7 +765,7 @@ auto app_config::set_value_by_name(const std::string &name,
if (name == "EnableMaxCacheSize") { if (name == "EnableMaxCacheSize") {
set_enable_max_cache_size(utils::string::to_bool(value)); set_enable_max_cache_size(utils::string::to_bool(value));
return utils::string::from_bool(get_enable_max_cache_size()); return utils::string::from_bool(get_enable_max_cache_size());
#ifdef _WIN32 #if defined(_WIN32)
} }
if (name == "EnableMountManager") { if (name == "EnableMountManager") {
set_enable_mount_manager(utils::string::to_bool(value)); set_enable_mount_manager(utils::string::to_bool(value));

View File

@ -25,12 +25,10 @@
#include "utils/path_utils.hpp" #include "utils/path_utils.hpp"
namespace repertory { namespace repertory {
#ifndef _WIN32 #if !defined(_WIN32)
auto directory_iterator::fill_buffer(const remote::file_offset &offset, auto directory_iterator::fill_buffer(
fuse_fill_dir_t filler_function, const remote::file_offset &offset, fuse_fill_dir_t filler_function,
void *buffer, void *buffer, populate_stat_callback populate_stat) -> int {
populate_stat_callback populate_stat)
-> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
if (offset < items_.size()) { if (offset < items_.size()) {

View File

@ -49,7 +49,7 @@ auto eviction::check_minimum_requirements(const std::string &file_path)
? utils::file::get_accessed_time(file_path, reference_time) ? utils::file::get_accessed_time(file_path, reference_time)
: utils::file::get_modified_time(file_path, reference_time); : utils::file::get_modified_time(file_path, reference_time);
if (ret) { if (ret) {
#ifdef _WIN32 #if defined(_WIN32)
const auto now = std::chrono::system_clock::now(); const auto now = std::chrono::system_clock::now();
const auto delay = const auto delay =
std::chrono::minutes(config_.get_eviction_delay_mins()); std::chrono::minutes(config_.get_eviction_delay_mins());

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef _WIN32 #if !defined(_WIN32)
#include "drives/fuse/fuse_base.hpp" #include "drives/fuse/fuse_base.hpp"
@ -51,12 +51,12 @@ fuse_base::fuse_base(app_config &config) : config_(config) {
fuse_ops_.open = fuse_base::open_; fuse_ops_.open = fuse_base::open_;
fuse_ops_.read = fuse_base::read_; fuse_ops_.read = fuse_base::read_;
fuse_ops_.write = fuse_base::write_; fuse_ops_.write = fuse_base::write_;
#ifndef __APPLE__ #if !defined(__APPLE__)
fuse_ops_.statfs = fuse_base::statfs_; fuse_ops_.statfs = fuse_base::statfs_;
#endif // __APPLE__ #endif // __APPLE__
fuse_ops_.release = fuse_base::release_; fuse_ops_.release = fuse_base::release_;
fuse_ops_.fsync = fuse_base::fsync_; fuse_ops_.fsync = fuse_base::fsync_;
#if HAS_SETXATTR #if defined(HAS_SETXATTR)
fuse_ops_.setxattr = fuse_base::setxattr_; fuse_ops_.setxattr = fuse_base::setxattr_;
fuse_ops_.getxattr = fuse_base::getxattr_; fuse_ops_.getxattr = fuse_base::getxattr_;
fuse_ops_.listxattr = fuse_base::listxattr_; fuse_ops_.listxattr = fuse_base::listxattr_;
@ -81,7 +81,7 @@ fuse_base::fuse_base(app_config &config) : config_(config) {
fuse_ops_.flag_reserved = 0; fuse_ops_.flag_reserved = 0;
#endif #endif
fuse_ops_.fallocate = fuse_base::fallocate_; fuse_ops_.fallocate = fuse_base::fallocate_;
#ifdef __APPLE__ #if defined(__APPLE__)
fuse_ops_.chflags = fuse_base::chflags_; fuse_ops_.chflags = fuse_base::chflags_;
fuse_ops_.fsetattr_x = fuse_base::fsetattr_x_; fuse_ops_.fsetattr_x = fuse_base::fsetattr_x_;
fuse_ops_.getxtimes = fuse_base::getxtimes_; fuse_ops_.getxtimes = fuse_base::getxtimes_;
@ -109,7 +109,7 @@ auto fuse_base::access_(const char *path, int mask) -> int {
}); });
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_base::chflags_(const char *path, uint32_t flags) -> int { auto fuse_base::chflags_(const char *path, uint32_t flags) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
@ -121,8 +121,8 @@ auto fuse_base::chflags_(const char *path, uint32_t flags) -> int {
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto fuse_base::chmod_(const char *path, mode_t mode, struct fuse_file_info *fi) auto fuse_base::chmod_(const char *path, mode_t mode,
-> int { struct fuse_file_info *fi) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
return instance().execute_callback( return instance().execute_callback(
@ -264,7 +264,7 @@ auto fuse_base::fgetattr_(const char *path, struct stat *st,
} }
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_base::fsetattr_x_(const char *path, struct setattr_x *attr, auto fuse_base::fsetattr_x_(const char *path, struct setattr_x *attr,
struct fuse_file_info *fi) -> int { struct fuse_file_info *fi) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
@ -319,7 +319,7 @@ auto fuse_base::getattr_(const char *path, struct stat *st) -> int {
} }
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime, auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime,
struct timespec *crtime) -> int { struct timespec *crtime) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
@ -332,8 +332,8 @@ auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime,
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto fuse_base::init_(struct fuse_conn_info *conn, struct fuse_config *cfg) auto fuse_base::init_(struct fuse_conn_info *conn,
-> void * { struct fuse_config *cfg) -> void * {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
return execute_void_pointer_callback(function_name, [&]() -> void * { return execute_void_pointer_callback(function_name, [&]() -> void * {
@ -358,7 +358,7 @@ auto fuse_base::init_impl(struct fuse_conn_info *conn) -> void * {
utils::file::change_to_process_directory(); utils::file::change_to_process_directory();
repertory::project_initialize(); repertory::project_initialize();
#ifdef __APPLE__ #if defined(__APPLE__)
conn->want |= FUSE_CAP_VOL_RENAME; conn->want |= FUSE_CAP_VOL_RENAME;
conn->want |= FUSE_CAP_XTIMES; conn->want |= FUSE_CAP_XTIMES;
#endif // __APPLE__ #endif // __APPLE__
@ -459,8 +459,8 @@ auto fuse_base::read_(const char *path, char *buffer, size_t read_size,
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
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, fuse_fill_dir_t fuse_fill_dir, off_t offset,
struct fuse_file_info *fi, fuse_readdir_flags flags) struct fuse_file_info *fi,
-> int { fuse_readdir_flags flags) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
return instance().execute_callback( return instance().execute_callback(
@ -492,8 +492,8 @@ 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) auto fuse_base::releasedir_(const char *path,
-> int { struct fuse_file_info *fi) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
return instance().execute_callback( return instance().execute_callback(
@ -503,8 +503,8 @@ auto fuse_base::releasedir_(const char *path, struct fuse_file_info *fi)
} }
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto fuse_base::rename_(const char *from, const char *to, unsigned int flags) auto fuse_base::rename_(const char *from, const char *to,
-> int { unsigned int flags) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
return instance().execute_callback( return instance().execute_callback(
@ -536,8 +536,8 @@ auto fuse_base::rmdir_(const char *path) -> int {
}); });
} }
#ifdef HAS_SETXATTR #if defined(HAS_SETXATTR)
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_base::getxattr_(const char *path, const char *name, char *value, auto fuse_base::getxattr_(const char *path, const char *name, char *value,
size_t size, uint32_t position) -> int { size_t size, uint32_t position) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
@ -695,7 +695,7 @@ auto fuse_base::removexattr_(const char *path, const char *name) -> int {
}); });
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_base::setxattr_(const char *path, const char *name, const char *value, auto fuse_base::setxattr_(const char *path, const char *name, const char *value,
size_t size, int flags, uint32_t position) -> int { size_t size, int flags, uint32_t position) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
@ -735,7 +735,7 @@ void fuse_base::shutdown() {
std::to_string(res)); std::to_string(res));
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_base::setattr_x_(const char *path, struct setattr_x *attr) -> int { auto fuse_base::setattr_x_(const char *path, struct setattr_x *attr) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
@ -745,8 +745,8 @@ auto fuse_base::setattr_x_(const char *path, struct setattr_x *attr) -> int {
}); });
} }
auto fuse_base::setbkuptime_(const char *path, const struct timespec *bkuptime) auto fuse_base::setbkuptime_(const char *path,
-> int { const struct timespec *bkuptime) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
return instance().execute_callback( return instance().execute_callback(
@ -755,8 +755,8 @@ auto fuse_base::setbkuptime_(const char *path, const struct timespec *bkuptime)
}); });
} }
auto fuse_base::setchgtime_(const char *path, const struct timespec *chgtime) auto fuse_base::setchgtime_(const char *path,
-> int { const struct timespec *chgtime) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
return instance().execute_callback( return instance().execute_callback(
@ -765,8 +765,8 @@ auto fuse_base::setchgtime_(const char *path, const struct timespec *chgtime)
}); });
} }
auto fuse_base::setcrtime_(const char *path, const struct timespec *crtime) auto fuse_base::setcrtime_(const char *path,
-> int { const struct timespec *crtime) -> int {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
return instance().execute_callback( return instance().execute_callback(
@ -834,7 +834,7 @@ auto fuse_base::unlink_(const char *path) -> int {
} }
auto fuse_base::unmount(const std::string &mount_location) -> int { auto fuse_base::unmount(const std::string &mount_location) -> int {
#if __APPLE__ #if defined(__APPLE__)
const auto cmd = "umount \"" + mount_location + "\" >/dev/null 2>&1"; const auto cmd = "umount \"" + mount_location + "\" >/dev/null 2>&1";
#else #else
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef _WIN32 #if !defined(_WIN32)
#include "drives/fuse/fuse_drive.hpp" #include "drives/fuse/fuse_drive.hpp"
@ -49,7 +49,7 @@ fuse_drive::fuse_drive(app_config &config, lock_data &lock_data,
i_provider &provider) i_provider &provider)
: fuse_drive_base(config), lock_data_(lock_data), provider_(provider) {} : fuse_drive_base(config), lock_data_(lock_data), provider_(provider) {}
#ifdef __APPLE__ #if defined(__APPLE__)
api_error fuse_drive::chflags_impl(std::string api_path, uint32_t flags) { api_error fuse_drive::chflags_impl(std::string api_path, uint32_t flags) {
return check_and_perform(api_path, X_OK, [&](api_meta_map &) -> api_error { return check_and_perform(api_path, X_OK, [&](api_meta_map &) -> api_error {
return provider_.set_item_meta(api_path, META_OSXFLAGS, return provider_.set_item_meta(api_path, META_OSXFLAGS,
@ -75,8 +75,8 @@ auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid,
struct fuse_file_info * /*file_info*/) struct fuse_file_info * /*file_info*/)
-> api_error { -> api_error {
#else #else
auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid) auto fuse_drive::chown_impl(std::string api_path, uid_t uid,
-> api_error { gid_t gid) -> api_error {
#endif #endif
return check_and_perform(api_path, X_OK, return check_and_perform(api_path, X_OK,
[&](api_meta_map &meta) -> api_error { [&](api_meta_map &meta) -> api_error {
@ -163,7 +163,7 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode,
std::shared_ptr<i_open_file> open_file; std::shared_ptr<i_open_file> open_file;
if (is_create_op) { if (is_create_op) {
const auto now = utils::get_file_time_now(); const auto now = utils::get_file_time_now();
#ifdef __APPLE__ #if defined(__APPLE__)
const auto osx_flags = static_cast<std::uint32_t>(file_info->flags); const auto osx_flags = static_cast<std::uint32_t>(file_info->flags);
#else #else
const auto osx_flags = 0U; const auto osx_flags = 0U;
@ -270,7 +270,7 @@ auto fuse_drive::fallocate_impl(std::string /*api_path*/, int mode,
i_open_file::native_operation_callback allocator; i_open_file::native_operation_callback allocator;
#ifdef __APPLE__ #if defined(__APPLE__)
fstore_t fstore = {0}; fstore_t fstore = {0};
if (not(mode & PREALLOCATE)) { if (not(mode & PREALLOCATE)) {
if (mode & ALLOCATECONTIG) { if (mode & ALLOCATECONTIG) {
@ -332,7 +332,7 @@ auto fuse_drive::fgetattr_impl(std::string api_path, struct stat *st,
return api_error::success; return api_error::success;
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_drive::fsetattr_x_impl(std::string api_path, struct setattr_x *attr, auto fuse_drive::fsetattr_x_impl(std::string api_path, struct setattr_x *attr,
struct fuse_file_info *file_info) struct fuse_file_info *file_info)
-> api_error { -> api_error {
@ -354,7 +354,7 @@ auto fuse_drive::fsync_impl(std::string /*api_path*/, int datasync,
return open_file->native_operation([&datasync](int handle) -> api_error { return open_file->native_operation([&datasync](int handle) -> api_error {
if (handle != REPERTORY_INVALID_HANDLE) { if (handle != REPERTORY_INVALID_HANDLE) {
#ifdef __APPLE__ #if defined(__APPLE__)
if ((datasync == 0 ? fsync(handle) : fcntl(handle, F_FULLFSYNC)) == -1) { if ((datasync == 0 ? fsync(handle) : fcntl(handle, F_FULLFSYNC)) == -1) {
#else // __APPLE__ #else // __APPLE__
if ((datasync == 0 ? fsync(handle) : fdatasync(handle)) == -1) { if ((datasync == 0 ? fsync(handle) : fdatasync(handle)) == -1) {
@ -439,8 +439,8 @@ auto fuse_drive::getattr_impl(std::string api_path, struct stat *st,
struct fuse_file_info * /*file_info*/) struct fuse_file_info * /*file_info*/)
-> api_error { -> api_error {
#else #else
auto fuse_drive::getattr_impl(std::string api_path, struct stat *st) auto fuse_drive::getattr_impl(std::string api_path,
-> api_error { struct stat *st) -> api_error {
#endif #endif
const auto parent = utils::path::get_parent_api_path(api_path); const auto parent = utils::path::get_parent_api_path(api_path);
@ -497,7 +497,7 @@ void fuse_drive::get_volume_info(UINT64 &total_size, UINT64 &free_size,
volume_label = utils::create_volume_label(config_.get_provider_type()); volume_label = utils::create_volume_label(config_.get_provider_type());
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime, auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime,
struct timespec *crtime) -> api_error { struct timespec *crtime) -> api_error {
if (not(bkuptime && crtime)) { if (not(bkuptime && crtime)) {
@ -522,8 +522,8 @@ auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime,
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto fuse_drive::init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) auto fuse_drive::init_impl(struct fuse_conn_info *conn,
-> void * { struct fuse_config *cfg) -> void * {
#else #else
void *fuse_drive::init_impl(struct fuse_conn_info *conn) { void *fuse_drive::init_impl(struct fuse_conn_info *conn) {
#endif #endif
@ -747,9 +747,8 @@ auto fuse_drive::release_impl(std::string /*api_path*/,
return api_error::success; return api_error::success;
} }
auto fuse_drive::releasedir_impl(std::string /*api_path*/, auto fuse_drive::releasedir_impl(
struct fuse_file_info *file_info) std::string /*api_path*/, struct fuse_file_info *file_info) -> api_error {
-> api_error {
auto *iter = reinterpret_cast<directory_iterator *>(file_info->fh); auto *iter = reinterpret_cast<directory_iterator *>(file_info->fh);
if (iter == nullptr) { if (iter == nullptr) {
return api_error::invalid_handle; return api_error::invalid_handle;
@ -769,8 +768,8 @@ auto fuse_drive::rename_directory(const std::string &from_api_path,
} }
auto fuse_drive::rename_file(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) const std::string &to_api_path,
-> int { bool overwrite) -> int {
const auto res = fm_->rename_file(from_api_path, to_api_path, overwrite); const auto res = fm_->rename_file(from_api_path, to_api_path, overwrite);
errno = std::abs(utils::from_api_error(res)); errno = std::abs(utils::from_api_error(res));
return (res == api_error::success) ? 0 : -1; return (res == api_error::success) ? 0 : -1;
@ -780,8 +779,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, auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path,
unsigned int /*flags*/) -> api_error { unsigned int /*flags*/) -> api_error {
#else #else
auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path) auto fuse_drive::rename_impl(std::string from_api_path,
-> api_error { std::string to_api_path) -> api_error {
#endif #endif
auto res = check_parent_access(to_api_path, W_OK | X_OK); auto res = check_parent_access(to_api_path, W_OK | X_OK);
if (res != api_error::success) { if (res != api_error::success) {
@ -826,12 +825,12 @@ auto fuse_drive::rmdir_impl(std::string api_path) -> api_error {
return api_error::success; return api_error::success;
} }
#ifdef HAS_SETXATTR #if defined(HAS_SETXATTR)
auto fuse_drive::getxattr_common(std::string api_path, const char *name, auto fuse_drive::getxattr_common(std::string api_path, const char *name,
char *value, size_t size, int &attribute_size, char *value, size_t size, int &attribute_size,
uint32_t *position) -> api_error { uint32_t *position) -> api_error {
std::string attribute_name; std::string attribute_name;
#ifdef __APPLE__ #if defined(__APPLE__)
auto res = parse_xattr_parameters(name, value, size, *position, auto res = parse_xattr_parameters(name, value, size, *position,
attribute_name, api_path); attribute_name, api_path);
#else // __APPLE__ #else // __APPLE__
@ -881,7 +880,7 @@ auto fuse_drive::getxattr_common(std::string api_path, const char *name,
return res; return res;
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_drive::getxattr_impl(std::string api_path, const char *name, auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
char *value, size_t size, uint32_t position, char *value, size_t size, uint32_t position,
int &attribute_size) -> api_error { int &attribute_size) -> api_error {
@ -890,15 +889,15 @@ auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
} }
#else // __APPLE__ #else // __APPLE__
auto fuse_drive::getxattr_impl(std::string api_path, const char *name, auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
char *value, size_t size, int &attribute_size) char *value, size_t size,
-> api_error { int &attribute_size) -> api_error {
return getxattr_common(api_path, name, value, size, attribute_size, nullptr); return getxattr_common(api_path, name, value, size, attribute_size, nullptr);
} }
#endif // __APPLE__ #endif // __APPLE__
auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size, auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
int &required_size, bool &return_size) int &required_size,
-> api_error { bool &return_size) -> api_error {
const auto check_size = (size == 0); const auto check_size = (size == 0);
auto res = check_parent_access(api_path, X_OK); auto res = check_parent_access(api_path, X_OK);
@ -911,7 +910,7 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
for (const auto &meta_item : meta) { for (const auto &meta_item : meta) {
if (utils::collection_excludes(META_USED_NAMES, meta_item.first)) { if (utils::collection_excludes(META_USED_NAMES, meta_item.first)) {
auto attribute_name = meta_item.first; auto attribute_name = meta_item.first;
#ifdef __APPLE__ #if defined(__APPLE__)
if (attribute_name != G_KAUTH_FILESEC_XATTR) { if (attribute_name != G_KAUTH_FILESEC_XATTR) {
#endif #endif
const auto attribute_name_size = strlen(attribute_name.c_str()) + 1U; const auto attribute_name_size = strlen(attribute_name.c_str()) + 1U;
@ -924,7 +923,7 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
} }
required_size += static_cast<int>(attribute_name_size); required_size += static_cast<int>(attribute_name_size);
#ifdef __APPLE__ #if defined(__APPLE__)
} }
#endif #endif
} }
@ -937,10 +936,10 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
return res; return res;
} }
auto fuse_drive::removexattr_impl(std::string api_path, const char *name) auto fuse_drive::removexattr_impl(std::string api_path,
-> api_error { const char *name) -> api_error {
std::string attribute_name; std::string attribute_name;
#ifdef __APPLE__ #if defined(__APPLE__)
auto res = parse_xattr_parameters(name, 0, attribute_name, api_path); auto res = parse_xattr_parameters(name, 0, attribute_name, api_path);
#else #else
auto res = parse_xattr_parameters(name, attribute_name, api_path); auto res = parse_xattr_parameters(name, attribute_name, api_path);
@ -960,17 +959,17 @@ auto fuse_drive::removexattr_impl(std::string api_path, const char *name)
}); });
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_drive::setxattr_impl(std::string api_path, const char *name, auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
const char *value, size_t size, int flags, const char *value, size_t size, int flags,
uint32_t position) -> api_error { uint32_t position) -> api_error {
#else // __APPLE__ #else // __APPLE__
auto fuse_drive::setxattr_impl(std::string api_path, const char *name, auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
const char *value, size_t size, int flags) const char *value, size_t size,
-> api_error { int flags) -> api_error {
#endif #endif
std::string attribute_name; std::string attribute_name;
#ifdef __APPLE__ #if defined(__APPLE__)
auto res = parse_xattr_parameters(name, value, size, position, attribute_name, auto res = parse_xattr_parameters(name, value, size, position, attribute_name,
api_path); api_path);
#else // __APPLE__ #else // __APPLE__
@ -991,7 +990,7 @@ auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
if (utils::string::contains(attribute_name, " .") || if (utils::string::contains(attribute_name, " .") ||
utils::string::contains(attribute_name, ". ") utils::string::contains(attribute_name, ". ")
#ifndef __APPLE__ #if !defined(__APPLE__)
|| utils::collection_excludes(utils::attribute_namespaces, || utils::collection_excludes(utils::attribute_namespaces,
attribute_namespace) attribute_namespace)
#endif #endif
@ -1039,9 +1038,9 @@ void fuse_drive::set_item_meta(const std::string &api_path,
} }
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr) auto fuse_drive::setattr_x_impl(std::string api_path,
-> api_error { struct setattr_x *attr) -> api_error {
bool exists{}; bool exists{};
auto res = provider_.is_file(api_path, exists); auto res = provider_.is_file(api_path, exists);
if (res != api_error::success) { if (res != api_error::success) {
@ -1140,9 +1139,8 @@ auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr)
return api_error::success; return api_error::success;
} }
auto fuse_drive::setbkuptime_impl(std::string api_path, auto fuse_drive::setbkuptime_impl(
const struct timespec *bkuptime) std::string api_path, const struct timespec *bkuptime) -> api_error {
-> api_error {
return check_and_perform( return check_and_perform(
api_path, X_OK, [&](api_meta_map &meta) -> api_error { api_path, X_OK, [&](api_meta_map &meta) -> api_error {
const auto nanos = const auto nanos =
@ -1178,8 +1176,8 @@ auto fuse_drive::setvolname_impl(const char * /*volname*/) -> api_error {
return api_error::success; return api_error::success;
} }
auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf) auto fuse_drive::statfs_x_impl(std::string /*api_path*/,
-> api_error { struct statfs *stbuf) -> api_error {
if (statfs(&config_.get_cache_directory()[0], stbuf) != 0) { if (statfs(&config_.get_cache_directory()[0], stbuf) != 0) {
return api_error::os_error; return api_error::os_error;
} }
@ -1204,8 +1202,8 @@ auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf)
return api_error::success; return api_error::success;
} }
#else // __APPLE__ #else // __APPLE__
auto fuse_drive::statfs_impl(std::string /*api_path*/, struct statvfs *stbuf) auto fuse_drive::statfs_impl(std::string /*api_path*/,
-> api_error { struct statvfs *stbuf) -> api_error {
if (statvfs(config_.get_cache_directory().data(), stbuf) != 0) { if (statvfs(config_.get_cache_directory().data(), stbuf) != 0) {
return api_error::os_error; return api_error::os_error;
} }
@ -1286,8 +1284,8 @@ auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2],
struct fuse_file_info * /*file_info*/) struct fuse_file_info * /*file_info*/)
-> api_error { -> api_error {
#else #else
auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2]) auto fuse_drive::utimens_impl(std::string api_path,
-> api_error { const struct timespec tv[2]) -> api_error {
#endif #endif
api_meta_map meta; api_meta_map meta;
auto res = provider_.get_item_meta(api_path, meta); auto res = provider_.get_item_meta(api_path, meta);

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef _WIN32 #if !defined(_WIN32)
#include "drives/fuse/fuse_drive_base.hpp" #include "drives/fuse/fuse_drive_base.hpp"
@ -30,8 +30,8 @@ auto fuse_drive_base::access_impl(std::string api_path, int mask) -> api_error {
return check_access(api_path, mask); return check_access(api_path, mask);
} }
auto fuse_drive_base::check_access(const std::string &api_path, int mask) const auto fuse_drive_base::check_access(const std::string &api_path,
-> api_error { int mask) const -> api_error {
api_meta_map meta; api_meta_map meta;
const auto res = get_item_meta(api_path, meta); const auto res = get_item_meta(api_path, meta);
if (res != api_error::success) { if (res != api_error::success) {
@ -126,9 +126,8 @@ auto fuse_drive_base::check_and_perform(
return action(meta); return action(meta);
} }
auto fuse_drive_base::check_open_flags(int flags, int mask, auto fuse_drive_base::check_open_flags(
const api_error &fail_error) int flags, int mask, const api_error &fail_error) -> api_error {
-> api_error {
return ((flags & mask) ? fail_error : api_error::success); return ((flags & mask) ? fail_error : api_error::success);
} }
@ -185,8 +184,8 @@ auto fuse_drive_base::check_parent_access(const std::string &api_path,
return ret; return ret;
} }
auto fuse_drive_base::check_readable(int flags, const api_error &fail_error) auto fuse_drive_base::check_readable(int flags,
-> api_error { const api_error &fail_error) -> api_error {
const auto mode = (flags & O_ACCMODE); const auto mode = (flags & O_ACCMODE);
return ((mode == O_WRONLY) ? fail_error : api_error::success); return ((mode == O_WRONLY) ? fail_error : api_error::success);
} }
@ -214,7 +213,7 @@ auto fuse_drive_base::get_effective_uid() const -> uid_t {
return forced_uid_.has_value() ? forced_uid_.value() : get_current_uid(); return forced_uid_.has_value() ? forced_uid_.value() : get_current_uid();
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_drive_base::get_flags_from_meta(const api_meta_map &meta) auto fuse_drive_base::get_flags_from_meta(const api_meta_map &meta)
-> __uint32_t { -> __uint32_t {
return utils::string::to_uint32(meta.at(META_OSXFLAGS)); return utils::string::to_uint32(meta.at(META_OSXFLAGS));
@ -241,17 +240,14 @@ auto fuse_drive_base::get_uid_from_meta(const api_meta_map &meta) -> uid_t {
return static_cast<uid_t>(utils::string::to_uint32(meta.at(META_UID))); return static_cast<uid_t>(utils::string::to_uint32(meta.at(META_UID)));
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_drive_base::parse_xattr_parameters(const char *name, auto fuse_drive_base::parse_xattr_parameters(
const uint32_t &position, const char *name, const uint32_t &position, std::string &attribute_name,
std::string &attribute_name, const std::string &api_path) -> api_error {
const std::string &api_path)
-> api_error {
#else #else
auto fuse_drive_base::parse_xattr_parameters(const char *name, auto fuse_drive_base::parse_xattr_parameters(
std::string &attribute_name, const char *name, std::string &attribute_name,
const std::string &api_path) const std::string &api_path) -> api_error {
-> api_error {
#endif #endif
auto res = api_path.empty() ? api_error::bad_address : api_error::success; auto res = api_path.empty() ? api_error::bad_address : api_error::success;
if (res != api_error::success) { if (res != api_error::success) {
@ -263,7 +259,7 @@ auto fuse_drive_base::parse_xattr_parameters(const char *name,
} }
attribute_name = std::string(name); attribute_name = std::string(name);
#ifdef __APPLE__ #if defined(__APPLE__)
if (attribute_name == A_KAUTH_FILESEC_XATTR) { if (attribute_name == A_KAUTH_FILESEC_XATTR) {
char new_name[MAXPATHLEN] = {0}; char new_name[MAXPATHLEN] = {0};
memcpy(new_name, A_KAUTH_FILESEC_XATTR, sizeof(A_KAUTH_FILESEC_XATTR)); memcpy(new_name, A_KAUTH_FILESEC_XATTR, sizeof(A_KAUTH_FILESEC_XATTR));
@ -278,17 +274,15 @@ auto fuse_drive_base::parse_xattr_parameters(const char *name,
return api_error::success; return api_error::success;
} }
#ifdef __APPLE__ #if defined(__APPLE__)
auto fuse_drive_base::parse_xattr_parameters( auto fuse_drive_base::parse_xattr_parameters(
const char *name, const char *value, size_t size, const uint32_t &position, const char *name, const char *value, size_t size, const uint32_t &position,
std::string &attribute_name, const std::string &api_path) -> api_error { std::string &attribute_name, const std::string &api_path) -> api_error {
auto res = parse_xattr_parameters(name, position, attribute_name, api_path); auto res = parse_xattr_parameters(name, position, attribute_name, api_path);
#else #else
auto fuse_drive_base::parse_xattr_parameters(const char *name, auto fuse_drive_base::parse_xattr_parameters(
const char *value, size_t size, const char *name, const char *value, size_t size,
std::string &attribute_name, std::string &attribute_name, const std::string &api_path) -> api_error {
const std::string &api_path)
-> api_error {
auto res = parse_xattr_parameters(name, attribute_name, api_path); auto res = parse_xattr_parameters(name, attribute_name, api_path);
#endif #endif
if (res != api_error::success) { if (res != api_error::success) {
@ -325,7 +319,7 @@ void fuse_drive_base::populate_stat(const std::string &api_path,
st->st_gid = get_gid_from_meta(meta); st->st_gid = get_gid_from_meta(meta);
st->st_mode = (directory ? S_IFDIR : S_IFREG) | get_mode_from_meta(meta); st->st_mode = (directory ? S_IFDIR : S_IFREG) | get_mode_from_meta(meta);
st->st_uid = get_uid_from_meta(meta); st->st_uid = get_uid_from_meta(meta);
#ifdef __APPLE__ #if defined(__APPLE__)
st->st_blksize = 0; st->st_blksize = 0;
st->st_flags = get_flags_from_meta(meta); st->st_flags = get_flags_from_meta(meta);

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef _WIN32 #if !defined(_WIN32)
#include "drives/fuse/remotefuse/remote_fuse_drive.hpp" #include "drives/fuse/remotefuse/remote_fuse_drive.hpp"
@ -38,13 +38,13 @@
#include "utils/utils.hpp" #include "utils/utils.hpp"
namespace repertory::remote_fuse { namespace repertory::remote_fuse {
auto remote_fuse_drive::access_impl(std::string api_path, int mask) auto remote_fuse_drive::access_impl(std::string api_path,
-> api_error { int mask) -> api_error {
return utils::to_api_error( return utils::to_api_error(
remote_instance_->fuse_access(api_path.c_str(), mask)); remote_instance_->fuse_access(api_path.c_str(), mask));
} }
#ifdef __APPLE__ #if defined(__APPLE__)
api_error remote_fuse_drive::chflags_impl(std::string api_path, api_error remote_fuse_drive::chflags_impl(std::string api_path,
uint32_t flags) { uint32_t flags) {
return utils::to_api_error( return utils::to_api_error(
@ -57,8 +57,8 @@ auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode,
struct fuse_file_info * /*f_info*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
#else #else
auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode) auto remote_fuse_drive::chmod_impl(std::string api_path,
-> api_error { mode_t mode) -> api_error {
#endif #endif
return utils::to_api_error(remote_instance_->fuse_chmod( return utils::to_api_error(remote_instance_->fuse_chmod(
api_path.c_str(), static_cast<remote::file_mode>(mode))); api_path.c_str(), static_cast<remote::file_mode>(mode)));
@ -69,8 +69,8 @@ auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid,
struct fuse_file_info * /*f_info*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
#else #else
auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid) auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid,
-> api_error { gid_t gid) -> api_error {
#endif #endif
return utils::to_api_error( return utils::to_api_error(
remote_instance_->fuse_chown(api_path.c_str(), uid, gid)); remote_instance_->fuse_chown(api_path.c_str(), uid, gid));
@ -114,10 +114,9 @@ void remote_fuse_drive::destroy_impl(void *ptr) {
fuse_base::destroy_impl(ptr); fuse_base::destroy_impl(ptr);
} }
auto remote_fuse_drive::fgetattr_impl(std::string api_path, auto remote_fuse_drive::fgetattr_impl(
struct stat *unix_st, std::string api_path, struct stat *unix_st,
struct fuse_file_info *f_info) struct fuse_file_info *f_info) -> api_error {
-> api_error {
remote::stat r_stat{}; remote::stat r_stat{};
auto directory = false; auto directory = false;
@ -130,7 +129,7 @@ auto remote_fuse_drive::fgetattr_impl(std::string api_path,
return utils::to_api_error(res); return utils::to_api_error(res);
} }
#ifdef __APPLE__ #if defined(__APPLE__)
api_error remote_fuse_drive::fsetattr_x_impl(std::string api_path, api_error remote_fuse_drive::fsetattr_x_impl(std::string api_path,
struct setattr_x *attr, struct setattr_x *attr,
struct fuse_file_info *f_info) { struct fuse_file_info *f_info) {
@ -177,8 +176,8 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st,
struct fuse_file_info * /*f_info*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
#else #else
auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st) auto remote_fuse_drive::getattr_impl(std::string api_path,
-> api_error { struct stat *unix_st) -> api_error {
#endif #endif
bool directory = false; bool directory = false;
remote::stat r_stat{}; remote::stat r_stat{};
@ -192,7 +191,7 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st)
return utils::to_api_error(res); return utils::to_api_error(res);
} }
#ifdef __APPLE__ #if defined(__APPLE__)
api_error remote_fuse_drive::getxtimes_impl(std::string api_path, api_error remote_fuse_drive::getxtimes_impl(std::string api_path,
struct timespec *bkuptime, struct timespec *bkuptime,
struct timespec *crtime) { struct timespec *crtime) {
@ -259,8 +258,8 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * {
return ret; return ret;
} }
auto remote_fuse_drive::mkdir_impl(std::string api_path, mode_t mode) auto remote_fuse_drive::mkdir_impl(std::string api_path,
-> api_error { mode_t mode) -> api_error {
return utils::to_api_error(remote_instance_->fuse_mkdir( return utils::to_api_error(remote_instance_->fuse_mkdir(
api_path.c_str(), static_cast<remote::file_mode>(mode))); api_path.c_str(), static_cast<remote::file_mode>(mode)));
} }
@ -282,9 +281,8 @@ auto remote_fuse_drive::open_impl(std::string api_path,
f_info->fh)); f_info->fh));
} }
auto remote_fuse_drive::opendir_impl(std::string api_path, auto remote_fuse_drive::opendir_impl(
struct fuse_file_info *f_info) std::string api_path, struct fuse_file_info *f_info) -> api_error {
-> api_error {
return utils::to_api_error( return utils::to_api_error(
remote_instance_->fuse_opendir(api_path.c_str(), f_info->fh)); remote_instance_->fuse_opendir(api_path.c_str(), f_info->fh));
@ -294,7 +292,7 @@ void remote_fuse_drive::populate_stat(const remote::stat &r_stat,
bool directory, struct stat &unix_st) { bool directory, struct stat &unix_st) {
memset(&unix_st, 0, sizeof(struct stat)); memset(&unix_st, 0, sizeof(struct stat));
#ifdef __APPLE__ #if defined(__APPLE__)
unix_st.st_blksize = 0; unix_st.st_blksize = 0;
unix_st.st_atimespec.tv_nsec = r_stat.st_atimespec % NANOS_PER_SECOND; unix_st.st_atimespec.tv_nsec = r_stat.st_atimespec % NANOS_PER_SECOND;
@ -364,18 +362,14 @@ auto remote_fuse_drive::read_impl(std::string api_path, char *buffer,
} }
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf, auto remote_fuse_drive::readdir_impl(
fuse_fill_dir_t fuse_fill_dir, std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
off_t offset, off_t offset, struct fuse_file_info *f_info,
struct fuse_file_info *f_info, fuse_readdir_flags /*flags*/) -> api_error {
fuse_readdir_flags /*flags*/)
-> api_error {
#else #else
auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf, auto remote_fuse_drive::readdir_impl(
fuse_fill_dir_t fuse_fill_dir, std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
off_t offset, off_t offset, struct fuse_file_info *f_info) -> api_error {
struct fuse_file_info *f_info)
-> api_error {
#endif #endif
std::string item_path; std::string item_path;
int res = 0; int res = 0;
@ -403,16 +397,14 @@ auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
return utils::to_api_error(res); return utils::to_api_error(res);
} }
auto remote_fuse_drive::release_impl(std::string api_path, auto remote_fuse_drive::release_impl(
struct fuse_file_info *f_info) std::string api_path, struct fuse_file_info *f_info) -> api_error {
-> api_error {
return utils::to_api_error( return utils::to_api_error(
remote_instance_->fuse_release(api_path.c_str(), f_info->fh)); remote_instance_->fuse_release(api_path.c_str(), f_info->fh));
} }
auto remote_fuse_drive::releasedir_impl(std::string api_path, auto remote_fuse_drive::releasedir_impl(
struct fuse_file_info *f_info) std::string api_path, struct fuse_file_info *f_info) -> api_error {
-> api_error {
return utils::to_api_error( return utils::to_api_error(
remote_instance_->fuse_releasedir(api_path.c_str(), f_info->fh)); remote_instance_->fuse_releasedir(api_path.c_str(), f_info->fh));
} }
@ -433,7 +425,7 @@ auto remote_fuse_drive::rmdir_impl(std::string api_path) -> api_error {
return utils::to_api_error(remote_instance_->fuse_rmdir(api_path.c_str())); return utils::to_api_error(remote_instance_->fuse_rmdir(api_path.c_str()));
} }
#ifdef __APPLE__ #if defined(__APPLE__)
api_error remote_fuse_drive::setattr_x_impl(std::string api_path, api_error remote_fuse_drive::setattr_x_impl(std::string api_path,
struct setattr_x *attr) { struct setattr_x *attr) {
remote::setattr_x attributes{}; remote::setattr_x attributes{};
@ -508,8 +500,8 @@ api_error remote_fuse_drive::statfs_x_impl(std::string api_path,
return utils::to_api_error(res); return utils::to_api_error(res);
} }
#else // __APPLE__ #else // __APPLE__
auto remote_fuse_drive::statfs_impl(std::string api_path, struct statvfs *stbuf) auto remote_fuse_drive::statfs_impl(std::string api_path,
-> api_error { struct statvfs *stbuf) -> api_error {
auto res = statvfs(config_.get_data_directory().c_str(), stbuf); auto res = statvfs(config_.get_data_directory().c_str(), stbuf);
if (res == 0) { if (res == 0) {
remote::statfs r_stat{}; remote::statfs r_stat{};
@ -536,8 +528,8 @@ auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size,
struct fuse_file_info * /*f_info*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
#else #else
auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size) auto remote_fuse_drive::truncate_impl(std::string api_path,
-> api_error { off_t size) -> api_error {
#endif #endif
return utils::to_api_error(remote_instance_->fuse_truncate( return utils::to_api_error(remote_instance_->fuse_truncate(
api_path.c_str(), static_cast<remote::file_offset>(size))); api_path.c_str(), static_cast<remote::file_offset>(size)));
@ -548,10 +540,9 @@ auto remote_fuse_drive::unlink_impl(std::string api_path) -> api_error {
} }
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto remote_fuse_drive::utimens_impl(std::string api_path, auto remote_fuse_drive::utimens_impl(
const struct timespec tv[2], std::string api_path, const struct timespec tv[2],
struct fuse_file_info * /*f_info*/) struct fuse_file_info * /*f_info*/) -> api_error {
-> api_error {
#else #else
auto remote_fuse_drive::utimens_impl(std::string api_path, auto remote_fuse_drive::utimens_impl(std::string api_path,
const struct timespec tv[2]) -> api_error { const struct timespec tv[2]) -> api_error {

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef _WIN32 #if !defined(_WIN32)
#include "drives/fuse/remotefuse/remote_server.hpp" #include "drives/fuse/remotefuse/remote_server.hpp"
@ -146,7 +146,7 @@ void remote_server::populate_file_info(const std::string &api_path,
void remote_server::populate_stat(const struct stat64 &unix_st, void remote_server::populate_stat(const struct stat64 &unix_st,
remote::stat &r_stat) { remote::stat &r_stat) {
memset(&r_stat, 0, sizeof(r_stat)); memset(&r_stat, 0, sizeof(r_stat));
#ifdef __APPLE__ #if defined(__APPLE__)
r_stat.st_flags = unix_st.st_flags; r_stat.st_flags = unix_st.st_flags;
r_stat.st_atimespec = unix_st.st_atimespec.tv_nsec + r_stat.st_atimespec = unix_st.st_atimespec.tv_nsec +
@ -190,8 +190,8 @@ auto remote_server::fuse_access(const char *path, const std::int32_t &mask)
return ret; return ret;
} }
auto remote_server::fuse_chflags(const char *path, std::uint32_t flags) auto remote_server::fuse_chflags(const char *path,
-> packet::error_type { std::uint32_t flags) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -264,7 +264,7 @@ auto remote_server::fuse_destroy() -> packet::error_type {
std::int32_t &mode, const remote::file_offset &offset, const remote::file_offset std::int32_t &mode, const remote::file_offset &offset, const remote::file_offset
&length, const remote::file_handle &handle) { const auto file_path = &length, const remote::file_handle &handle) { const auto file_path =
ConstructPath(path); auto ret = HasOpenFileInfo(handle, -EBADF); if (ret == 0) { ConstructPath(path); auto ret = HasOpenFileInfo(handle, -EBADF); if (ret == 0) {
#ifdef __APPLE__ #if defined(__APPLE__)
ret = STATUS_NOT_IMPLEMENTED; ret = STATUS_NOT_IMPLEMENTED;
fstore_t fstore = {0}; fstore_t fstore = {0};
@ -298,10 +298,9 @@ length); ret = ((res < 0) ? -errno : 0); #endif
return ret; return ret;
}*/ }*/
auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, auto remote_server::fuse_fgetattr(
bool &directory, const char *path, remote::stat &r_stat, bool &directory,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -322,10 +321,9 @@ auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat,
return ret; return ret;
} }
auto remote_server::fuse_fsetattr_x(const char *path, auto remote_server::fuse_fsetattr_x(
const remote::setattr_x &attr, const char *path, const remote::setattr_x &attr,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -425,7 +423,7 @@ auto remote_server::fuse_fsync(const char *path, const std::int32_t &datasync,
auto res = has_open_info(static_cast<native_handle>(handle), EBADF); auto res = has_open_info(static_cast<native_handle>(handle), EBADF);
if (res == 0) { if (res == 0) {
#ifdef __APPLE__ #if defined(__APPLE__)
res = datasync ? fcntl(static_cast<native_handle>(handle), F_FULLFSYNC) res = datasync ? fcntl(static_cast<native_handle>(handle), F_FULLFSYNC)
: fsync(static_cast<native_handle>(handle)); : fsync(static_cast<native_handle>(handle));
#else #else
@ -439,10 +437,9 @@ auto remote_server::fuse_fsync(const char *path, const std::int32_t &datasync,
return ret; return ret;
} }
auto remote_server::fuse_ftruncate(const char *path, auto remote_server::fuse_ftruncate(
const remote::file_offset &size, const char *path, const remote::file_offset &size,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -486,7 +483,7 @@ utils::path::create_api_path(path); const auto file_path =
ConstructPath(api_path); const auto parentApiPath = ConstructPath(api_path); const auto parentApiPath =
utils::path::get_parent_api_path(api_path); utils::path::get_parent_api_path(api_path);
#if __APPLE__ || !HAS_SETXATTR #if defined(__APPLE__) || !defined(HAS_SETXATTR)
auto ret = STATUS_NOT_IMPLEMENTED; auto ret = STATUS_NOT_IMPLEMENTED;
#else #else
auto found = false; auto found = false;
@ -524,7 +521,8 @@ filePath, ret); return ret;
packet::error_type remote_server::fuse_getxattrOSX(const char *path, const char packet::error_type remote_server::fuse_getxattrOSX(const char *path, const char
*name, char *value, const remote::file_size &size, std::uint32_t position) { *name, char *value, const remote::file_size &size, std::uint32_t position) {
const auto file_path = ConstructPath(path); #if __APPLE__ && HAS_SETXATTR const auto file_path = ConstructPath(path); #if defined(__APPLE__) &&
defined(HAS_SETXATTR)
// TODO: CheckParentAccess(api_path, X_OK) // TODO: CheckParentAccess(api_path, X_OK)
// TODO: Use iterator cache // TODO: Use iterator cache
const auto res = getxattr(file_path.c_str(), name, value, size, position, const auto res = getxattr(file_path.c_str(), name, value, size, position,
@ -533,10 +531,9 @@ STATUS_NOT_IMPLEMENTED; #endif RAISE_REMOTE_FUSE_SERVER_EVENT(function_name,
file_path, ret); return ret; file_path, ret); return ret;
}*/ }*/
auto remote_server::fuse_getxtimes(const char *path, auto remote_server::fuse_getxtimes(
remote::file_time &bkuptime, const char *path, remote::file_time &bkuptime,
remote::file_time &crtime) remote::file_time &crtime) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -575,10 +572,10 @@ auto remote_server::fuse_init() -> packet::error_type {
/*packet::error_type remote_server::fuse_listxattr(const char *path, char /*packet::error_type remote_server::fuse_listxattr(const char *path, char
*buffer, const remote::file_size &size) { const auto file_path = *buffer, const remote::file_size &size) { const auto file_path =
ConstructPath(path); #ifdef HAS_SETXATTR #ifdef __APPLE__ const auto res = ConstructPath(path); #if defined(HAS_SETXATTR) #if defined(__APPLE__) const auto
listxattr(file_path.c_str(), buffer, size, FSOPT_NOFOLLOW); #else const auto res res = listxattr(file_path.c_str(), buffer, size, FSOPT_NOFOLLOW); #else const
= listxattr(file_path.c_str(), buffer, size); #endif auto ret = ((res < 0) ? auto res = listxattr(file_path.c_str(), buffer, size); #endif auto ret = ((res <
-errno : 0); #else auto ret = STATUS_NOT_IMPLEMENTED; #endif 0) ? -errno : 0); #else auto ret = STATUS_NOT_IMPLEMENTED; #endif
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret);
return ret; return ret;
}*/ }*/
@ -636,11 +633,10 @@ auto remote_server::fuse_opendir(const char *path, remote::file_handle &handle)
return ret; return ret;
} }
auto remote_server::fuse_read(const char *path, char *buffer, auto remote_server::fuse_read(
const remote::file_size &read_size, const char *path, char *buffer, const remote::file_size &read_size,
const remote::file_offset &read_offset, const remote::file_offset &read_offset,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -661,8 +657,8 @@ auto remote_server::fuse_read(const char *path, char *buffer,
return static_cast<packet::error_type>(ret); return static_cast<packet::error_type>(ret);
} }
auto remote_server::fuse_rename(const char *from, const char *to) auto remote_server::fuse_rename(const char *from,
-> packet::error_type { const char *to) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto from_path = utils::path::combine(mount_location_, {from}); const auto from_path = utils::path::combine(mount_location_, {from});
@ -700,9 +696,8 @@ auto remote_server::fuse_readdir(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_release(const char *path, auto remote_server::fuse_release(
const remote::file_handle &handle) const char *path, const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
packet::error_type ret = 0; packet::error_type ret = 0;
@ -719,9 +714,8 @@ auto remote_server::fuse_release(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_releasedir(const char *path, auto remote_server::fuse_releasedir(
const remote::file_handle &handle) const char *path, const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -734,16 +728,11 @@ auto remote_server::fuse_releasedir(const char *path,
} }
/*packet::error_type remote_server::fuse_removexattr(const char *path, const /*packet::error_type remote_server::fuse_removexattr(const char *path, const
char *name) { const auto file_path = ConstructPath(path); #ifdef HAS_SETXATTR char *name) { const auto file_path = ConstructPath(path); #if
#ifdef __APPLE__ defined(HAS_SETXATTR) #if defined(__APPLE__) const auto res =
const auto res = removexattr(file_path.c_str(), name, FSOPT_NOFOLLOW); removexattr(file_path.c_str(), name, FSOPT_NOFOLLOW); #else const auto res =
#else removexattr(file_path.c_str(), name); #endif auto ret = ((res < 0) ? -errno :
const auto res = removexattr(file_path.c_str(), name); 0); #else auto ret = STATUS_NOT_IMPLEMENTED; #endif
#endif
auto ret = ((res < 0) ? -errno : 0);
#else
auto ret = STATUS_NOT_IMPLEMENTED;
#endif
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret);
return ret; return ret;
}*/ }*/
@ -778,9 +767,8 @@ auto remote_server::fuse_setattr_x(const char *path, remote::setattr_x &attr)
return ret; return ret;
} }
auto remote_server::fuse_setbkuptime(const char *path, auto remote_server::fuse_setbkuptime(
const remote::file_time &bkuptime) const char *path, const remote::file_time &bkuptime) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -799,9 +787,8 @@ auto remote_server::fuse_setbkuptime(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_setchgtime(const char *path, auto remote_server::fuse_setchgtime(
const remote::file_time &chgtime) const char *path, const remote::file_time &chgtime) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -820,9 +807,8 @@ auto remote_server::fuse_setchgtime(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_setcrtime(const char *path, auto remote_server::fuse_setcrtime(
const remote::file_time &crtime) const char *path, const remote::file_time &crtime) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -850,8 +836,8 @@ auto remote_server::fuse_setvolname(const char *volname) -> packet::error_type {
/*packet::error_type remote_server::fuse_setxattr(const char *path, const char /*packet::error_type remote_server::fuse_setxattr(const char *path, const char
*name, const char *value, const remote::file_size &size, const std::int32_t *name, const char *value, const remote::file_size &size, const std::int32_t
&flags) { const auto file_path = ConstructPath(path); #if __APPLE__ || &flags) { const auto file_path = ConstructPath(path); #if defined(__APPLE__{} ||
!HAS_SETXATTR auto ret = STATUS_NOT_IMPLEMENTED; #else const auto res = !defined(HAS_SETXATTR) auto ret = STATUS_NOT_IMPLEMENTED; #else const auto res =
setxattr(file_path.c_str(), name, value, size, flags); auto ret = ((res < 0) ? setxattr(file_path.c_str(), name, value, size, flags); auto ret = ((res < 0) ?
-errno : 0); #endif RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, -errno : 0); #endif RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path,
ret); return ret; ret); return ret;
@ -860,8 +846,9 @@ ret); return ret;
packet::error_type remote_server::fuse_setxattrOSX(const char *path, const char packet::error_type remote_server::fuse_setxattrOSX(const char *path, const char
*name, const char *value, const remote::file_size &size, const std::int32_t *name, const char *value, const remote::file_size &size, const std::int32_t
&flags, const std::uint32_t &position) { const auto file_path = &flags, const std::uint32_t &position) { const auto file_path =
ConstructPath(path); #if __APPLE__ && HAS_SETXATTR const auto res = ConstructPath(path); #if defined(__APPLE__) && defined(HAS_SETXATTR) const auto
setxattr(file_path.c_str(), name, value, size, position, flags); auto ret = res = setxattr(file_path.c_str(), name, value, size, position, flags); auto ret
=
((res < 0) ? -errno : 0); #else auto ret = STATUS_NOT_IMPLEMENTED; #endif ((res < 0) ? -errno : 0); #else auto ret = STATUS_NOT_IMPLEMENTED; #endif
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret);
return ret; return ret;
@ -912,9 +899,8 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize,
return 0; return 0;
} }
auto remote_server::fuse_truncate(const char *path, auto remote_server::fuse_truncate(
const remote::file_offset &size) const char *path, const remote::file_offset &size) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -935,8 +921,8 @@ auto remote_server::fuse_unlink(const char *path) -> packet::error_type {
} }
auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
std::uint64_t op0, std::uint64_t op1) std::uint64_t op0,
-> packet::error_type { std::uint64_t op1) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -965,11 +951,10 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
return ret; return ret;
} }
auto remote_server::fuse_write(const char *path, const char *buffer, auto remote_server::fuse_write(
const remote::file_size &write_size, const char *path, const char *buffer, const remote::file_size &write_size,
const remote::file_offset &write_offset, const remote::file_offset &write_offset,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -999,8 +984,8 @@ auto remote_server::fuse_write_base64(
} }
// WinFSP Layer // WinFSP Layer
auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR file_name) auto remote_server::winfsp_can_delete(PVOID file_desc,
-> packet::error_type { PWSTR file_name) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
@ -1026,8 +1011,8 @@ auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR file_name)
} }
auto remote_server::winfsp_cleanup(PVOID /*file_desc*/, PWSTR file_name, auto remote_server::winfsp_cleanup(PVOID /*file_desc*/, PWSTR file_name,
UINT32 flags, BOOLEAN &was_closed) UINT32 flags,
-> packet::error_type { BOOLEAN &was_closed) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
@ -1104,8 +1089,8 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, UINT32 attributes, UINT32 granted_access, UINT32 attributes,
UINT64 /*allocation_size*/, PVOID *file_desc, UINT64 /*allocation_size*/, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *file_info,
std::string &normalized_name, BOOLEAN &exists) std::string &normalized_name,
-> packet::error_type { BOOLEAN &exists) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
@ -1173,9 +1158,8 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
return ret; return ret;
} }
auto remote_server::winfsp_get_file_info(PVOID file_desc, auto remote_server::winfsp_get_file_info(
remote::file_info *file_info) PVOID file_desc, remote::file_info *file_info) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto handle = reinterpret_cast<remote::file_handle>(file_desc); const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
@ -1218,10 +1202,9 @@ auto remote_server::winfsp_get_security_by_name(
return ret; return ret;
} }
auto remote_server::winfsp_get_volume_info(UINT64 &total_size, auto remote_server::winfsp_get_volume_info(
UINT64 &free_size, UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) std::string &volume_label) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
drive_.get_volume_info(total_size, free_size, volume_label); drive_.get_volume_info(total_size, free_size, volume_label);
@ -1238,11 +1221,10 @@ auto remote_server::winfsp_mounted(const std::wstring &location)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, auto remote_server::winfsp_open(
UINT32 granted_access, PVOID *file_desc, PWSTR file_name, UINT32 create_options, UINT32 granted_access,
remote::file_info *file_info, PVOID *file_desc, remote::file_info *file_info,
std::string &normalized_name) std::string &normalized_name) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
@ -1277,11 +1259,10 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options,
return ret; return ret;
} }
auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, auto remote_server::winfsp_overwrite(
BOOLEAN replace_attributes, PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes,
UINT64 /*allocation_size*/, UINT64 /*allocation_size*/,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto handle = reinterpret_cast<remote::file_handle>(file_desc); const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
@ -1397,10 +1378,9 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
return ret; return ret;
} }
auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, auto remote_server::winfsp_rename(
PWSTR new_file_name, PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) BOOLEAN replace_if_exists) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
@ -1489,10 +1469,9 @@ auto remote_server::winfsp_set_basic_info(
return ret; return ret;
} }
auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, auto remote_server::winfsp_set_file_size(
BOOLEAN set_allocation_size, PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto handle = reinterpret_cast<remote::file_handle>(file_desc); const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
@ -1526,12 +1505,10 @@ auto remote_server::winfsp_unmounted(const std::wstring &location)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, auto remote_server::winfsp_write(
UINT32 length, BOOLEAN write_to_end, PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN constrained_io, BOOLEAN write_to_end, BOOLEAN constrained_io, PUINT32 bytes_transferred,
PUINT32 bytes_transferred, remote::file_info *file_info) -> packet::error_type {
remote::file_info *file_info)
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
*bytes_transferred = 0; *bytes_transferred = 0;
@ -1578,9 +1555,8 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
return ret; return ret;
} }
auto remote_server::json_create_directory_snapshot(const std::string &path, auto remote_server::json_create_directory_snapshot(
json &json_data) const std::string &path, json &json_data) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -1635,8 +1611,8 @@ auto remote_server::json_read_directory_snapshot(
} }
auto remote_server::json_release_directory_snapshot( auto remote_server::json_release_directory_snapshot(
const std::string &path, const remote::file_handle &handle) const std::string &path,
-> packet::error_type { const remote::file_handle &handle) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);

View File

@ -46,7 +46,7 @@ void remote_open_file_table::close_all(const std::string &client_id) {
compat_lock.unlock(); compat_lock.unlock();
for (auto &handle : compat_handles) { for (auto &handle : compat_handles) {
#ifdef _WIN32 #if defined(_WIN32)
_close(static_cast<int>(handle)); _close(static_cast<int>(handle));
#else #else
close(static_cast<int>(handle)); close(static_cast<int>(handle));
@ -64,7 +64,7 @@ void remote_open_file_table::close_all(const std::string &client_id) {
file_lock.unlock(); file_lock.unlock();
for (auto &handle : handles) { for (auto &handle : handles) {
#ifdef _WIN32 #if defined(_WIN32)
::CloseHandle(handle); ::CloseHandle(handle);
#else #else
close(handle); close(handle);
@ -86,7 +86,7 @@ void remote_open_file_table::close_all(const std::string &client_id) {
} }
} }
#ifdef _WIN32 #if defined(_WIN32)
auto remote_open_file_table::get_directory_buffer(const native_handle &handle, auto remote_open_file_table::get_directory_buffer(const native_handle &handle,
PVOID *&buffer) -> bool { PVOID *&buffer) -> bool {
recur_mutex_lock file_lock(file_mutex_); recur_mutex_lock file_lock(file_mutex_);
@ -224,7 +224,7 @@ void remote_open_file_table::remove_open_info(const native_handle &handle) {
file_lookup_[handle].count--; file_lookup_[handle].count--;
} }
if (not file_lookup_[handle].count) { if (not file_lookup_[handle].count) {
#ifdef _WIN32 #if defined(_WIN32)
if (file_lookup_[handle].directory_buffer) { if (file_lookup_[handle].directory_buffer) {
FspFileSystemDeleteDirectoryBuffer( FspFileSystemDeleteDirectoryBuffer(
&file_lookup_[handle].directory_buffer); &file_lookup_[handle].directory_buffer);

View File

@ -203,7 +203,7 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options,
set_open_info( set_open_info(
to_handle(*file_desc), to_handle(*file_desc),
open_info{0, "", nullptr, utils::string::to_utf8(file_name)}); open_info{0, "", nullptr, utils::string::to_utf8(file_name)});
#ifdef _WIN32 #if defined(_WIN32)
if (exists) { if (exists) {
::SetLastError(ERROR_ALREADY_EXISTS); ::SetLastError(ERROR_ALREADY_EXISTS);
} }
@ -237,7 +237,7 @@ auto remote_client::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
auto remote_client::winfsp_get_dir_buffer([[maybe_unused]] PVOID file_desc, auto remote_client::winfsp_get_dir_buffer([[maybe_unused]] PVOID file_desc,
[[maybe_unused]] PVOID *&ptr) [[maybe_unused]] PVOID *&ptr)
-> packet::error_type { -> packet::error_type {
#ifdef _WIN32 #if defined(_WIN32)
if (get_directory_buffer(reinterpret_cast<native_handle>(file_desc), ptr)) { if (get_directory_buffer(reinterpret_cast<native_handle>(file_desc), ptr)) {
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -402,7 +402,7 @@ auto remote_client::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
DECODE_OR_IGNORE(&response, *bytes_transferred); DECODE_OR_IGNORE(&response, *bytes_transferred);
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
ret = response.decode(buffer, *bytes_transferred); ret = response.decode(buffer, *bytes_transferred);
#ifdef _WIN32 #if defined(_WIN32)
if ((ret == STATUS_SUCCESS) && if ((ret == STATUS_SUCCESS) &&
(not *bytes_transferred || (*bytes_transferred != length))) { (not *bytes_transferred || (*bytes_transferred != length))) {
::SetLastError(ERROR_HANDLE_EOF); ::SetLastError(ERROR_HANDLE_EOF);
@ -555,7 +555,7 @@ auto remote_client::winfsp_write(
return ret; return ret;
} }
#ifndef _WIN32 #if !defined(_WIN32)
auto remote_client::to_handle(PVOID file_desc) -> native_handle { auto remote_client::to_handle(PVOID file_desc) -> native_handle {
return static_cast<native_handle>(reinterpret_cast<std::uint64_t>(file_desc)); return static_cast<native_handle>(reinterpret_cast<std::uint64_t>(file_desc));
} }

View File

@ -21,7 +21,7 @@
*/ */
// NOTE: Most of the WinFSP pass-through code has been modified from: // NOTE: Most of the WinFSP pass-through code has been modified from:
// https://github.com/billziss-gh/winfsp/blob/master/tst/passthrough-cpp/passthrough-cpp.cpp // https://github.com/billziss-gh/winfsp/blob/master/tst/passthrough-cpp/passthrough-cpp.cpp
#ifdef _WIN32 #if defined(_WIN32)
#include "drives/winfsp/remotewinfsp/remote_server.hpp" #include "drives/winfsp/remotewinfsp/remote_server.hpp"
@ -39,7 +39,7 @@
#include "utils/file_utils.hpp" #include "utils/file_utils.hpp"
#include "utils/path_utils.hpp" #include "utils/path_utils.hpp"
#ifndef _SH_DENYNO #if !defined(_SH_DENYNO)
#define _SH_DENYRW 0x10 // deny read/write mode #define _SH_DENYRW 0x10 // deny read/write mode
#define _SH_DENYWR 0x20 // deny write mode #define _SH_DENYWR 0x20 // deny write mode
#define _SH_DENYRD 0x30 // deny read mode #define _SH_DENYRD 0x30 // deny read mode
@ -129,10 +129,9 @@ auto remote_server::fuse_chmod(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_chown(const char *path, auto remote_server::fuse_chown(
const remote::user_id & /*uid*/, const char *path, const remote::user_id & /*uid*/,
const remote::group_id & /*gid*/) const remote::group_id & /*gid*/) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -160,10 +159,9 @@ construct_path(path); auto res = HasOpenFileCompatInfo(handle, EBADF); if (res
return ret; return ret;
}*/ }*/
auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, auto remote_server::fuse_fgetattr(
bool &directory, const char *path, remote::stat &r_stat, bool &directory,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -184,10 +182,9 @@ auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat,
return ret; return ret;
} }
auto remote_server::fuse_fsetattr_x(const char *path, auto remote_server::fuse_fsetattr_x(
const remote::setattr_x & /*attr*/, const char *path, const remote::setattr_x & /*attr*/,
const remote::file_handle & /*handle*/) const remote::file_handle & /*handle*/) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -196,10 +193,9 @@ auto remote_server::fuse_fsetattr_x(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_fsync(const char *path, auto remote_server::fuse_fsync(
const std::int32_t & /*datasync*/, const char *path, const std::int32_t & /*datasync*/,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -224,10 +220,9 @@ auto remote_server::fuse_fsync(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_ftruncate(const char *path, auto remote_server::fuse_ftruncate(
const remote::file_offset &size, const char *path, const remote::file_offset &size,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -288,10 +283,9 @@ STATUS_NOT_IMPLEMENTED; RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name,
file_path, ret); return ret; file_path, ret); return ret;
}*/ }*/
auto remote_server::fuse_getxtimes(const char *path, auto remote_server::fuse_getxtimes(
remote::file_time & /*bkuptime*/, const char *path, remote::file_time & /*bkuptime*/,
remote::file_time & /*crtime*/) remote::file_time & /*crtime*/) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -416,11 +410,10 @@ auto remote_server::fuse_open(const char *path, const remote::open_flags &flags,
return ret; return ret;
} }
auto remote_server::fuse_read(const char *path, char *buffer, auto remote_server::fuse_read(
const remote::file_size &read_size, const char *path, char *buffer, const remote::file_size &read_size,
const remote::file_offset &read_offset, const remote::file_offset &read_offset,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -464,8 +457,8 @@ auto remote_server::fuse_read(const char *path, char *buffer,
return ret; return ret;
} }
auto remote_server::fuse_rename(const char *from, const char *to) auto remote_server::fuse_rename(const char *from,
-> packet::error_type { const char *to) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto from_path = utils::path::combine(mount_location_, {from}); const auto from_path = utils::path::combine(mount_location_, {from});
@ -478,11 +471,10 @@ auto remote_server::fuse_rename(const char *from, const char *to)
return ret; return ret;
} }
auto remote_server::fuse_write(const char *path, const char *buffer, auto remote_server::fuse_write(
const remote::file_size &write_size, const char *path, const char *buffer, const remote::file_size &write_size,
const remote::file_offset &write_offset, const remote::file_offset &write_offset,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -553,9 +545,8 @@ auto remote_server::fuse_readdir(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_release(const char *path, auto remote_server::fuse_release(
const remote::file_handle &handle) const char *path, const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -595,9 +586,8 @@ auto remote_server::fuse_rmdir(const char *path) -> packet::error_type {
return ret; return ret;
} }
auto remote_server::fuse_setattr_x(const char *path, auto remote_server::fuse_setattr_x(
remote::setattr_x & /*attr*/) const char *path, remote::setattr_x & /*attr*/) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -709,9 +699,8 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize,
return 0; return 0;
} }
auto remote_server::fuse_truncate(const char *path, auto remote_server::fuse_truncate(
const remote::file_offset &size) const char *path, const remote::file_offset &size) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -756,8 +745,8 @@ auto remote_server::fuse_unlink(const char *path) -> packet::error_type {
} }
auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
std::uint64_t op0, std::uint64_t op1) std::uint64_t op0,
-> packet::error_type { std::uint64_t op1) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -817,9 +806,8 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
} }
// JSON Layer // JSON Layer
auto remote_server::json_create_directory_snapshot(const std::string &path, auto remote_server::json_create_directory_snapshot(
json &json_data) const std::string &path, json &json_data) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -872,8 +860,8 @@ auto remote_server::json_read_directory_snapshot(
} }
auto remote_server::json_release_directory_snapshot( auto remote_server::json_release_directory_snapshot(
const std::string &path, const remote::file_handle & /*handle*/) const std::string &path,
-> packet::error_type { const remote::file_handle & /*handle*/) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -904,8 +892,8 @@ auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR /*file_name*/)
} }
auto remote_server::winfsp_cleanup(PVOID file_desc, PWSTR /*file_name*/, auto remote_server::winfsp_cleanup(PVOID file_desc, PWSTR /*file_name*/,
UINT32 flags, BOOLEAN &was_closed) UINT32 flags,
-> packet::error_type { BOOLEAN &was_closed) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = get_open_file_path(file_desc); const auto file_path = get_open_file_path(file_desc);
@ -942,8 +930,8 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, UINT32 attributes, UINT32 granted_access, UINT32 attributes,
UINT64 /*allocation_size*/, PVOID *file_desc, UINT64 /*allocation_size*/, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *file_info,
std::string &normalized_name, BOOLEAN &exists) std::string &normalized_name,
-> packet::error_type { BOOLEAN &exists) -> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = utils::string::from_utf8(utils::path::combine( const auto file_path = utils::string::from_utf8(utils::path::combine(
@ -1004,9 +992,8 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
return ret; return ret;
} }
auto remote_server::winfsp_get_file_info(PVOID file_desc, auto remote_server::winfsp_get_file_info(
remote::file_info *file_info) PVOID file_desc, remote::file_info *file_info) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
auto *handle = reinterpret_cast<HANDLE>(file_desc); auto *handle = reinterpret_cast<HANDLE>(file_desc);
@ -1020,11 +1007,9 @@ auto remote_server::winfsp_get_file_info(PVOID file_desc,
return ret; return ret;
} }
auto remote_server::winfsp_get_security_by_name(PWSTR file_name, auto remote_server::winfsp_get_security_by_name(
PUINT32 attributes, PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size,
std::uint64_t *descriptor_size, std::wstring &string_descriptor) -> packet::error_type {
std::wstring &string_descriptor)
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = utils::string::from_utf8(utils::path::combine( const auto file_path = utils::string::from_utf8(utils::path::combine(
@ -1062,10 +1047,9 @@ auto remote_server::winfsp_get_security_by_name(PWSTR file_name,
return ret; return ret;
} }
auto remote_server::winfsp_get_volume_info(UINT64 &total_size, auto remote_server::winfsp_get_volume_info(
UINT64 &free_size, UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) std::string &volume_label) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
drive_.get_volume_info(total_size, free_size, volume_label); drive_.get_volume_info(total_size, free_size, volume_label);
@ -1082,11 +1066,10 @@ auto remote_server::winfsp_mounted(const std::wstring &location)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, auto remote_server::winfsp_open(
UINT32 granted_access, PVOID *file_desc, PWSTR file_name, UINT32 create_options, UINT32 granted_access,
remote::file_info *file_info, PVOID *file_desc, remote::file_info *file_info,
std::string &normalized_name) std::string &normalized_name) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto file_path = utils::string::from_utf8(utils::path::combine( const auto file_path = utils::string::from_utf8(utils::path::combine(
@ -1118,11 +1101,10 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options,
return ret; return ret;
} }
auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, auto remote_server::winfsp_overwrite(
BOOLEAN replace_attributes, PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes,
UINT64 /*allocation_size*/, UINT64 /*allocation_size*/,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
auto *handle = reinterpret_cast<HANDLE>(file_desc); auto *handle = reinterpret_cast<HANDLE>(file_desc);
@ -1234,10 +1216,9 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
return ret; return ret;
} }
auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, auto remote_server::winfsp_rename(
PWSTR new_file_name, PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) BOOLEAN replace_if_exists) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
const auto from_path = utils::string::from_utf8(utils::path::combine( const auto from_path = utils::string::from_utf8(utils::path::combine(
@ -1289,10 +1270,9 @@ auto remote_server::winfsp_set_basic_info(
return ret; return ret;
} }
auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, auto remote_server::winfsp_set_file_size(
BOOLEAN set_allocation_size, PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type {
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
auto *handle = reinterpret_cast<HANDLE>(file_desc); auto *handle = reinterpret_cast<HANDLE>(file_desc);
@ -1335,12 +1315,10 @@ auto remote_server::winfsp_unmounted(const std::wstring &location)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, auto remote_server::winfsp_write(
UINT32 length, BOOLEAN /*write_to_end*/, PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN constrained_io, BOOLEAN /*write_to_end*/, BOOLEAN constrained_io, PUINT32 bytes_transferred,
PUINT32 bytes_transferred, remote::file_info *file_info) -> packet::error_type {
remote::file_info *file_info)
-> packet::error_type {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
auto *handle = reinterpret_cast<HANDLE>(file_desc); auto *handle = reinterpret_cast<HANDLE>(file_desc);

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifdef _WIN32 #if defined(_WIN32)
#include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp" #include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp"
@ -124,8 +124,8 @@ auto remote_winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, UINT32 attributes, UINT32 granted_access, UINT32 attributes,
PSECURITY_DESCRIPTOR /*descriptor*/, PSECURITY_DESCRIPTOR /*descriptor*/,
UINT64 allocation_size, PVOID * /*file_node*/, UINT64 allocation_size, PVOID * /*file_node*/,
PVOID *file_desc, OpenFileInfo *ofi) PVOID *file_desc,
-> NTSTATUS { OpenFileInfo *ofi) -> NTSTATUS {
remote::file_info fi{}; remote::file_info fi{};
std::string normalized_name; std::string normalized_name;
BOOLEAN exists = 0; BOOLEAN exists = 0;
@ -159,10 +159,9 @@ auto remote_winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc,
return ret; return ret;
} }
auto remote_winfsp_drive::GetSecurityByName(PWSTR file_name, PUINT32 attributes, auto remote_winfsp_drive::GetSecurityByName(
PSECURITY_DESCRIPTOR descriptor, PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor,
SIZE_T *descriptor_size) SIZE_T *descriptor_size) -> NTSTATUS {
-> NTSTATUS {
std::wstring string_descriptor; std::wstring string_descriptor;
std::uint64_t sds = descriptor_size ? *descriptor_size : 0; std::uint64_t sds = descriptor_size ? *descriptor_size : 0;
auto ret = remote_instance_->winfsp_get_security_by_name( auto ret = remote_instance_->winfsp_get_security_by_name(
@ -278,8 +277,8 @@ auto remote_winfsp_drive::Mounted(PVOID host) -> NTSTATUS {
auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options, auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID * /*file_node*/, UINT32 granted_access, PVOID * /*file_node*/,
PVOID *file_desc, OpenFileInfo *ofi) PVOID *file_desc,
-> NTSTATUS { OpenFileInfo *ofi) -> NTSTATUS {
remote::file_info fi{}; remote::file_info fi{};
std::string normalize_name; std::string normalize_name;
const auto ret = const auto ret =
@ -299,8 +298,8 @@ auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
auto remote_winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc, auto remote_winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
UINT32 attributes, UINT32 attributes,
BOOLEAN replace_attributes, BOOLEAN replace_attributes,
UINT64 allocation_size, FileInfo *file_info) UINT64 allocation_size,
-> NTSTATUS { FileInfo *file_info) -> NTSTATUS {
remote::file_info fi{}; remote::file_info fi{};
const auto ret = remote_instance_->winfsp_overwrite( const auto ret = remote_instance_->winfsp_overwrite(
file_desc, attributes, replace_attributes, allocation_size, &fi); file_desc, attributes, replace_attributes, allocation_size, &fi);
@ -414,8 +413,8 @@ auto remote_winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc,
UINT32 attributes, UINT64 creation_time, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_access_time,
UINT64 last_write_time, UINT64 last_write_time,
UINT64 change_time, FileInfo *file_info) UINT64 change_time,
-> NTSTATUS { FileInfo *file_info) -> NTSTATUS {
remote::file_info fi{}; remote::file_info fi{};
const auto ret = remote_instance_->winfsp_set_basic_info( const auto ret = remote_instance_->winfsp_set_basic_info(
file_desc, attributes, creation_time, last_access_time, last_write_time, file_desc, attributes, creation_time, last_access_time, last_write_time,
@ -467,8 +466,8 @@ VOID remote_winfsp_drive::Unmounted(PVOID host) {
auto remote_winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc, auto remote_winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc,
PVOID buffer, UINT64 offset, ULONG length, PVOID buffer, UINT64 offset, ULONG length,
BOOLEAN write_to_end, BOOLEAN constrained_io, BOOLEAN write_to_end, BOOLEAN constrained_io,
PULONG bytes_transferred, FileInfo *file_info) PULONG bytes_transferred,
-> NTSTATUS { FileInfo *file_info) -> NTSTATUS {
remote::file_info fi{}; remote::file_info fi{};
const auto ret = remote_instance_->winfsp_write( const auto ret = remote_instance_->winfsp_write(
file_desc, buffer, offset, length, write_to_end, constrained_io, file_desc, buffer, offset, length, write_to_end, constrained_io,

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifdef _WIN32 #if defined(_WIN32)
#include "drives/winfsp/winfsp_drive.hpp" #include "drives/winfsp/winfsp_drive.hpp"

View File

@ -171,7 +171,7 @@ void logging_consumer::process_event(const event &event) {
void logging_consumer::reopen_log_file() { void logging_consumer::reopen_log_file() {
close_log_file(); close_log_file();
#ifdef _WIN32 #if defined(_WIN32)
log_file_ = _fsopen(&log_path_[0], "a+", _SH_DENYWR); log_file_ = _fsopen(&log_path_[0], "a+", _SH_DENYWR);
#else #else
log_file_ = fopen(&log_path_[0], "a+"); log_file_ = fopen(&log_path_[0], "a+");

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef _WIN32 #if !defined(_WIN32)
#include "platform/unix_platform.hpp" #include "platform/unix_platform.hpp"
@ -91,7 +91,7 @@ auto lock_data::get_mount_state(json &mount_state) -> bool {
} }
auto lock_data::get_state_directory() -> std::string { auto lock_data::get_state_directory() -> std::string {
#ifdef __APPLE__ #if defined(__APPLE__)
return utils::path::resolve("~/Library/Application Support/" + return utils::path::resolve("~/Library/Application Support/" +
std::string(REPERTORY_DATA_NAME) + "/state"); std::string(REPERTORY_DATA_NAME) + "/state");
#else #else

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifdef _WIN32 #if defined(_WIN32)
#include "platform/win32_platform.hpp" #include "platform/win32_platform.hpp"
@ -27,8 +27,8 @@
#include "utils/error_utils.hpp" #include "utils/error_utils.hpp"
namespace repertory { namespace repertory {
auto lock_data::get_mount_state(const provider_type & /*pt*/, json &mount_state) auto lock_data::get_mount_state(const provider_type & /*pt*/,
-> bool { json &mount_state) -> bool {
const auto ret = get_mount_state(mount_state); const auto ret = get_mount_state(mount_state);
if (ret) { if (ret) {
const auto mount_id = const auto mount_id =

View File

@ -66,11 +66,10 @@ const std::map<std::string, std::string> sql_create_tables = {
namespace repertory { namespace repertory {
encrypt_provider::encrypt_provider(app_config &config) : config_(config) {} encrypt_provider::encrypt_provider(app_config &config) : config_(config) {}
auto encrypt_provider::create_api_file(const std::string &api_path, auto encrypt_provider::create_api_file(
bool directory, const std::string &api_path, bool directory,
const std::string &source_path) const std::string &source_path) -> api_file {
-> api_file { #if defined(_WIN32)
#ifdef _WIN32
struct _stat64 buf {}; struct _stat64 buf {};
_stat64(source_path.c_str(), &buf); _stat64(source_path.c_str(), &buf);
#else #else
@ -87,7 +86,7 @@ auto encrypt_provider::create_api_file(const std::string &api_path,
: utils::encryption::encrypting_reader::calculate_encrypted_size( : utils::encryption::encrypting_reader::calculate_encrypted_size(
source_path); source_path);
file.source_path = source_path; file.source_path = source_path;
#ifdef __APPLE__ #if defined(__APPLE__)
file.changed_date = file.changed_date =
buf.st_ctimespec.tv_nsec + (buf.st_ctimespec.tv_sec * NANOS_PER_SECOND); buf.st_ctimespec.tv_nsec + (buf.st_ctimespec.tv_sec * NANOS_PER_SECOND);
file.accessed_date = file.accessed_date =
@ -96,7 +95,7 @@ auto encrypt_provider::create_api_file(const std::string &api_path,
(buf.st_birthtimespec.tv_sec * NANOS_PER_SECOND); (buf.st_birthtimespec.tv_sec * NANOS_PER_SECOND);
file.modified_date = file.modified_date =
buf.st_mtimespec.tv_nsec + (buf.st_mtimespec.tv_sec * NANOS_PER_SECOND); buf.st_mtimespec.tv_nsec + (buf.st_mtimespec.tv_sec * NANOS_PER_SECOND);
#elif _WIN32 #elif defined(_WIN32)
FILETIME ft{}; FILETIME ft{};
utils::unix_time_to_filetime(utils::time64_to_unix_time(buf.st_atime), ft); utils::unix_time_to_filetime(utils::time64_to_unix_time(buf.st_atime), ft);
file.accessed_date = file.accessed_date =
@ -129,7 +128,7 @@ auto encrypt_provider::create_api_file(const std::string &api_path,
void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory, void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory,
const api_file &file) { const api_file &file) {
#ifdef _WIN32 #if defined(_WIN32)
struct _stat64 buf {}; struct _stat64 buf {};
_stat64(file.source_path.c_str(), &buf); _stat64(file.source_path.c_str(), &buf);
#else #else
@ -138,11 +137,11 @@ void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory,
#endif #endif
meta[META_ACCESSED] = std::to_string(file.accessed_date); meta[META_ACCESSED] = std::to_string(file.accessed_date);
#ifdef _WIN32 #if defined(_WIN32)
meta[META_ATTRIBUTES] = meta[META_ATTRIBUTES] =
std::to_string(::GetFileAttributesA(file.source_path.c_str())); std::to_string(::GetFileAttributesA(file.source_path.c_str()));
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
meta[META_BACKUP]; meta[META_BACKUP];
#endif #endif
meta[META_CHANGED] = std::to_string(file.changed_date); meta[META_CHANGED] = std::to_string(file.changed_date);
@ -151,7 +150,7 @@ void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory,
meta[META_GID] = std::to_string(buf.st_gid); meta[META_GID] = std::to_string(buf.st_gid);
meta[META_MODE] = std::to_string(buf.st_mode); meta[META_MODE] = std::to_string(buf.st_mode);
meta[META_MODIFIED] = std::to_string(file.modified_date); meta[META_MODIFIED] = std::to_string(file.modified_date);
#ifdef __APPLE__ #if defined(__APPLE__)
meta[META_OSXFLAGS]; meta[META_OSXFLAGS];
#endif #endif
meta[META_SIZE] = std::to_string(file.file_size); meta[META_SIZE] = std::to_string(file.file_size);
@ -214,9 +213,8 @@ auto encrypt_provider::do_fs_operation(
return callback(cfg, source_path); return callback(cfg, source_path);
} }
auto encrypt_provider::get_api_path_from_source(const std::string &source_path, auto encrypt_provider::get_api_path_from_source(
std::string &api_path) const const std::string &source_path, std::string &api_path) const -> api_error {
-> api_error {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
try { try {
@ -284,9 +282,8 @@ auto encrypt_provider::get_directory_item_count(
return count; return count;
} }
auto encrypt_provider::get_directory_items(const std::string &api_path, auto encrypt_provider::get_directory_items(
directory_item_list &list) const const std::string &api_path, directory_item_list &list) const -> api_error {
-> api_error {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
return do_fs_operation( return do_fs_operation(
@ -446,9 +443,8 @@ auto encrypt_provider::get_file_list(api_file_list &list) const -> api_error {
return api_error::error; return api_error::error;
} }
auto encrypt_provider::get_file_size(const std::string &api_path, auto encrypt_provider::get_file_size(
std::uint64_t &file_size) const const std::string &api_path, std::uint64_t &file_size) const -> api_error {
-> api_error {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__); constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
try { try {
@ -474,10 +470,9 @@ auto encrypt_provider::get_file_size(const std::string &api_path,
return api_error::error; return api_error::error;
} }
auto encrypt_provider::get_filesystem_item(const std::string &api_path, auto encrypt_provider::get_filesystem_item(
bool directory, const std::string &api_path, bool directory,
filesystem_item &fsi) const filesystem_item &fsi) const -> api_error {
-> api_error {
auto result = db::db_select{*db_, source_table} auto result = db::db_select{*db_, source_table}
.column("source_path") .column("source_path")
.where("api_path") .where("api_path")
@ -553,10 +548,9 @@ auto encrypt_provider::get_filesystem_item_from_source_path(
return get_filesystem_item(api_path, false, fsi); return get_filesystem_item(api_path, false, fsi);
} }
auto encrypt_provider::get_filesystem_item_and_file(const std::string &api_path, auto encrypt_provider::get_filesystem_item_and_file(
api_file &file, const std::string &api_path, api_file &file,
filesystem_item &fsi) const filesystem_item &fsi) const -> api_error {
-> api_error {
bool exists{}; bool exists{};
auto res = is_directory(api_path, exists); auto res = is_directory(api_path, exists);
if (res != api_error::success) { if (res != api_error::success) {
@ -658,8 +652,8 @@ auto encrypt_provider::is_directory(const std::string &api_path,
return api_error::success; return api_error::success;
} }
auto encrypt_provider::is_file(const std::string &api_path, bool &exists) const auto encrypt_provider::is_file(const std::string &api_path,
-> api_error { bool &exists) const -> api_error {
auto result = db::db_select{*db_, source_table} auto result = db::db_select{*db_, source_table}
.column("source_path") .column("source_path")
.where("api_path") .where("api_path")

View File

@ -22,7 +22,7 @@
#include "types/remote.hpp" #include "types/remote.hpp"
namespace repertory::remote { namespace repertory::remote {
#ifndef _WIN32 #if !defined(_WIN32)
auto create_open_flags(std::uint32_t flags) -> open_flags { auto create_open_flags(std::uint32_t flags) -> open_flags {
open_flags ret{}; open_flags ret{};
{ {
@ -42,25 +42,25 @@ auto create_open_flags(std::uint32_t flags) -> open_flags {
set_if_has_flag(O_ASYNC, open_flags::async); set_if_has_flag(O_ASYNC, open_flags::async);
set_if_has_flag(O_CLOEXEC, open_flags::clo_exec); set_if_has_flag(O_CLOEXEC, open_flags::clo_exec);
set_if_has_flag(O_CREAT, open_flags::create); set_if_has_flag(O_CREAT, open_flags::create);
#ifdef O_DIRECT #if defined(O_DIRECT)
set_if_has_flag(O_DIRECT, open_flags::direct); set_if_has_flag(O_DIRECT, open_flags::direct);
#endif #endif
set_if_has_flag(O_DIRECTORY, open_flags::directory); set_if_has_flag(O_DIRECTORY, open_flags::directory);
#ifdef O_DSYNC #if defined(O_DSYNC)
set_if_has_flag(O_DSYNC, open_flags::dsync); set_if_has_flag(O_DSYNC, open_flags::dsync);
#endif #endif
set_if_has_flag(O_EXCL, open_flags::excl); set_if_has_flag(O_EXCL, open_flags::excl);
#ifdef O_NOATIME #if defined(O_NOATIME)
set_if_has_flag(O_NOATIME, open_flags::no_atime); set_if_has_flag(O_NOATIME, open_flags::no_atime);
#endif #endif
set_if_has_flag(O_NOCTTY, open_flags::no_ctty); set_if_has_flag(O_NOCTTY, open_flags::no_ctty);
set_if_has_flag(O_NOFOLLOW, open_flags::no_follow); set_if_has_flag(O_NOFOLLOW, open_flags::no_follow);
set_if_has_flag(O_NONBLOCK, open_flags::non_blocking); set_if_has_flag(O_NONBLOCK, open_flags::non_blocking);
#ifdef O_PATH #if defined(O_PATH)
set_if_has_flag(O_PATH, open_flags::path); set_if_has_flag(O_PATH, open_flags::path);
#endif #endif
set_if_has_flag(O_SYNC, open_flags::sync); set_if_has_flag(O_SYNC, open_flags::sync);
#ifdef O_TMPFILE #if defined(O_TMPFILE)
set_if_has_flag(O_TMPFILE, open_flags::temp_file); set_if_has_flag(O_TMPFILE, open_flags::temp_file);
#endif #endif
set_if_has_flag(O_TRUNC, open_flags::truncate); set_if_has_flag(O_TRUNC, open_flags::truncate);
@ -89,25 +89,25 @@ auto create_os_open_flags(const open_flags &flags) -> std::uint32_t {
set_if_has_flag(open_flags::async, O_ASYNC); set_if_has_flag(open_flags::async, O_ASYNC);
set_if_has_flag(open_flags::clo_exec, O_CLOEXEC); set_if_has_flag(open_flags::clo_exec, O_CLOEXEC);
set_if_has_flag(open_flags::create, O_CREAT); set_if_has_flag(open_flags::create, O_CREAT);
#ifdef O_DIRECT #if defined(O_DIRECT)
set_if_has_flag(open_flags::direct, O_DIRECT); set_if_has_flag(open_flags::direct, O_DIRECT);
#endif #endif
set_if_has_flag(open_flags::directory, O_DIRECTORY); set_if_has_flag(open_flags::directory, O_DIRECTORY);
#ifdef O_DSYNC #if defined(O_DSYNC)
set_if_has_flag(open_flags::dsync, O_DSYNC); set_if_has_flag(open_flags::dsync, O_DSYNC);
#endif #endif
set_if_has_flag(open_flags::excl, O_EXCL); set_if_has_flag(open_flags::excl, O_EXCL);
#ifdef O_NOATIME #if defined(O_NOATIME)
set_if_has_flag(open_flags::no_atime, O_NOATIME); set_if_has_flag(open_flags::no_atime, O_NOATIME);
#endif #endif
set_if_has_flag(open_flags::no_ctty, O_NOCTTY); set_if_has_flag(open_flags::no_ctty, O_NOCTTY);
set_if_has_flag(open_flags::no_follow, O_NOFOLLOW); set_if_has_flag(open_flags::no_follow, O_NOFOLLOW);
set_if_has_flag(open_flags::non_blocking, O_NONBLOCK); set_if_has_flag(open_flags::non_blocking, O_NONBLOCK);
#ifdef O_PATH #if defined(O_PATH)
set_if_has_flag(open_flags::path, O_PATH); set_if_has_flag(open_flags::path, O_PATH);
#endif #endif
set_if_has_flag(open_flags::sync, O_SYNC); set_if_has_flag(open_flags::sync, O_SYNC);
#ifdef O_TMPFILE #if defined(O_TMPFILE)
set_if_has_flag(open_flags::temp_file, O_TMPFILE); set_if_has_flag(open_flags::temp_file, O_TMPFILE);
#endif #endif
set_if_has_flag(open_flags::truncate, O_TRUNC); set_if_has_flag(open_flags::truncate, O_TRUNC);

View File

@ -50,8 +50,8 @@ void get_api_authentication_data(std::string &user, std::string &password,
} }
} }
[[nodiscard]] auto get_provider_type_from_args(std::vector<const char *> args) [[nodiscard]] auto
-> provider_type { get_provider_type_from_args(std::vector<const char *> args) -> provider_type {
#if defined(REPERTORY_ENABLE_S3) #if defined(REPERTORY_ENABLE_S3)
if (has_option(args, options::s3_option)) { if (has_option(args, options::s3_option)) {
return provider_type::s3; return provider_type::s3;
@ -67,8 +67,8 @@ void get_api_authentication_data(std::string &user, std::string &password,
return provider_type::sia; return provider_type::sia;
} }
auto has_option(std::vector<const char *> args, const std::string &option_name) auto has_option(std::vector<const char *> args,
-> bool { const std::string &option_name) -> bool {
return std::find_if(args.begin(), args.end(), return std::find_if(args.begin(), args.end(),
[&option_name](const auto &value) -> bool { [&option_name](const auto &value) -> bool {
return option_name == value; return option_name == value;
@ -80,8 +80,8 @@ auto has_option(std::vector<const char *> args, const option &opt) -> bool {
} }
auto parse_option(std::vector<const char *> args, auto parse_option(std::vector<const char *> args,
const std::string &option_name, std::uint8_t count) const std::string &option_name,
-> std::vector<std::string> { std::uint8_t count) -> std::vector<std::string> {
std::vector<std::string> ret; std::vector<std::string> ret;
auto found{false}; auto found{false};
for (std::size_t i = 0U; not found && (i < args.size()); i++) { for (std::size_t i = 0U; not found && (i < args.size()); i++) {
@ -119,10 +119,9 @@ auto parse_string_option(std::vector<const char *> args, const option &opt,
return ret; return ret;
} }
auto parse_drive_options(std::vector<const char *> args, auto parse_drive_options(
[[maybe_unused]] provider_type &prov, std::vector<const char *> args, [[maybe_unused]] provider_type &prov,
[[maybe_unused]] std::string &data_directory) [[maybe_unused]] std::string &data_directory) -> std::vector<std::string> {
-> std::vector<std::string> {
// Strip out options from command line // Strip out options from command line
const auto &option_list = options::option_list; const auto &option_list = options::option_list;
std::vector<std::string> drive_args; std::vector<std::string> drive_args;
@ -140,7 +139,7 @@ auto parse_drive_options(std::vector<const char *> args,
(std::string(args.at(i)) == options::remote_mount_option.at(1U)) || (std::string(args.at(i)) == options::remote_mount_option.at(1U)) ||
(std::string(args.at(i)) == options::data_directory_option.at(0U)) || (std::string(args.at(i)) == options::data_directory_option.at(0U)) ||
(std::string(args.at(i)) == options::data_directory_option.at(1U)) (std::string(args.at(i)) == options::data_directory_option.at(1U))
#ifdef REPERTORY_ENABLE_S3 #if defined(REPERTORY_ENABLE_S3)
|| (std::string(args.at(i)) == options::name_option.at(0U)) || || (std::string(args.at(i)) == options::name_option.at(0U)) ||
(std::string(args.at(i)) == options::name_option.at(1U)) (std::string(args.at(i)) == options::name_option.at(1U))
#endif // REPERTORY_ENABLE_S3 #endif // REPERTORY_ENABLE_S3
@ -150,7 +149,7 @@ auto parse_drive_options(std::vector<const char *> args,
} }
} }
#ifndef _WIN32 #if !defined(_WIN32)
std::vector<std::string> fuse_flags_list; std::vector<std::string> fuse_flags_list;
for (std::size_t i = 1; i < drive_args.size(); i++) { for (std::size_t i = 1; i < drive_args.size(); i++) {
if (drive_args.at(i).find("-o") == 0) { if (drive_args.at(i).find("-o") == 0) {
@ -219,7 +218,7 @@ auto parse_drive_options(std::vector<const char *> args,
} }
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
{ {
auto it = std::remove_if( auto it = std::remove_if(
fuse_flags_list.begin(), fuse_flags_list.end(), fuse_flags_list.begin(), fuse_flags_list.end(),

View File

@ -31,7 +31,7 @@ namespace repertory::utils::file {
auto calculate_used_space(std::string path, bool recursive) -> std::uint64_t { auto calculate_used_space(std::string path, bool recursive) -> std::uint64_t {
path = utils::path::absolute(path); path = utils::path::absolute(path);
std::uint64_t ret{}; std::uint64_t ret{};
#ifdef _WIN32 #if defined(_WIN32)
WIN32_FIND_DATA fd{}; WIN32_FIND_DATA fd{};
const auto search = utils::path::combine(path, {"*.*"}); const auto search = utils::path::combine(path, {"*.*"});
auto find = ::FindFirstFile(search.c_str(), &fd); auto find = ::FindFirstFile(search.c_str(), &fd);
@ -79,7 +79,7 @@ auto calculate_used_space(std::string path, bool recursive) -> std::uint64_t {
} }
void change_to_process_directory() { void change_to_process_directory() {
#ifdef _WIN32 #if defined(_WIN32)
std::string file_name; std::string file_name;
file_name.resize(MAX_PATH); file_name.resize(MAX_PATH);
::GetModuleFileNameA(nullptr, &file_name[0u], ::GetModuleFileNameA(nullptr, &file_name[0u],
@ -91,7 +91,7 @@ void change_to_process_directory() {
#else #else
std::string path; std::string path;
path.resize(PATH_MAX + 1); path.resize(PATH_MAX + 1);
#ifdef __APPLE__ #if defined(__APPLE__)
proc_pidpath(getpid(), &path[0u], path.size()); proc_pidpath(getpid(), &path[0u], path.size());
#else #else
readlink("/proc/self/exe", &path[0u], path.size()); readlink("/proc/self/exe", &path[0u], path.size());
@ -111,13 +111,13 @@ auto copy_file(std::string from_path, std::string to_path) -> bool {
return false; return false;
} }
auto copy_directory_recursively(std::string from_path, std::string to_path) auto copy_directory_recursively(std::string from_path,
-> bool { std::string to_path) -> bool {
from_path = utils::path::absolute(from_path); from_path = utils::path::absolute(from_path);
to_path = utils::path::absolute(to_path); to_path = utils::path::absolute(to_path);
auto ret = create_full_directory_path(to_path); auto ret = create_full_directory_path(to_path);
if (ret) { if (ret) {
#ifdef _WIN32 #if defined(_WIN32)
WIN32_FIND_DATA fd{}; WIN32_FIND_DATA fd{};
const auto search = utils::path::combine(from_path, {"*.*"}); const auto search = utils::path::combine(from_path, {"*.*"});
auto find = ::FindFirstFile(search.c_str(), &fd); auto find = ::FindFirstFile(search.c_str(), &fd);
@ -166,7 +166,7 @@ auto copy_directory_recursively(std::string from_path, std::string to_path)
} }
auto create_full_directory_path(std::string path) -> bool { auto create_full_directory_path(std::string path) -> bool {
#ifdef _WIN32 #if defined(_WIN32)
const auto unicode_path = const auto unicode_path =
utils::string::from_utf8(utils::path::absolute(path)); utils::string::from_utf8(utils::path::absolute(path));
return is_directory(path) || return is_directory(path) ||
@ -196,7 +196,7 @@ auto delete_directory(std::string path, bool recursive) -> bool {
} }
path = utils::path::absolute(path); path = utils::path::absolute(path);
#ifdef _WIN32 #if defined(_WIN32)
return (not is_directory(path) || utils::retryable_action([&]() -> bool { return (not is_directory(path) || utils::retryable_action([&]() -> bool {
return !!::RemoveDirectoryA(path.c_str()); return !!::RemoveDirectoryA(path.c_str());
})); }));
@ -207,7 +207,7 @@ auto delete_directory(std::string path, bool recursive) -> bool {
auto delete_directory_recursively(std::string path) -> bool { auto delete_directory_recursively(std::string path) -> bool {
path = utils::path::absolute(path); path = utils::path::absolute(path);
#ifdef _WIN32 #if defined(_WIN32)
WIN32_FIND_DATA fd{}; WIN32_FIND_DATA fd{};
const auto search = utils::path::combine(path, {"*.*"}); const auto search = utils::path::combine(path, {"*.*"});
@ -253,7 +253,7 @@ auto delete_directory_recursively(std::string path) -> bool {
auto delete_file(std::string path) -> bool { auto delete_file(std::string path) -> bool {
path = utils::path::absolute(path); path = utils::path::absolute(path);
#ifdef _WIN32 #if defined(_WIN32)
return (not is_file(path) || utils::retryable_action([&]() -> bool { return (not is_file(path) || utils::retryable_action([&]() -> bool {
const auto ret = !!::DeleteFileA(path.c_str()); const auto ret = !!::DeleteFileA(path.c_str());
if (not ret) { if (not ret) {
@ -314,12 +314,12 @@ auto generate_sha256(const std::string &file_path) -> std::string {
} }
auto get_free_drive_space(const std::string &path) -> std::uint64_t { auto get_free_drive_space(const std::string &path) -> std::uint64_t {
#ifdef _WIN32 #if defined(_WIN32)
ULARGE_INTEGER li{}; ULARGE_INTEGER li{};
::GetDiskFreeSpaceEx(path.c_str(), &li, nullptr, nullptr); ::GetDiskFreeSpaceEx(path.c_str(), &li, nullptr, nullptr);
return li.QuadPart; return li.QuadPart;
#endif #endif
#ifdef __linux__ #if defined(__linux__)
std::uint64_t ret = 0; std::uint64_t ret = 0;
struct statfs64 st {}; struct statfs64 st {};
if (statfs64(path.c_str(), &st) == 0) { if (statfs64(path.c_str(), &st) == 0) {
@ -327,7 +327,7 @@ auto get_free_drive_space(const std::string &path) -> std::uint64_t {
} }
return ret; return ret;
#endif #endif
#if __APPLE__ #if defined(__APPLE__)
struct statvfs st {}; struct statvfs st {};
statvfs(path.c_str(), &st); statvfs(path.c_str(), &st);
return st.f_bfree * st.f_frsize; return st.f_bfree * st.f_frsize;
@ -335,12 +335,12 @@ auto get_free_drive_space(const std::string &path) -> std::uint64_t {
} }
auto get_total_drive_space(const std::string &path) -> std::uint64_t { auto get_total_drive_space(const std::string &path) -> std::uint64_t {
#ifdef _WIN32 #if defined(_WIN32)
ULARGE_INTEGER li{}; ULARGE_INTEGER li{};
::GetDiskFreeSpaceEx(path.c_str(), nullptr, &li, nullptr); ::GetDiskFreeSpaceEx(path.c_str(), nullptr, &li, nullptr);
return li.QuadPart; return li.QuadPart;
#endif #endif
#ifdef __linux__ #if defined(__linux__)
std::uint64_t ret = 0; std::uint64_t ret = 0;
struct statfs64 st {}; struct statfs64 st {};
if (statfs64(path.c_str(), &st) == 0) { if (statfs64(path.c_str(), &st) == 0) {
@ -348,19 +348,19 @@ auto get_total_drive_space(const std::string &path) -> std::uint64_t {
} }
return ret; return ret;
#endif #endif
#if __APPLE__ #if defined(__APPLE__)
struct statvfs st {}; struct statvfs st {};
statvfs(path.c_str(), &st); statvfs(path.c_str(), &st);
return st.f_blocks * st.f_frsize; return st.f_blocks * st.f_frsize;
#endif #endif
} }
auto get_directory_files(std::string path, bool oldest_first, bool recursive) auto get_directory_files(std::string path, bool oldest_first,
-> std::deque<std::string> { bool recursive) -> std::deque<std::string> {
path = utils::path::absolute(path); path = utils::path::absolute(path);
std::deque<std::string> ret; std::deque<std::string> ret;
std::unordered_map<std::string, std::uint64_t> lookup; std::unordered_map<std::string, std::uint64_t> lookup;
#ifdef _WIN32 #if defined(_WIN32)
WIN32_FIND_DATA fd{}; WIN32_FIND_DATA fd{};
const auto search = utils::path::combine(path, {"*.*"}); const auto search = utils::path::combine(path, {"*.*"});
auto find = ::FindFirstFile(search.c_str(), &fd); auto find = ::FindFirstFile(search.c_str(), &fd);
@ -411,7 +411,7 @@ auto get_directory_files(std::string path, bool oldest_first, bool recursive)
if (lookup.find(lookup_path) == lookup.end()) { if (lookup.find(lookup_path) == lookup.end()) {
struct stat st {}; struct stat st {};
stat(lookup_path.c_str(), &st); stat(lookup_path.c_str(), &st);
#ifdef __APPLE__ #if defined(__APPLE__)
lookup[lookup_path] = static_cast<std::uint64_t>( lookup[lookup_path] = static_cast<std::uint64_t>(
(st.st_mtimespec.tv_sec * NANOS_PER_SECOND) + (st.st_mtimespec.tv_sec * NANOS_PER_SECOND) +
st.st_mtimespec.tv_nsec); st.st_mtimespec.tv_nsec);
@ -433,18 +433,18 @@ auto get_directory_files(std::string path, bool oldest_first, bool recursive)
return ret; return ret;
} }
auto get_accessed_time(const std::string &path, std::uint64_t &accessed) auto get_accessed_time(const std::string &path,
-> bool { std::uint64_t &accessed) -> bool {
auto ret = false; auto ret = false;
accessed = 0; accessed = 0;
#ifdef _WIN32 #if defined(_WIN32)
struct _stat64 st {}; struct _stat64 st {};
if (_stat64(path.c_str(), &st) != -1) { if (_stat64(path.c_str(), &st) != -1) {
accessed = static_cast<uint64_t>(st.st_atime); accessed = static_cast<uint64_t>(st.st_atime);
#else #else
struct stat st {}; struct stat st {};
if (stat(path.c_str(), &st) != -1) { if (stat(path.c_str(), &st) != -1) {
#ifdef __APPLE__ #if defined(__APPLE__)
accessed = static_cast<uint64_t>( accessed = static_cast<uint64_t>(
st.st_atimespec.tv_nsec + (st.st_atimespec.tv_sec * NANOS_PER_SECOND)); st.st_atimespec.tv_nsec + (st.st_atimespec.tv_sec * NANOS_PER_SECOND));
#else #else
@ -458,18 +458,18 @@ auto get_accessed_time(const std::string &path, std::uint64_t &accessed)
return ret; return ret;
} }
auto get_modified_time(const std::string &path, std::uint64_t &modified) auto get_modified_time(const std::string &path,
-> bool { std::uint64_t &modified) -> bool {
auto ret = false; auto ret = false;
modified = 0u; modified = 0u;
#ifdef _WIN32 #if defined(_WIN32)
struct _stat64 st {}; struct _stat64 st {};
if (_stat64(path.c_str(), &st) != -1) { if (_stat64(path.c_str(), &st) != -1) {
modified = static_cast<uint64_t>(st.st_mtime); modified = static_cast<uint64_t>(st.st_mtime);
#else #else
struct stat st {}; struct stat st {};
if (stat(path.c_str(), &st) != -1) { if (stat(path.c_str(), &st) != -1) {
#ifdef __APPLE__ #if defined(__APPLE__)
modified = static_cast<uint64_t>( modified = static_cast<uint64_t>(
st.st_mtimespec.tv_nsec + (st.st_mtimespec.tv_sec * NANOS_PER_SECOND)); st.st_mtimespec.tv_nsec + (st.st_mtimespec.tv_sec * NANOS_PER_SECOND));
#else #else
@ -487,11 +487,11 @@ auto get_file_size(std::string path, std::uint64_t &file_size) -> bool {
file_size = 0u; file_size = 0u;
path = utils::path::finalize(path); path = utils::path::finalize(path);
#ifdef _WIN32 #if defined(_WIN32)
struct _stat64 st {}; struct _stat64 st {};
if (_stat64(path.c_str(), &st) != 0) { if (_stat64(path.c_str(), &st) != 0) {
#else #else
#if __APPLE__ #if defined(__APPLE__)
struct stat st {}; struct stat st {};
if (stat(path.c_str(), &st) != 0) { if (stat(path.c_str(), &st) != 0) {
#else #else
@ -510,7 +510,7 @@ auto get_file_size(std::string path, std::uint64_t &file_size) -> bool {
} }
auto is_directory(const std::string &path) -> bool { auto is_directory(const std::string &path) -> bool {
#ifdef _WIN32 #if defined(_WIN32)
return ::PathIsDirectory(path.c_str()) != 0; return ::PathIsDirectory(path.c_str()) != 0;
#else #else
struct stat st {}; struct stat st {};
@ -519,7 +519,7 @@ auto is_directory(const std::string &path) -> bool {
} }
auto is_file(const std::string &path) -> bool { auto is_file(const std::string &path) -> bool {
#ifdef _WIN32 #if defined(_WIN32)
return (::PathFileExists(path.c_str()) && return (::PathFileExists(path.c_str()) &&
not ::PathIsDirectory(path.c_str())); not ::PathIsDirectory(path.c_str()));
#else #else
@ -535,7 +535,7 @@ auto is_modified_date_older_than(const std::string &path,
if (get_modified_time(path, modified)) { if (get_modified_time(path, modified)) {
const auto seconds = const auto seconds =
std::chrono::duration_cast<std::chrono::seconds>(hours); std::chrono::duration_cast<std::chrono::seconds>(hours);
#ifdef _WIN32 #if defined(_WIN32)
return (std::chrono::system_clock::from_time_t( return (std::chrono::system_clock::from_time_t(
static_cast<time_t>(modified)) + static_cast<time_t>(modified)) +
seconds) < std::chrono::system_clock::now(); seconds) < std::chrono::system_clock::now();
@ -557,7 +557,7 @@ auto move_file(std::string from, std::string to) -> bool {
return false; return false;
} }
#ifdef _WIN32 #if defined(_WIN32)
const bool ret = ::MoveFile(from.c_str(), to.c_str()) != 0; const bool ret = ::MoveFile(from.c_str(), to.c_str()) != 0;
#else #else
const bool ret = (rename(from.c_str(), to.c_str()) == 0); const bool ret = (rename(from.c_str(), to.c_str()) == 0);
@ -616,7 +616,7 @@ auto read_json_file(const std::string &path, json &data) -> bool {
auto reset_modified_time(const std::string &path) -> bool { auto reset_modified_time(const std::string &path) -> bool {
auto ret = false; auto ret = false;
#ifdef _WIN32 #if defined(_WIN32)
SYSTEMTIME st{}; SYSTEMTIME st{};
::GetSystemTime(&st); ::GetSystemTime(&st);

View File

@ -38,14 +38,14 @@ native_file::~native_file() {
auto native_file::clone(const native_file_ptr &ptr) -> native_file_ptr { auto native_file::clone(const native_file_ptr &ptr) -> native_file_ptr {
std::string source_path; std::string source_path;
#ifdef _WIN32 #if defined(_WIN32)
source_path.resize(MAX_PATH + 1); source_path.resize(MAX_PATH + 1);
::GetFinalPathNameByHandleA(ptr->get_handle(), source_path.data(), ::GetFinalPathNameByHandleA(ptr->get_handle(), source_path.data(),
MAX_PATH + 1, MAX_PATH + 1,
FILE_NAME_NORMALIZED | VOLUME_NAME_DOS); FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
#else #else
source_path.resize(PATH_MAX + 1); source_path.resize(PATH_MAX + 1);
#ifdef __APPLE__ #if defined(__APPLE__)
fcntl(ptr->get_handle(), F_GETPATH, source_path.data()); fcntl(ptr->get_handle(), F_GETPATH, source_path.data());
#else #else
readlink(("/proc/self/fd/" + std::to_string(ptr->get_handle())).c_str(), readlink(("/proc/self/fd/" + std::to_string(ptr->get_handle())).c_str(),
@ -66,7 +66,7 @@ auto native_file::clone(const native_file_ptr &ptr) -> native_file_ptr {
auto native_file::create_or_open(const std::string &source_path, bool read_only, auto native_file::create_or_open(const std::string &source_path, bool read_only,
native_file_ptr &ptr) -> api_error { native_file_ptr &ptr) -> api_error {
#ifdef _WIN32 #if defined(_WIN32)
auto handle = auto handle =
read_only read_only
? ::CreateFileA(source_path.c_str(), GENERIC_READ, ? ::CreateFileA(source_path.c_str(), GENERIC_READ,
@ -94,14 +94,14 @@ auto native_file::create_or_open(const std::string &source_path,
return create_or_open(source_path, false, ptr); return create_or_open(source_path, false, ptr);
} }
auto native_file::open(const std::string &source_path, native_file_ptr &ptr) auto native_file::open(const std::string &source_path,
-> api_error { native_file_ptr &ptr) -> api_error {
return open(source_path, false, ptr); return open(source_path, false, ptr);
} }
auto native_file::open(const std::string &source_path, bool read_only, auto native_file::open(const std::string &source_path, bool read_only,
native_file_ptr &ptr) -> api_error { native_file_ptr &ptr) -> api_error {
#ifdef _WIN32 #if defined(_WIN32)
auto handle = auto handle =
read_only read_only
? ::CreateFileA(source_path.c_str(), GENERIC_READ, ? ::CreateFileA(source_path.c_str(), GENERIC_READ,
@ -123,23 +123,23 @@ auto native_file::open(const std::string &source_path, bool read_only,
} }
auto native_file::allocate(std::uint64_t file_size) -> bool { auto native_file::allocate(std::uint64_t file_size) -> bool {
#ifdef _WIN32 #if defined(_WIN32)
LARGE_INTEGER li{}; LARGE_INTEGER li{};
li.QuadPart = static_cast<LONGLONG>(file_size); li.QuadPart = static_cast<LONGLONG>(file_size);
return (::SetFilePointerEx(handle_, li, nullptr, FILE_BEGIN) && return (::SetFilePointerEx(handle_, li, nullptr, FILE_BEGIN) &&
::SetEndOfFile(handle_)); ::SetEndOfFile(handle_));
#endif #endif
#ifdef __linux__ #if defined(__linux__)
return (fallocate(handle_, 0, 0, static_cast<off_t>(file_size)) >= 0); return (fallocate(handle_, 0, 0, static_cast<off_t>(file_size)) >= 0);
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
return (ftruncate(handle_, file_size) >= 0); return (ftruncate(handle_, file_size) >= 0);
#endif #endif
} }
void native_file::close() { void native_file::close() {
if (handle_ != REPERTORY_INVALID_HANDLE) { if (handle_ != REPERTORY_INVALID_HANDLE) {
#ifdef WIN32 #if defined(_WIN32)
::CloseHandle(handle_); ::CloseHandle(handle_);
#else #else
::close(handle_); ::close(handle_);
@ -183,7 +183,7 @@ auto native_file::copy_from(const std::string &path) -> bool {
} }
void native_file::flush() { void native_file::flush() {
#ifdef _WIN32 #if defined(_WIN32)
recur_mutex_lock l(read_write_mutex_); recur_mutex_lock l(read_write_mutex_);
::FlushFileBuffers(handle_); ::FlushFileBuffers(handle_);
#else #else
@ -193,13 +193,13 @@ void native_file::flush() {
auto native_file::get_file_size(std::uint64_t &file_size) -> bool { auto native_file::get_file_size(std::uint64_t &file_size) -> bool {
auto ret = false; auto ret = false;
#ifdef _WIN32 #if defined(_WIN32)
LARGE_INTEGER li{}; LARGE_INTEGER li{};
if ((ret = ::GetFileSizeEx(handle_, &li) && (li.QuadPart >= 0))) { if ((ret = ::GetFileSizeEx(handle_, &li) && (li.QuadPart >= 0))) {
file_size = static_cast<std::uint64_t>(li.QuadPart); file_size = static_cast<std::uint64_t>(li.QuadPart);
} }
#else #else
#if __APPLE__ #if defined(__APPLE__)
struct stat unix_st {}; struct stat unix_st {};
if (fstat(handle_, &unix_st) >= 0) { if (fstat(handle_, &unix_st) >= 0) {
#else #else
@ -215,10 +215,10 @@ auto native_file::get_file_size(std::uint64_t &file_size) -> bool {
return ret; return ret;
} }
#ifdef _WIN32 #if defined(_WIN32)
auto native_file::read_bytes(char *buffer, std::size_t read_size, auto native_file::read_bytes(char *buffer, std::size_t read_size,
std::uint64_t read_offset, std::size_t &bytes_read) std::uint64_t read_offset,
-> bool { std::size_t &bytes_read) -> bool {
recur_mutex_lock l(read_write_mutex_); recur_mutex_lock l(read_write_mutex_);
auto ret = false; auto ret = false;
@ -244,8 +244,8 @@ auto native_file::read_bytes(char *buffer, std::size_t read_size,
} }
#else #else
auto native_file::read_bytes(char *buffer, std::size_t read_size, auto native_file::read_bytes(char *buffer, std::size_t read_size,
std::uint64_t read_offset, std::size_t &bytes_read) std::uint64_t read_offset,
-> bool { std::size_t &bytes_read) -> bool {
bytes_read = 0U; bytes_read = 0U;
ssize_t result = 0; ssize_t result = 0;
do { do {
@ -260,7 +260,7 @@ auto native_file::read_bytes(char *buffer, std::size_t read_size,
} }
#endif #endif
auto native_file::truncate(std::uint64_t file_size) -> bool { auto native_file::truncate(std::uint64_t file_size) -> bool {
#ifdef _WIN32 #if defined(_WIN32)
recur_mutex_lock l(read_write_mutex_); recur_mutex_lock l(read_write_mutex_);
LARGE_INTEGER li{}; LARGE_INTEGER li{};
li.QuadPart = static_cast<LONGLONG>(file_size); li.QuadPart = static_cast<LONGLONG>(file_size);
@ -271,7 +271,7 @@ auto native_file::truncate(std::uint64_t file_size) -> bool {
#endif #endif
} }
#ifdef _WIN32 #if defined(_WIN32)
auto native_file::write_bytes(const char *buffer, std::size_t write_size, auto native_file::write_bytes(const char *buffer, std::size_t write_size,
std::uint64_t write_offset, std::uint64_t write_offset,
std::size_t &bytes_written) -> bool { std::size_t &bytes_written) -> bool {

View File

@ -28,7 +28,7 @@
namespace repertory::utils::path { namespace repertory::utils::path {
auto absolute(std::string path) -> std::string { auto absolute(std::string path) -> std::string {
#ifdef _WIN32 #if defined(_WIN32)
if (not path.empty() && ::PathIsRelative(&path[0u])) { if (not path.empty() && ::PathIsRelative(&path[0u])) {
std::string temp; std::string temp;
temp.resize(MAX_PATH + 1); temp.resize(MAX_PATH + 1);
@ -56,8 +56,8 @@ auto absolute(std::string path) -> std::string {
return finalize(path); return finalize(path);
} }
auto combine(std::string path, const std::vector<std::string> &paths) auto combine(std::string path,
-> std::string { const std::vector<std::string> &paths) -> std::string {
return finalize( return finalize(
std::accumulate(paths.begin(), paths.end(), path, std::accumulate(paths.begin(), paths.end(), path,
[](std::string next_path, const auto &path_part) { [](std::string next_path, const auto &path_part) {
@ -97,7 +97,7 @@ auto finalize(std::string path) -> std::string {
path = path.substr(0u, path.size() - 1u); path = path.substr(0u, path.size() - 1u);
} }
#ifdef _WIN32 #if defined(_WIN32)
if ((path.size() >= 2u) && (path[1u] == ':')) { if ((path.size() >= 2u) && (path[1u] == ':')) {
path[0u] = utils::string::to_lower(std::string(1u, path[0u]))[0u]; path[0u] = utils::string::to_lower(std::string(1u, path[0u]))[0u];
} }
@ -129,7 +129,7 @@ auto get_parent_api_path(const std::string &path) -> std::string {
return ret; return ret;
} }
#ifndef _WIN32 #if !defined(_WIN32)
auto get_parent_directory(std::string path) -> std::string { auto get_parent_directory(std::string path) -> std::string {
auto ret = std::string(dirname(&path[0u])); auto ret = std::string(dirname(&path[0u]));
if (ret == ".") { if (ret == ".") {
@ -141,7 +141,7 @@ auto get_parent_directory(std::string path) -> std::string {
#endif #endif
auto is_ads_file_path([[maybe_unused]] const std::string &path) -> bool { auto is_ads_file_path([[maybe_unused]] const std::string &path) -> bool {
#ifdef _WIN32 #if defined(_WIN32)
return utils::string::contains(path, ":"); return utils::string::contains(path, ":");
#else #else
return false; return false;
@ -161,7 +161,7 @@ auto is_trash_directory(std::string path) -> bool {
auto remove_file_name(std::string path) -> std::string { auto remove_file_name(std::string path) -> std::string {
path = finalize(path); path = finalize(path);
#ifdef _WIN32 #if defined(_WIN32)
::PathRemoveFileSpec(&path[0u]); ::PathRemoveFileSpec(&path[0u]);
path = path.c_str(); path = path.c_str();
#else #else
@ -178,7 +178,7 @@ auto remove_file_name(std::string path) -> std::string {
return path; return path;
} }
#ifndef _WIN32 #if !defined(_WIN32)
auto resolve(std::string path) -> std::string { auto resolve(std::string path) -> std::string {
std::string home{}; std::string home{};
use_getpwuid(getuid(), [&home](struct passwd *pw) { use_getpwuid(getuid(), [&home](struct passwd *pw) {
@ -193,7 +193,7 @@ auto resolve(std::string path) -> std::string {
#endif #endif
auto strip_to_file_name(std::string path) -> std::string { auto strip_to_file_name(std::string path) -> std::string {
#ifdef _WIN32 #if defined(_WIN32)
return ::PathFindFileName(&path[0u]); return ::PathFindFileName(&path[0u]);
#else #else
return utils::string::contains(path, "/") ? basename(&path[0u]) : path; return utils::string::contains(path, "/") ? basename(&path[0u]) : path;

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef _WIN32 #if !defined(_WIN32)
#include "utils/unix/unix_utils.hpp" #include "utils/unix/unix_utils.hpp"
@ -27,7 +27,7 @@
#include "utils/utils.hpp" #include "utils/utils.hpp"
namespace repertory::utils { namespace repertory::utils {
#ifndef __APPLE__ #if !defined(__APPLE__)
auto convert_to_uint64(const pthread_t &thread) -> std::uint64_t { auto convert_to_uint64(const pthread_t &thread) -> std::uint64_t {
return static_cast<std::uint64_t>(thread); return static_cast<std::uint64_t>(thread);
} }
@ -48,7 +48,7 @@ auto from_api_error(const api_error &err) -> int {
case api_error::directory_not_found: case api_error::directory_not_found:
return -ENOTDIR; return -ENOTDIR;
case api_error::download_failed: case api_error::download_failed:
#ifdef __APPLE__ #if defined(__APPLE__)
return -EBADMSG; return -EBADMSG;
#else #else
return -EREMOTEIO; return -EREMOTEIO;
@ -84,13 +84,13 @@ auto from_api_error(const api_error &err) -> int {
case api_error::xattr_exists: case api_error::xattr_exists:
return -EEXIST; return -EEXIST;
case api_error::xattr_not_found: case api_error::xattr_not_found:
#ifdef __APPLE__ #if defined(__APPLE__)
return -ENOATTR; return -ENOATTR;
#else #else
return -ENODATA; return -ENODATA;
#endif #endif
case api_error::xattr_too_big: case api_error::xattr_too_big:
#ifdef __APPLE__ #if defined(__APPLE__)
return -ENAMETOOLONG; return -ENAMETOOLONG;
#else #else
return -E2BIG; return -E2BIG;
@ -112,7 +112,7 @@ auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool {
int group_count{}; int group_count{};
if (getgrouplist(pass->pw_name, pass->pw_gid, nullptr, &group_count) < 0) { if (getgrouplist(pass->pw_name, pass->pw_gid, nullptr, &group_count) < 0) {
groups.resize(static_cast<std::size_t>(group_count)); groups.resize(static_cast<std::size_t>(group_count));
#ifdef __APPLE__ #if defined(__APPLE__)
getgrouplist(pass->pw_name, pass->pw_gid, getgrouplist(pass->pw_name, pass->pw_gid,
reinterpret_cast<int *>(groups.data()), &group_count); reinterpret_cast<int *>(groups.data()), &group_count);
#else #else
@ -142,7 +142,7 @@ auto to_api_error(int err) -> api_error {
return api_error::directory_not_empty; return api_error::directory_not_empty;
case ENOTDIR: case ENOTDIR:
return api_error::directory_not_found; return api_error::directory_not_found;
#ifdef __APPLE__ #if defined(__APPLE__)
case EBADMSG: case EBADMSG:
return api_error::download_failed; return api_error::download_failed;
#else #else
@ -173,14 +173,14 @@ auto to_api_error(int err) -> api_error {
return api_error::upload_failed; return api_error::upload_failed;
case ERANGE: case ERANGE:
return api_error::xattr_buffer_small; return api_error::xattr_buffer_small;
#ifdef __APPLE__ #if defined(__APPLE__)
case ENOATTR: case ENOATTR:
return api_error::xattr_not_found; return api_error::xattr_not_found;
#else #else
case ENODATA: case ENODATA:
return api_error::xattr_not_found; return api_error::xattr_not_found;
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
case ENAMETOOLONG: case ENAMETOOLONG:
return api_error::xattr_too_big; return api_error::xattr_too_big;
#else #else

View File

@ -59,8 +59,8 @@ auto calculate_read_size(const uint64_t &total_size, std::size_t read_size,
: read_size); : read_size);
} }
auto compare_version_strings(std::string version1, std::string version2) auto compare_version_strings(std::string version1,
-> int { std::string version2) -> int {
if (utils::string::contains(version1, "-")) { if (utils::string::contains(version1, "-")) {
version1 = utils::string::split(version1, '-')[0U]; version1 = utils::string::split(version1, '-')[0U];
} }
@ -100,7 +100,7 @@ auto convert_api_date(const std::string &date) -> std::uint64_t {
utils::string::to_uint64(utils::string::split(date_parts[1U], 'Z')[0U]); utils::string::to_uint64(utils::string::split(date_parts[1U], 'Z')[0U]);
struct tm tm1 {}; struct tm tm1 {};
#ifdef _WIN32 #if defined(_WIN32)
utils::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1); utils::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
#else #else
strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1); strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
@ -134,9 +134,8 @@ auto create_volume_label(const provider_type &prov) -> std::string {
return "repertory_" + app_config::get_provider_name(prov); return "repertory_" + app_config::get_provider_name(prov);
} }
auto download_type_from_string(std::string type, auto download_type_from_string(
const download_type &default_type) std::string type, const download_type &default_type) -> download_type {
-> download_type {
type = utils::string::to_lower(utils::string::trim(type)); type = utils::string::to_lower(utils::string::trim(type));
if (type == "direct") { if (type == "direct") {
return download_type::direct; return download_type::direct;
@ -166,7 +165,7 @@ auto download_type_to_string(const download_type &type) -> std::string {
} }
} }
#ifdef _WIN32 #if defined(_WIN32)
// https://www.frenk.com/2009/12/convert-filetime-to-unix-timestamp/ // https://www.frenk.com/2009/12/convert-filetime-to-unix-timestamp/
auto filetime_to_unix_time(const FILETIME &ft) -> remote::file_time { auto filetime_to_unix_time(const FILETIME &ft) -> remote::file_time {
LARGE_INTEGER date{}; LARGE_INTEGER date{};
@ -211,7 +210,7 @@ auto get_environment_variable(const std::string &variable) -> std::string {
} }
auto get_file_time_now() -> std::uint64_t { auto get_file_time_now() -> std::uint64_t {
#ifdef _WIN32 #if defined(_WIN32)
SYSTEMTIME st{}; SYSTEMTIME st{};
::GetSystemTime(&st); ::GetSystemTime(&st);
FILETIME ft{}; FILETIME ft{};
@ -228,7 +227,7 @@ void get_local_time_now(struct tm &local_time) {
const auto now = const auto now =
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
#ifdef _WIN32 #if defined(_WIN32)
localtime_s(&local_time, &now); localtime_s(&local_time, &now);
#else #else
localtime_r(&now, &local_time); localtime_r(&now, &local_time);
@ -261,11 +260,11 @@ auto get_next_available_port(std::uint16_t first_port,
} }
auto get_time_now() -> std::uint64_t { auto get_time_now() -> std::uint64_t {
#ifdef _WIN32 #if defined(_WIN32)
return static_cast<std::uint64_t>( return static_cast<std::uint64_t>(
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now())); std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
#else #else
#if __APPLE__ #if defined(__APPLE__)
return std::chrono::nanoseconds( return std::chrono::nanoseconds(
std::chrono::system_clock::now().time_since_epoch()) std::chrono::system_clock::now().time_since_epoch())
.count(); .count();
@ -280,7 +279,7 @@ auto get_time_now() -> std::uint64_t {
auto reset_curl(CURL *curl_handle) -> CURL * { auto reset_curl(CURL *curl_handle) -> CURL * {
curl_easy_reset(curl_handle); curl_easy_reset(curl_handle);
#if __APPLE__ #if defined(__APPLE__)
curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
#endif #endif
return curl_handle; return curl_handle;

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifdef _WIN32 #if defined(_WIN32)
#include "utils/windows/windows_utils.hpp" #include "utils/windows/windows_utils.hpp"
@ -27,7 +27,7 @@
#include "utils/com_init_wrapper.hpp" #include "utils/com_init_wrapper.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
#ifndef STATUS_DEVICE_INSUFFICIENT_RESOURCES #if !defined(STATUS_DEVICE_INSUFFICIENT_RESOURCES)
#define STATUS_DEVICE_INSUFFICIENT_RESOURCES static_cast<NTSTATUS>(0xC0000468L) #define STATUS_DEVICE_INSUFFICIENT_RESOURCES static_cast<NTSTATUS>(0xC0000468L)
#endif #endif

View File

@ -71,7 +71,7 @@ template <typename drive> inline void help(std::vector<const char *> args) {
<< std::endl; << std::endl;
std::cout << " -pw,--password Specify API password" std::cout << " -pw,--password Specify API password"
<< std::endl; << std::endl;
#ifndef _WIN32 #if !defined(_WIN32)
#if defined(REPERTORY_ENABLE_S3) #if defined(REPERTORY_ENABLE_S3)
std::cout << " -o s3 Enables S3 mode for " std::cout << " -o s3 Enables S3 mode for "
"'fstab' mounts" "'fstab' mounts"

View File

@ -32,7 +32,7 @@
#include "utils/file_utils.hpp" #include "utils/file_utils.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
#ifdef _WIN32 #if defined(_WIN32)
#include "drives/winfsp/remotewinfsp/remote_client.hpp" #include "drives/winfsp/remotewinfsp/remote_client.hpp"
#include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp" #include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp"
#include "drives/winfsp/winfsp_drive.hpp" #include "drives/winfsp/winfsp_drive.hpp"
@ -84,7 +84,7 @@ mount(std::vector<const char *> args, std::string data_directory,
? exit_code::success ? exit_code::success
: exit_code::file_creation_failed; : exit_code::file_creation_failed;
} else { } else {
#ifdef _WIN32 #if defined(_WIN32)
if (utils::cli::has_option(args, utils::cli::options::hidden_option)) { if (utils::cli::has_option(args, utils::cli::options::hidden_option)) {
::ShowWindow(::GetConsoleWindow(), SW_HIDE); ::ShowWindow(::GetConsoleWindow(), SW_HIDE);
} }
@ -92,7 +92,7 @@ mount(std::vector<const char *> args, std::string data_directory,
const auto drive_args = const auto drive_args =
utils::cli::parse_drive_options(args, prov, data_directory); utils::cli::parse_drive_options(args, prov, data_directory);
app_config config(prov, data_directory); app_config config(prov, data_directory);
#ifdef _WIN32 #if defined(_WIN32)
if (config.get_enable_mount_manager() && if (config.get_enable_mount_manager() &&
not utils::is_process_elevated()) { not utils::is_process_elevated()) {
com_init_wrapper cw; com_init_wrapper cw;

View File

@ -92,7 +92,7 @@ auto main(int argc, char **argv) -> int {
} }
} }
#ifdef REPERTORY_ENABLE_S3 #if defined(REPERTORY_ENABLE_S3)
if ((res == exit_code::success) && (prov == provider_type::s3)) { if ((res == exit_code::success) && (prov == provider_type::s3)) {
std::string data; std::string data;
res = utils::cli::parse_string_option( res = utils::cli::parse_string_option(

View File

@ -19,9 +19,9 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef REPERTORY_WINFSP_FIXTURE_H #ifndef REPERTORY_WINFSP_FIXTURE_HPP
#define REPERTORY_WINFSP_FIXTURE_H #define REPERTORY_WINFSP_FIXTURE_HPP
#if _WIN32 #if defined(_WIN32)
#include "test_common.hpp" #include "test_common.hpp"
@ -47,7 +47,7 @@ protected:
void SetUp() override { void SetUp() override {
if (PROVIDER_INDEX != 0) { if (PROVIDER_INDEX != 0) {
if (PROVIDER_INDEX == 1) { if (PROVIDER_INDEX == 1) {
#ifdef REPERTORY_ENABLE_S3 #if defined(REPERTORY_ENABLE_S3)
EXPECT_TRUE(utils::file::delete_directory_recursively( EXPECT_TRUE(utils::file::delete_directory_recursively(
"./winfsp_test" + std::to_string(PROVIDER_INDEX))); "./winfsp_test" + std::to_string(PROVIDER_INDEX)));
@ -145,4 +145,4 @@ protected:
} // namespace repertory } // namespace repertory
#endif #endif
#endif // REPERTORY_WINFSP_FIXTURE_H #endif // REPERTORY_WINFSP_FIXTURE_HPP

View File

@ -21,7 +21,7 @@
*/ */
#ifndef TESTS_MOCKS_MOCK_FUSE_DRIVE_HPP_ #ifndef TESTS_MOCKS_MOCK_FUSE_DRIVE_HPP_
#define TESTS_MOCKS_MOCK_FUSE_DRIVE_HPP_ #define TESTS_MOCKS_MOCK_FUSE_DRIVE_HPP_
#ifndef _WIN32 #if !defined(_WIN32)
#include "test_common.hpp" #include "test_common.hpp"
@ -47,8 +47,8 @@ public:
return api_error::success; return api_error::success;
} }
auto check_parent_access(const std::string &, int) const auto check_parent_access(const std::string &,
-> api_error override { int) const -> api_error override {
return api_error::success; return api_error::success;
} }
@ -83,8 +83,8 @@ public:
return 0U; return 0U;
} }
auto get_item_meta(const std::string &api_path, api_meta_map &meta) const auto get_item_meta(const std::string &api_path,
-> api_error override { api_meta_map &meta) const -> api_error override {
meta = const_cast<mock_fuse_drive *>(this)->meta_[api_path]; meta = const_cast<mock_fuse_drive *>(this)->meta_[api_path];
return api_error::success; return api_error::success;
} }
@ -123,8 +123,8 @@ public:
} }
auto rename_file(const std::string &from_api_path, auto rename_file(const std::string &from_api_path,
const std::string &to_api_path, bool overwrite) const std::string &to_api_path,
-> int override { bool overwrite) -> int override {
const auto from_file_path = const auto from_file_path =
utils::path::combine(mount_location_, {from_api_path}); utils::path::combine(mount_location_, {from_api_path});
const auto to_file_path = const auto to_file_path =

View File

@ -21,7 +21,7 @@
*/ */
#ifndef TESTS_MOCKS_MOCK_WINFSP_DRIVE_HPP_ #ifndef TESTS_MOCKS_MOCK_WINFSP_DRIVE_HPP_
#define TESTS_MOCKS_MOCK_WINFSP_DRIVE_HPP_ #define TESTS_MOCKS_MOCK_WINFSP_DRIVE_HPP_
#ifdef _WIN32 #if defined(_WIN32)
#include "test_common.hpp" #include "test_common.hpp"
@ -40,9 +40,8 @@ private:
const std::string mount_location_; const std::string mount_location_;
public: public:
[[nodiscard]] auto [[nodiscard]] auto get_directory_item_count(
get_directory_item_count(const std::string & /*api_path*/) const const std::string & /*api_path*/) const -> std::uint64_t override {
-> std::uint64_t override {
return 1; return 1;
} }
@ -72,8 +71,8 @@ public:
return 0; return 0;
} }
auto get_item_meta(const std::string & /*api_path*/, api_meta_map &meta) const auto get_item_meta(const std::string & /*api_path*/,
-> api_error override { api_meta_map &meta) const -> api_error override {
return api_error::error; return api_error::error;
} }
@ -83,10 +82,10 @@ public:
return api_error::error; return api_error::error;
} }
auto get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes, auto
PSECURITY_DESCRIPTOR descriptor, get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes,
std::uint64_t *descriptor_size) PSECURITY_DESCRIPTOR descriptor,
-> NTSTATUS override { std::uint64_t *descriptor_size) -> NTSTATUS override {
auto ret = STATUS_SUCCESS; auto ret = STATUS_SUCCESS;
if (attributes) { if (attributes) {

View File

@ -22,7 +22,7 @@
#ifndef TESTS_TEST_COMMON_HPP_ #ifndef TESTS_TEST_COMMON_HPP_
#define TESTS_TEST_COMMON_HPP_ #define TESTS_TEST_COMMON_HPP_
#ifdef U #if defined(U)
#undef U #undef U
#endif #endif
@ -44,15 +44,14 @@ using ::testing::_;
using namespace ::testing; using namespace ::testing;
namespace repertory { namespace repertory {
[[nodiscard]] auto create_random_file(std::string path, std::size_t size) [[nodiscard]] auto create_random_file(std::string path,
-> native_file_ptr; std::size_t size) -> native_file_ptr;
void delete_generated_files(); void delete_generated_files();
[[nodiscard]] auto [[nodiscard]] auto generate_test_file_name(
generate_test_file_name(const std::string &directory, const std::string &directory,
const std::string &file_name_no_extension) const std::string &file_name_no_extension) -> std::string;
-> std::string;
template <typename T, typename T2> template <typename T, typename T2>
static void decrypt_and_verify(const T &buffer, const std::string &token, static void decrypt_and_verify(const T &buffer, const std::string &token,

View File

@ -21,13 +21,13 @@
*/ */
#include "initialize.hpp" #include "initialize.hpp"
#include "test_common.hpp" #include "test_common.hpp"
#ifdef _WIN32 #if defined(_WIN32)
#include "utils/cli_utils.hpp" #include "utils/cli_utils.hpp"
#endif // _WIN32 #endif // _WIN32
using namespace repertory; using namespace repertory;
#ifdef _WIN32 #if defined(_WIN32)
std::size_t PROVIDER_INDEX{0U}; std::size_t PROVIDER_INDEX{0U};
#endif // _WIN32 #endif // _WIN32
@ -36,7 +36,7 @@ auto main(int argc, char **argv) -> int {
return -1; return -1;
} }
#ifdef _WIN32 #if defined(_WIN32)
std::vector<const char *> args; std::vector<const char *> args;
{ {
auto args_span = std::span(argv, static_cast<std::size_t>(argc)); auto args_span = std::span(argv, static_cast<std::size_t>(argc));

View File

@ -49,7 +49,7 @@ const auto DEFAULT_SIA_CONFIG = "{\n"
" \"EnableCommDurationEvents\": false,\n" " \"EnableCommDurationEvents\": false,\n"
" \"EnableDriveEvents\": false,\n" " \"EnableDriveEvents\": false,\n"
" \"EnableMaxCacheSize\": false,\n" " \"EnableMaxCacheSize\": false,\n"
#ifdef _WIN32 #if defined(_WIN32)
" \"EnableMountManager\": false,\n" " \"EnableMountManager\": false,\n"
#endif #endif
" \"EventLevel\": \"normal\",\n" " \"EventLevel\": \"normal\",\n"
@ -97,7 +97,7 @@ const auto DEFAULT_S3_CONFIG = "{\n"
" \"EnableCommDurationEvents\": false,\n" " \"EnableCommDurationEvents\": false,\n"
" \"EnableDriveEvents\": false,\n" " \"EnableDriveEvents\": false,\n"
" \"EnableMaxCacheSize\": false,\n" " \"EnableMaxCacheSize\": false,\n"
#ifdef _WIN32 #if defined(_WIN32)
" \"EnableMountManager\": false,\n" " \"EnableMountManager\": false,\n"
#endif #endif
" \"EventLevel\": \"normal\",\n" " \"EventLevel\": \"normal\",\n"
@ -294,7 +294,7 @@ TEST_F(config_test, enable_max_cache_size) {
EXPECT_EQ(not original_value, config.get_enable_max_cache_size()); EXPECT_EQ(not original_value, config.get_enable_max_cache_size());
} }
} }
#ifdef _WIN32 #if defined(_WIN32)
TEST_F(config_test, enable_mount_manager) { TEST_F(config_test, enable_mount_manager) {
bool original_value; bool original_value;
{ {
@ -575,14 +575,14 @@ TEST_F(config_test, default_data_directory) {
app_config::default_data_directory(provider_type::sia), app_config::default_data_directory(provider_type::sia),
}; };
#ifdef _WIN32 #if defined(_WIN32)
const auto local_app_data = utils::get_environment_variable("localappdata"); const auto local_app_data = utils::get_environment_variable("localappdata");
#endif #endif
#if __linux__ #if defined(__linux__)
const auto local_app_data = const auto local_app_data =
utils::path::combine(utils::get_environment_variable("HOME"), {".local"}); utils::path::combine(utils::get_environment_variable("HOME"), {".local"});
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
const auto local_app_data = utils::path::combine( const auto local_app_data = utils::path::combine(
utils::get_environment_variable("HOME"), {"Library/Application Support"}); utils::get_environment_variable("HOME"), {"Library/Application Support"});
#endif #endif

View File

@ -588,7 +588,7 @@ TEST(open_file, can_add_handle) {
{"filesystem_item_opened", "filesystem_item_handle_opened"}); {"filesystem_item_opened", "filesystem_item_handle_opened"});
file_manager::open_file o(test_chunk_size, 0U, fsi, mp, um); file_manager::open_file o(test_chunk_size, 0U, fsi, mp, um);
#ifdef _WIN32 #if defined(_WIN32)
o.add(1u, {}); o.add(1u, {});
EXPECT_EQ(nullptr, o.get_open_data(1u).directory_buffer); EXPECT_EQ(nullptr, o.get_open_data(1u).directory_buffer);
#else #else
@ -653,7 +653,7 @@ TEST(open_file, can_remove_handle) {
}); });
file_manager::open_file o(test_chunk_size, 0U, fsi, mp, um); file_manager::open_file o(test_chunk_size, 0U, fsi, mp, um);
#ifdef _WIN32 #if defined(_WIN32)
o.add(1u, {}); o.add(1u, {});
#else #else
o.add(1u, O_RDWR | O_SYNC); o.add(1u, O_RDWR | O_SYNC);

View File

@ -39,7 +39,7 @@
#include "utils/utils.hpp" #include "utils/utils.hpp"
namespace repertory { namespace repertory {
#ifdef PROJECT_ENABLE_TESTING #if defined(PROJECT_ENABLE_TESTING)
auto file_manager::open(std::shared_ptr<i_closeable_open_file> of, auto file_manager::open(std::shared_ptr<i_closeable_open_file> of,
const open_file_data &ofd, std::uint64_t &handle, const open_file_data &ofd, std::uint64_t &handle,
std::shared_ptr<i_open_file> &f) -> api_error { std::shared_ptr<i_open_file> &f) -> api_error {
@ -154,7 +154,7 @@ TEST(file_manager, can_create_and_close_file) {
EXPECT_STREQ("1", ee.get_handle().get<std::string>().c_str()); EXPECT_STREQ("1", ee.get_handle().get<std::string>().c_str());
}); });
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, EXPECT_EQ(api_error::success,
fm.create("/test_create.txt", meta, {}, handle, f)); fm.create("/test_create.txt", meta, {}, handle, f));
#else #else
@ -270,7 +270,7 @@ TEST(file_manager, can_open_and_close_file) {
}); });
std::shared_ptr<i_open_file> f; std::shared_ptr<i_open_file> f;
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, EXPECT_EQ(api_error::success,
fm.open("/test_open.txt", false, {}, handle, f)); fm.open("/test_open.txt", false, {}, handle, f));
#else #else
@ -360,7 +360,7 @@ TEST(file_manager, can_open_and_close_multiple_handles_for_same_file) {
std::array<std::uint64_t, 4u> handles; std::array<std::uint64_t, 4u> handles;
for (std::uint8_t i = 0u; i < handles.size(); i++) { for (std::uint8_t i = 0u; i < handles.size(); i++) {
std::shared_ptr<i_open_file> f; std::shared_ptr<i_open_file> f;
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, EXPECT_EQ(api_error::success,
fm.open("/test_open.txt", false, {}, handles[i], f)); fm.open("/test_open.txt", false, {}, handles[i], f));
#else #else
@ -440,7 +440,7 @@ TEST(file_manager, download_is_stored_after_write_if_partially_downloaded) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f; std::shared_ptr<i_open_file> f;
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, fm.open("/test_write_partial_download.txt", EXPECT_EQ(api_error::success, fm.open("/test_write_partial_download.txt",
false, {}, handle, f)); false, {}, handle, f));
#else #else
@ -602,7 +602,7 @@ TEST(file_manager, upload_occurs_after_write_if_fully_downloaded) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f; std::shared_ptr<i_open_file> f;
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, EXPECT_EQ(api_error::success,
fm.open("/test_write_full_download.txt", false, {}, handle, f)); fm.open("/test_write_full_download.txt", false, {}, handle, f));
#else #else
@ -712,7 +712,7 @@ TEST(file_manager, can_evict_file) {
return api_error::success; return api_error::success;
}); });
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, EXPECT_EQ(api_error::success,
fm.create("/test_evict.txt", meta, {}, handle, f)); fm.create("/test_evict.txt", meta, {}, handle, f));
#else #else
@ -843,7 +843,7 @@ TEST(file_manager, evict_file_fails_if_file_is_open) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f{}; std::shared_ptr<i_open_file> f{};
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, EXPECT_EQ(api_error::success,
fm.open("/test_open.txt", false, {}, handle, f)); fm.open("/test_open.txt", false, {}, handle, f));
#else #else
@ -978,7 +978,7 @@ TEST(file_manager, evict_file_fails_if_file_is_uploading) {
return api_error::success; return api_error::success;
}); });
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, EXPECT_EQ(api_error::success,
fm.create("/test_evict.txt", meta, {}, handle, f)); fm.create("/test_evict.txt", meta, {}, handle, f));
#else #else
@ -1081,7 +1081,7 @@ TEST(file_manager, evict_file_fails_if_file_is_modified) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f; std::shared_ptr<i_open_file> f;
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f));
#else #else
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
@ -1129,7 +1129,7 @@ TEST(file_manager, evict_file_fails_if_file_is_not_complete) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f; std::shared_ptr<i_open_file> f;
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f));
#else #else
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
@ -1198,7 +1198,7 @@ TEST(file_manager, file_is_not_opened_if_provider_create_file_fails) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f; std::shared_ptr<i_open_file> f;
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::error, EXPECT_EQ(api_error::error,
fm.create("/test_create.txt", meta, {}, handle, f)); fm.create("/test_create.txt", meta, {}, handle, f));
#else #else
@ -1230,7 +1230,7 @@ TEST(file_manager, create_fails_if_provider_create_is_unsuccessful) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f{}; std::shared_ptr<i_open_file> f{};
api_meta_map meta{}; api_meta_map meta{};
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::error, EXPECT_EQ(api_error::error,
fm.create("/test_create.txt", meta, {}, handle, f)); fm.create("/test_create.txt", meta, {}, handle, f));
#else #else
@ -1319,7 +1319,7 @@ TEST(file_manager,
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f{}; std::shared_ptr<i_open_file> f{};
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, fm.open(non_writeable, {}, handle, f)); EXPECT_EQ(api_error::success, fm.open(non_writeable, {}, handle, f));
EXPECT_CALL(*non_writeable, get_open_data()) EXPECT_CALL(*non_writeable, get_open_data())
.WillOnce([&handle]() -> std::map<std::uint64_t, open_file_data> { .WillOnce([&handle]() -> std::map<std::uint64_t, open_file_data> {
@ -1404,7 +1404,7 @@ TEST(file_manager, open_file_fails_if_provider_get_filesystem_item_fails) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f{}; std::shared_ptr<i_open_file> f{};
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::error, fm.open(of, {}, handle, f)); EXPECT_EQ(api_error::error, fm.open(of, {}, handle, f));
#else #else
EXPECT_EQ(api_error::error, fm.open(of, O_RDWR, handle, f)); EXPECT_EQ(api_error::error, fm.open(of, O_RDWR, handle, f));
@ -1455,7 +1455,7 @@ TEST(file_manager, open_file_fails_if_provider_set_item_meta_fails) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f{}; std::shared_ptr<i_open_file> f{};
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::error, fm.open(of, {}, handle, f)); EXPECT_EQ(api_error::error, fm.open(of, {}, handle, f));
#else #else
EXPECT_EQ(api_error::error, fm.open(of, O_RDWR, handle, f)); EXPECT_EQ(api_error::error, fm.open(of, O_RDWR, handle, f));
@ -1514,7 +1514,7 @@ TEST(file_manager, open_file_creates_source_path_if_empty) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f{}; std::shared_ptr<i_open_file> f{};
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f));
#else #else
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
@ -1569,7 +1569,7 @@ TEST(file_manager, open_file_first_file_handle_is_not_zero) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f{}; std::shared_ptr<i_open_file> f{};
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f));
#else #else
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
@ -1701,7 +1701,7 @@ TEST(file_manager, remove_file_fails_if_open_file_is_modified) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f{}; std::shared_ptr<i_open_file> f{};
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f));
#else #else
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
@ -1762,7 +1762,7 @@ TEST(file_manager, file_is_closed_after_download_timeout) {
std::uint64_t handle{}; std::uint64_t handle{};
std::shared_ptr<i_open_file> f; std::shared_ptr<i_open_file> f;
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(api_error::success, EXPECT_EQ(api_error::success,
fm.open("/test_download_timeout.txt", false, {}, handle, f)); fm.open("/test_download_timeout.txt", false, {}, handle, f));
#else #else

View File

@ -34,7 +34,7 @@
#include "utils/file_utils.hpp" #include "utils/file_utils.hpp"
#include "utils/utils.hpp" #include "utils/utils.hpp"
#ifndef ACCESSPERMS #if !defined(ACCESSPERMS)
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */ #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
#endif #endif
@ -278,7 +278,7 @@ static void test_ftruncate(const std::string &file_path) {
close(fd); close(fd);
} }
#ifndef __APPLE__ #if !defined(__APPLE__)
static void test_fallocate(const std::string & /* api_path */, static void test_fallocate(const std::string & /* api_path */,
const std::string &file_path) { const std::string &file_path) {
std::cout << __FUNCTION__ << std::endl; std::cout << __FUNCTION__ << std::endl;
@ -344,7 +344,7 @@ test_write_operations_fail_if_read_only(const std::string & /* api_path */,
EXPECT_EQ(-1, ftruncate(fd, 9u)); EXPECT_EQ(-1, ftruncate(fd, 9u));
#ifndef __APPLE__ #if !defined(__APPLE__)
EXPECT_EQ(-1, fallocate(fd, 0, 0, 16)); EXPECT_EQ(-1, fallocate(fd, 0, 0, 16));
#endif #endif
@ -536,7 +536,7 @@ TEST(fuse_drive, all_tests) {
switch (idx) { switch (idx) {
case 0U: { case 0U: {
#ifdef REPERTORY_ENABLE_S3 #if defined(REPERTORY_ENABLE_S3)
config_ptr = config_ptr =
std::make_unique<app_config>(provider_type::s3, cfg_directory); std::make_unique<app_config>(provider_type::s3, cfg_directory);
{ {
@ -623,7 +623,7 @@ TEST(fuse_drive, all_tests) {
test_ftruncate(file_path); test_ftruncate(file_path);
unlink_file_and_test(file_path); unlink_file_and_test(file_path);
#ifndef __APPLE__ #if !defined(__APPLE__)
file_path = create_file_and_test(mount_location, "fallocate_file_test"); file_path = create_file_and_test(mount_location, "fallocate_file_test");
test_fallocate(utils::path::create_api_path("fallocate_file_test"), test_fallocate(utils::path::create_api_path("fallocate_file_test"),
file_path); file_path);

View File

@ -40,7 +40,7 @@ TEST(lock_data, lock_and_unlock) {
EXPECT_EQ(lock_result::success, l.grab_lock(10)); EXPECT_EQ(lock_result::success, l.grab_lock(10));
}).join(); }).join();
#ifdef _WIN32 #if defined(_WIN32)
lock_data l2(provider_type::remote, "1"); lock_data l2(provider_type::remote, "1");
EXPECT_EQ(lock_result::success, l2.grab_lock()); EXPECT_EQ(lock_result::success, l2.grab_lock());
@ -49,7 +49,7 @@ TEST(lock_data, lock_and_unlock) {
#endif #endif
} }
#ifdef _WIN32 #if defined(_WIN32)
TEST(lock_data, set_and_unset_mount_state) { TEST(lock_data, set_and_unset_mount_state) {
lock_data l(provider_type::sia, "1"); lock_data l(provider_type::sia, "1");
EXPECT_TRUE(l.set_mount_state(true, "C:", 99)); EXPECT_TRUE(l.set_mount_state(true, "C:", 99));

View File

@ -27,21 +27,21 @@ namespace repertory {
TEST(path_utils, combine) { TEST(path_utils, combine) {
auto s = utils::path::combine(R"(\test\path)", {}); auto s = utils::path::combine(R"(\test\path)", {});
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_STREQ(R"(\test\path)", s.c_str()); EXPECT_STREQ(R"(\test\path)", s.c_str());
#else #else
EXPECT_STREQ("/test/path", s.c_str()); EXPECT_STREQ("/test/path", s.c_str());
#endif #endif
s = utils::path::combine(R"(\test)", {R"(\path)"}); s = utils::path::combine(R"(\test)", {R"(\path)"});
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_STREQ(R"(\test\path)", s.c_str()); EXPECT_STREQ(R"(\test\path)", s.c_str());
#else #else
EXPECT_STREQ("/test/path", s.c_str()); EXPECT_STREQ("/test/path", s.c_str());
#endif #endif
s = utils::path::combine(R"(\test)", {R"(\path)", R"(\again\)"}); s = utils::path::combine(R"(\test)", {R"(\path)", R"(\again\)"});
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_STREQ(R"(\test\path\again)", s.c_str()); EXPECT_STREQ(R"(\test\path\again)", s.c_str());
#else #else
EXPECT_STREQ("/test/path/again", s.c_str()); EXPECT_STREQ("/test/path/again", s.c_str());
@ -82,49 +82,49 @@ TEST(path_utils, finalize) {
EXPECT_STREQ("", s.c_str()); EXPECT_STREQ("", s.c_str());
s = utils::path::finalize(R"(\)"); s = utils::path::finalize(R"(\)");
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_STREQ(R"(\)", s.c_str()); EXPECT_STREQ(R"(\)", s.c_str());
#else #else
EXPECT_STREQ("/", s.c_str()); EXPECT_STREQ("/", s.c_str());
#endif #endif
s = utils::path::finalize("/"); s = utils::path::finalize("/");
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_STREQ(R"(\)", s.c_str()); EXPECT_STREQ(R"(\)", s.c_str());
#else #else
EXPECT_STREQ("/", s.c_str()); EXPECT_STREQ("/", s.c_str());
#endif #endif
s = utils::path::finalize(R"(\\)"); s = utils::path::finalize(R"(\\)");
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_STREQ(R"(\)", s.c_str()); EXPECT_STREQ(R"(\)", s.c_str());
#else #else
EXPECT_STREQ("/", s.c_str()); EXPECT_STREQ("/", s.c_str());
#endif #endif
s = utils::path::finalize("//"); s = utils::path::finalize("//");
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_STREQ(R"(\)", s.c_str()); EXPECT_STREQ(R"(\)", s.c_str());
#else #else
EXPECT_STREQ("/", s.c_str()); EXPECT_STREQ("/", s.c_str());
#endif #endif
s = utils::path::finalize("/cow///moose/////dog/chicken"); s = utils::path::finalize("/cow///moose/////dog/chicken");
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str()); EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str());
#else #else
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str()); EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
#endif #endif
s = utils::path::finalize("\\cow\\\\\\moose\\\\\\\\dog\\chicken/"); s = utils::path::finalize("\\cow\\\\\\moose\\\\\\\\dog\\chicken/");
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str()); EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str());
#else #else
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str()); EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
#endif #endif
s = utils::path::finalize("/cow\\\\/moose\\\\/\\dog\\chicken\\"); s = utils::path::finalize("/cow\\\\/moose\\\\/\\dog\\chicken\\");
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str()); EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str());
#else #else
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str()); EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());

View File

@ -36,7 +36,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace { namespace {
#ifdef _WIN32 #if defined(_WIN32)
using gid_t = std::uint32_t; using gid_t = std::uint32_t;
using uid_t = std::uint32_t; using uid_t = std::uint32_t;
static constexpr auto getgid() -> gid_t { return 0U; } static constexpr auto getgid() -> gid_t { return 0U; }
@ -435,7 +435,7 @@ static void get_directory_items(const app_config &cfg, i_provider &provider) {
EXPECT_LT(file, list_decrypted.end()); EXPECT_LT(file, list_decrypted.end());
EXPECT_STREQ("/test.txt", file->api_path.c_str()); EXPECT_STREQ("/test.txt", file->api_path.c_str());
EXPECT_STREQ("/", file->api_parent.c_str()); EXPECT_STREQ("/", file->api_parent.c_str());
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(std::size_t(47U), file->size); EXPECT_EQ(std::size_t(47U), file->size);
#else #else
EXPECT_EQ(std::size_t(46U), file->size); EXPECT_EQ(std::size_t(46U), file->size);
@ -465,7 +465,7 @@ static void get_directory_items(const app_config &cfg, i_provider &provider) {
EXPECT_LT(file2, list_decrypted2.end()); EXPECT_LT(file2, list_decrypted2.end());
EXPECT_STREQ("/sub10/moose.txt", file2->api_path.c_str()); EXPECT_STREQ("/sub10/moose.txt", file2->api_path.c_str());
EXPECT_STREQ("/sub10", file2->api_parent.c_str()); EXPECT_STREQ("/sub10", file2->api_parent.c_str());
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(std::size_t(46U), file2->size); EXPECT_EQ(std::size_t(46U), file2->size);
#else #else
EXPECT_EQ(std::size_t(45U), file2->size); EXPECT_EQ(std::size_t(45U), file2->size);
@ -514,7 +514,7 @@ static void get_file(const app_config &cfg, i_provider &provider) {
EXPECT_STREQ("/test.txt", file.api_path.c_str()); EXPECT_STREQ("/test.txt", file.api_path.c_str());
EXPECT_STREQ("/", file.api_parent.c_str()); EXPECT_STREQ("/", file.api_parent.c_str());
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(std::size_t(47U), file.file_size); EXPECT_EQ(std::size_t(47U), file.file_size);
#else #else
EXPECT_EQ(std::size_t(46U), file.file_size); EXPECT_EQ(std::size_t(46U), file.file_size);

View File

@ -21,7 +21,7 @@
*/ */
#include "test_common.hpp" #include "test_common.hpp"
#ifdef _WIN32 #if defined(_WIN32)
#define NOT_IMPLEMENTED STATUS_NOT_IMPLEMENTED #define NOT_IMPLEMENTED STATUS_NOT_IMPLEMENTED
#include "drives/winfsp/i_winfsp_drive.hpp" #include "drives/winfsp/i_winfsp_drive.hpp"
#include "drives/winfsp/remotewinfsp/remote_server.hpp" #include "drives/winfsp/remotewinfsp/remote_server.hpp"
@ -37,7 +37,7 @@
#include "utils/utils.hpp" #include "utils/utils.hpp"
using namespace repertory; using namespace repertory;
#ifdef _WIN32 #if defined(_WIN32)
using namespace repertory::remote_winfsp; using namespace repertory::remote_winfsp;
#else #else
using namespace repertory::remote_fuse; using namespace repertory::remote_fuse;
@ -77,7 +77,7 @@ static void chflags_test(repertory::remote_fuse::remote_client &client) {
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
if (ret == 0) { if (ret == 0) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_chflags(api_path.c_str(), 0)); EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_chflags(api_path.c_str(), 0));
#else #else
EXPECT_EQ(0, client.fuse_chflags(api_path.c_str(), 0)); EXPECT_EQ(0, client.fuse_chflags(api_path.c_str(), 0));
@ -100,7 +100,7 @@ static void chmod_test(repertory::remote_fuse::remote_client &client) {
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
if (ret == 0) { if (ret == 0) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_chmod(api_path.c_str(), 0)); EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_chmod(api_path.c_str(), 0));
#else #else
EXPECT_EQ(0, client.fuse_chmod(api_path.c_str(), S_IRUSR | S_IWUSR)); EXPECT_EQ(0, client.fuse_chmod(api_path.c_str(), S_IRUSR | S_IWUSR));
@ -123,7 +123,7 @@ static void chown_test(repertory::remote_fuse::remote_client &client) {
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
if (ret == 0) { if (ret == 0) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_chown(api_path.c_str(), 0, 0)); EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_chown(api_path.c_str(), 0, 0));
#else #else
if (getuid() == 0) { if (getuid() == 0) {
@ -205,7 +205,7 @@ static void fgetattr_test(repertory::remote_fuse::remote_client &client) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
EXPECT_FALSE(directory); EXPECT_FALSE(directory);
#ifdef _WIN32 #if defined(_WIN32)
struct _stat64 st1 {}; struct _stat64 st1 {};
_stat64(&test_file[0], &st1); _stat64(&test_file[0], &st1);
#else #else
@ -244,7 +244,7 @@ static void fsetattr_x_test(repertory::remote_fuse::remote_client &client) {
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
if (ret == 0) { if (ret == 0) {
remote::setattr_x attr{}; remote::setattr_x attr{};
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(NOT_IMPLEMENTED, EXPECT_EQ(NOT_IMPLEMENTED,
client.fuse_fsetattr_x(api_path.c_str(), attr, handle)); client.fuse_fsetattr_x(api_path.c_str(), attr, handle));
#else #else
@ -319,7 +319,7 @@ static void getattr_test(repertory::remote_fuse::remote_client &client) {
remote::stat st{}; remote::stat st{};
EXPECT_EQ(0, client.fuse_getattr(api_path.c_str(), st, directory)); EXPECT_EQ(0, client.fuse_getattr(api_path.c_str(), st, directory));
EXPECT_FALSE(directory); EXPECT_FALSE(directory);
#ifdef _WIN32 #if defined(_WIN32)
struct _stat64 st1 {}; struct _stat64 st1 {};
_stat64(&test_file[0], &st1); _stat64(&test_file[0], &st1);
#else #else
@ -355,7 +355,7 @@ api_path = test_file.substr(mount_location_.size());
api_path.c_str(), 0, remote::open_flags::Create | api_path.c_str(), 0, remote::open_flags::Create |
remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) { remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
#if _WIN32 || !HAS_SETXATTR || __APPLE__ #if defined(_WIN32) || !defined(HAS_SETXATTR) || defined(__APPLE__)
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_getxattr(api_path.c_str(), "test", EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_getxattr(api_path.c_str(), "test",
nullptr, 0)); #else EXPECT_EQ(-EACCES, client.fuse_getxattr(api_path.c_str(), nullptr, 0)); #else EXPECT_EQ(-EACCES, client.fuse_getxattr(api_path.c_str(),
"test", nullptr, 0)); #endif "test", nullptr, 0)); #endif
@ -396,7 +396,7 @@ static void getxtimes_test(repertory::remote_fuse::remote_client &client) {
if (ret == 0) { if (ret == 0) {
remote::file_time bkuptime = 0; remote::file_time bkuptime = 0;
remote::file_time crtime = 0; remote::file_time crtime = 0;
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(NOT_IMPLEMENTED, EXPECT_EQ(NOT_IMPLEMENTED,
client.fuse_getxtimes(api_path.c_str(), bkuptime, crtime)); client.fuse_getxtimes(api_path.c_str(), bkuptime, crtime));
#else #else
@ -423,7 +423,7 @@ api_path = test_file.substr(mount_location_.size());
api_path.c_str(), 0, remote::open_flags::Create | api_path.c_str(), 0, remote::open_flags::Create |
remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) { remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
#if _WIN32 || !HAS_SETXATTR #if defined(_WIN32) || !defined(HAS_SETXATTR)
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_listxattr(api_path.c_str(), nullptr, EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_listxattr(api_path.c_str(), nullptr,
0)); #else EXPECT_EQ(-EIO, client.fuse_listxattr(api_path.c_str(), nullptr, 0)); 0)); #else EXPECT_EQ(-EIO, client.fuse_listxattr(api_path.c_str(), nullptr, 0));
#endif #endif
@ -438,7 +438,7 @@ static void mkdir_test(repertory::remote_fuse::remote_client &client) {
const auto api_path = test_directory.substr(mount_location_.size()); const auto api_path = test_directory.substr(mount_location_.size());
EXPECT_TRUE(utils::file::delete_directory(test_directory)); EXPECT_TRUE(utils::file::delete_directory(test_directory));
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0)); EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0));
#else #else
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU)); EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
@ -455,7 +455,7 @@ static void open_test(repertory::remote_fuse::remote_client &client) {
EXPECT_TRUE(utils::file::retry_delete_file(test_file)); EXPECT_TRUE(utils::file::retry_delete_file(test_file));
remote::file_handle handle; remote::file_handle handle;
#ifdef _WIN32 #if defined(_WIN32)
const auto ret = client.fuse_create( const auto ret = client.fuse_create(
api_path.c_str(), 0, api_path.c_str(), 0,
remote::open_flags::create | remote::open_flags::read_write, handle); remote::open_flags::create | remote::open_flags::read_write, handle);
@ -484,7 +484,7 @@ opendir_and_releasedir_test(repertory::remote_fuse::remote_client &client) {
const auto api_path = test_directory.substr(mount_location_.size()); const auto api_path = test_directory.substr(mount_location_.size());
EXPECT_TRUE(utils::file::delete_directory(test_directory)); EXPECT_TRUE(utils::file::delete_directory(test_directory));
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0)); EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0));
#else #else
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU)); EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
@ -554,7 +554,7 @@ static void readdir_test(repertory::remote_fuse::remote_client &client) {
const auto api_path = test_directory.substr(mount_location_.size()); const auto api_path = test_directory.substr(mount_location_.size());
EXPECT_TRUE(utils::file::delete_directory(test_directory)); EXPECT_TRUE(utils::file::delete_directory(test_directory));
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0)); EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0));
#else #else
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU)); EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
@ -587,7 +587,7 @@ api_path = test_file.substr(mount_location_.size());
api_path.c_str(), 0, remote::open_flags::Create | api_path.c_str(), 0, remote::open_flags::Create |
remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) { remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
#if _WIN32 || !HAS_SETXATTR #if defined(_WIN32) || !defined(HAS_SETXATTR)
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_removexattr(api_path.c_str(), EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_removexattr(api_path.c_str(),
"test")); #else EXPECT_EQ(-EACCES, client.fuse_removexattr(api_path.c_str(), "test")); #else EXPECT_EQ(-EACCES, client.fuse_removexattr(api_path.c_str(),
"test")); #endif "test")); #endif
@ -608,7 +608,7 @@ static void rename_test(repertory::remote_fuse::remote_client &client) {
EXPECT_TRUE(utils::file::retry_delete_file(renamed_test_file)); EXPECT_TRUE(utils::file::retry_delete_file(renamed_test_file));
remote::file_handle handle; remote::file_handle handle;
#ifdef _WIN32 #if defined(_WIN32)
const auto ret = client.fuse_create( const auto ret = client.fuse_create(
api_path.c_str(), 0, api_path.c_str(), 0,
remote::open_flags::create | remote::open_flags::read_write, handle); remote::open_flags::create | remote::open_flags::read_write, handle);
@ -637,7 +637,7 @@ static void rmdir_test(repertory::remote_fuse::remote_client &client) {
const auto api_path = test_directory.substr(mount_location_.size()); const auto api_path = test_directory.substr(mount_location_.size());
EXPECT_TRUE(utils::file::delete_directory(test_directory)); EXPECT_TRUE(utils::file::delete_directory(test_directory));
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0)); EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0));
#else #else
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU)); EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
@ -665,7 +665,7 @@ static void setattr_x_test(repertory::remote_fuse::remote_client &client) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
remote::setattr_x attr{}; remote::setattr_x attr{};
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setattr_x(api_path.c_str(), attr)); EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setattr_x(api_path.c_str(), attr));
#else #else
EXPECT_EQ(0, client.fuse_setattr_x(api_path.c_str(), attr)); EXPECT_EQ(0, client.fuse_setattr_x(api_path.c_str(), attr));
@ -690,7 +690,7 @@ static void setbkuptime_test(repertory::remote_fuse::remote_client &client) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
remote::file_time ts = utils::get_file_time_now(); remote::file_time ts = utils::get_file_time_now();
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setbkuptime(api_path.c_str(), ts)); EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setbkuptime(api_path.c_str(), ts));
#else #else
EXPECT_EQ(0, client.fuse_setbkuptime(api_path.c_str(), ts)); EXPECT_EQ(0, client.fuse_setbkuptime(api_path.c_str(), ts));
@ -715,7 +715,7 @@ static void setchgtime_test(repertory::remote_fuse::remote_client &client) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
remote::file_time ts = utils::get_file_time_now(); remote::file_time ts = utils::get_file_time_now();
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setchgtime(api_path.c_str(), ts)); EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setchgtime(api_path.c_str(), ts));
#else #else
EXPECT_EQ(0, client.fuse_setchgtime(api_path.c_str(), ts)); EXPECT_EQ(0, client.fuse_setchgtime(api_path.c_str(), ts));
@ -740,7 +740,7 @@ static void setcrtime_test(repertory::remote_fuse::remote_client &client) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
remote::file_time ts = utils::get_file_time_now(); remote::file_time ts = utils::get_file_time_now();
#ifdef _WIN32 #if defined(_WIN32)
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setcrtime(api_path.c_str(), ts)); EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setcrtime(api_path.c_str(), ts));
#else #else
EXPECT_EQ(0, client.fuse_setcrtime(api_path.c_str(), ts)); EXPECT_EQ(0, client.fuse_setcrtime(api_path.c_str(), ts));
@ -765,7 +765,7 @@ api_path = test_file.substr(mount_location_.size());
api_path.c_str(), 0, remote::open_flags::Create | api_path.c_str(), 0, remote::open_flags::Create |
remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) { remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
#if _WIN32 || !HAS_SETXATTR #if defined(_WIN32) || !defined(HAS_SETXATTR)
EXPECT_EQ(NOT_IMPLEMENTED, EXPECT_EQ(NOT_IMPLEMENTED,
client.fuse_setxattr(api_path.c_str(), "test", "moose", 5, 0)); client.fuse_setxattr(api_path.c_str(), "test", "moose", 5, 0));
#else #else
@ -796,7 +796,7 @@ remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
utils::file::retry_delete_file(test_file); utils::file::retry_delete_file(test_file);
}*/ }*/
#ifdef _WIN32 #if defined(_WIN32)
static void test_statfs(repertory::remote_fuse::remote_client &client, static void test_statfs(repertory::remote_fuse::remote_client &client,
const i_winfsp_drive &drive) { const i_winfsp_drive &drive) {
#else #else
@ -823,7 +823,7 @@ static void test_statfs(repertory::remote_fuse::remote_client &client,
EXPECT_EQ(st.f_favail, st.f_ffree); EXPECT_EQ(st.f_favail, st.f_ffree);
} }
#ifdef _WIN32 #if defined(_WIN32)
static void statfs_x_test(repertory::remote_fuse::remote_client &client, static void statfs_x_test(repertory::remote_fuse::remote_client &client,
const i_winfsp_drive &drive) { const i_winfsp_drive &drive) {
#else #else
@ -860,7 +860,7 @@ static void truncate_test(repertory::remote_fuse::remote_client &client) {
EXPECT_TRUE(utils::file::retry_delete_file(test_file)); EXPECT_TRUE(utils::file::retry_delete_file(test_file));
remote::file_handle handle; remote::file_handle handle;
#ifdef _WIN32 #if defined(_WIN32)
const auto ret = client.fuse_create( const auto ret = client.fuse_create(
api_path.c_str(), 0, api_path.c_str(), 0,
remote::open_flags::create | remote::open_flags::read_write, handle); remote::open_flags::create | remote::open_flags::read_write, handle);
@ -939,7 +939,7 @@ TEST(remote_fuse, all_tests) {
config.set_event_level(event_level::verbose); config.set_event_level(event_level::verbose);
event_system::instance().start(); event_system::instance().start();
#ifdef _WIN32 #if defined(_WIN32)
mount_location_ = std::string(__FILE__).substr(0, 2); mount_location_ = std::string(__FILE__).substr(0, 2);
mock_winfsp_drive drive(mount_location_); mock_winfsp_drive drive(mount_location_);
remote_server server(config, drive, mount_location_); remote_server server(config, drive, mount_location_);

View File

@ -24,7 +24,7 @@
#include "drives/winfsp/i_winfsp_drive.hpp" #include "drives/winfsp/i_winfsp_drive.hpp"
#include "drives/winfsp/remotewinfsp/remote_client.hpp" #include "drives/winfsp/remotewinfsp/remote_client.hpp"
#include "events/consumers/console_consumer.hpp" #include "events/consumers/console_consumer.hpp"
#ifdef _WIN32 #if defined(_WIN32)
#include "drives/winfsp/remotewinfsp/remote_server.hpp" #include "drives/winfsp/remotewinfsp/remote_server.hpp"
#include "mocks/mock_winfsp_drive.hpp" #include "mocks/mock_winfsp_drive.hpp"
#else #else
@ -409,7 +409,7 @@ static void set_basic_info_test(remote_client &client) {
EXPECT_EQ(STATUS_SUCCESS, ret); EXPECT_EQ(STATUS_SUCCESS, ret);
const auto attributes = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE; const auto attributes = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE;
#ifdef _WIN32 #if defined(_WIN32)
SYSTEMTIME st{}; SYSTEMTIME st{};
::GetSystemTime(&st); ::GetSystemTime(&st);
@ -493,7 +493,7 @@ TEST(remote_winfsp, all_tests) {
config.set_event_level(event_level::verbose); config.set_event_level(event_level::verbose);
event_system::instance().start(); event_system::instance().start();
#ifdef _WIN32 #if defined(_WIN32)
mount_location_ = std::string(__FILE__).substr(0, 2); mount_location_ = std::string(__FILE__).substr(0, 2);
mock_winfsp_drive drive(mount_location_); mock_winfsp_drive drive(mount_location_);
remote_server server(config, drive, mount_location_); remote_server server(config, drive, mount_location_);

View File

@ -27,7 +27,7 @@
#include "utils/utils.hpp" #include "utils/utils.hpp"
namespace repertory { namespace repertory {
#ifdef _WIN32 #if defined(_WIN32)
TEST(utils, convert_api_date) { TEST(utils, convert_api_date) {
LARGE_INTEGER li{}; LARGE_INTEGER li{};
li.QuadPart = utils::convert_api_date("2009-10-12T17:50:30.111Z"); li.QuadPart = utils::convert_api_date("2009-10-12T17:50:30.111Z");

View File

@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#if _WIN32 #if defined(_WIN32)
#include "test_common.hpp" #include "test_common.hpp"
@ -333,7 +333,7 @@ TEST_F(winfsp_test, all_tests) {
return; return;
} }
#ifndef REPERTORY_ENABLE_S3 #if !defined(REPERTORY_ENABLE_S3)
if (PROVIDER_INDEX == 1U) { if (PROVIDER_INDEX == 1U) {
return; return;
} }