From 6a984ac84ccea11fdbdc2916ada0c4918ab03937 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 15 Jul 2024 12:20:15 -0500 Subject: [PATCH] refactor proprocessor directives --- repertory/librepertory/include/app_config.hpp | 40 +-- repertory/librepertory/include/common.hpp | 38 +-- .../include/drives/directory_iterator.hpp | 12 +- .../include/drives/fuse/fuse_base.hpp | 265 +++++++++--------- .../include/drives/fuse/fuse_drive.hpp | 255 ++++++++--------- .../include/drives/fuse/fuse_drive_base.hpp | 84 +++--- .../include/drives/fuse/i_fuse_drive.hpp | 49 ++-- .../fuse/remotefuse/remote_fuse_drive.hpp | 207 +++++++------- .../drives/fuse/remotefuse/remote_server.hpp | 243 ++++++++-------- .../drives/remote/remote_open_file_table.hpp | 24 +- .../drives/remote/remote_server_base.hpp | 8 +- .../include/drives/winfsp/i_winfsp_drive.hpp | 35 ++- .../winfsp/remotewinfsp/remote_client.hpp | 69 +++-- .../winfsp/remotewinfsp/remote_server.hpp | 153 +++++----- .../remotewinfsp/remote_winfsp_drive.hpp | 30 +- .../include/drives/winfsp/winfsp_drive.hpp | 65 +++-- .../events/consumers/console_consumer.hpp | 4 +- .../librepertory/include/events/events.hpp | 2 +- .../include/file_manager/file_manager.hpp | 68 ++--- .../include/platform/unix_platform.hpp | 11 +- .../include/platform/win32_platform.hpp | 6 +- .../librepertory/include/types/remote.hpp | 16 +- .../librepertory/include/types/repertory.hpp | 10 +- repertory/librepertory/include/types/s3.hpp | 4 +- .../include/utils/com_init_wrapper.hpp | 2 +- .../include/utils/native_file.hpp | 14 +- .../librepertory/include/utils/path_utils.hpp | 11 +- .../include/utils/unix/unix_utils.hpp | 20 +- .../include/utils/windows/windows_utils.hpp | 26 +- repertory/librepertory/src/app_config.cpp | 18 +- .../src/drives/directory_iterator.cpp | 10 +- .../librepertory/src/drives/eviction.cpp | 2 +- .../src/drives/fuse/fuse_base.cpp | 58 ++-- .../src/drives/fuse/fuse_drive.cpp | 96 ++++--- .../src/drives/fuse/fuse_drive_base.cpp | 48 ++-- .../fuse/remotefuse/remote_fuse_drive.cpp | 87 +++--- .../drives/fuse/remotefuse/remote_server.cpp | 208 ++++++-------- .../drives/remote/remote_open_file_table.cpp | 8 +- .../winfsp/remotewinfsp/remote_client.cpp | 8 +- .../winfsp/remotewinfsp/remote_server.cpp | 166 +++++------ .../remotewinfsp/remote_winfsp_drive.cpp | 29 +- .../src/drives/winfsp/winfsp_drive.cpp | 2 +- .../src/events/consumers/logging_consumer.cpp | 2 +- .../src/platform/unix_platform.cpp | 4 +- .../src/platform/win32_platform.cpp | 6 +- .../providers/encrypt/encrypt_provider.cpp | 54 ++-- repertory/librepertory/src/types/remote.cpp | 22 +- .../librepertory/src/utils/cli_utils.cpp | 25 +- .../librepertory/src/utils/file_utils.cpp | 70 ++--- .../librepertory/src/utils/native_file.cpp | 40 +-- .../librepertory/src/utils/path_utils.cpp | 18 +- .../src/utils/unix/unix_utils.cpp | 18 +- repertory/librepertory/src/utils/utils.cpp | 23 +- .../src/utils/windows/windows_utils.cpp | 4 +- repertory/repertory/include/cli/help.hpp | 2 +- repertory/repertory/include/cli/mount.hpp | 6 +- repertory/repertory/main.cpp | 2 +- .../include/fixtures/winfsp_fixture.hpp | 10 +- .../include/mocks/mock_fuse_drive.hpp | 14 +- .../include/mocks/mock_winfsp_drive.hpp | 19 +- .../repertory_test/include/test_common.hpp | 13 +- repertory/repertory_test/main.cpp | 6 +- repertory/repertory_test/src/config_test.cpp | 12 +- .../src/file_manager_open_file_test.cpp | 4 +- .../repertory_test/src/file_manager_test.cpp | 40 +-- .../repertory_test/src/fuse_drive_test.cpp | 10 +- .../repertory_test/src/lock_data_test.cpp | 4 +- .../repertory_test/src/path_utils_test.cpp | 20 +- .../repertory_test/src/providers_test.cpp | 8 +- .../repertory_test/src/remote_fuse_test.cpp | 54 ++-- .../repertory_test/src/remote_winfsp_test.cpp | 6 +- repertory/repertory_test/src/utils_test.cpp | 2 +- repertory/repertory_test/src/winfsp_test.cpp | 4 +- 73 files changed, 1450 insertions(+), 1583 deletions(-) diff --git a/repertory/librepertory/include/app_config.hpp b/repertory/librepertory/include/app_config.hpp index 237e62b0..7710236a 100644 --- a/repertory/librepertory/include/app_config.hpp +++ b/repertory/librepertory/include/app_config.hpp @@ -30,29 +30,29 @@ namespace repertory { class app_config final { public: - [[nodiscard]] static auto default_agent_name(const provider_type &prov) - -> std::string; + [[nodiscard]] static auto + default_agent_name(const provider_type &prov) -> std::string; - [[nodiscard]] static auto default_api_port(const provider_type &prov) - -> std::uint16_t; + [[nodiscard]] static auto + default_api_port(const provider_type &prov) -> std::uint16_t; - [[nodiscard]] static auto default_data_directory(const provider_type &prov) - -> std::string; + [[nodiscard]] static auto + default_data_directory(const provider_type &prov) -> std::string; - [[nodiscard]] static auto default_remote_port(const provider_type &prov) - -> std::uint16_t; + [[nodiscard]] static auto + default_remote_port(const provider_type &prov) -> std::uint16_t; - [[nodiscard]] static auto default_rpc_port(const provider_type &prov) - -> std::uint16_t; + [[nodiscard]] static auto + default_rpc_port(const provider_type &prov) -> std::uint16_t; - [[nodiscard]] static auto get_provider_api_password(const provider_type &prov) - -> std::string; + [[nodiscard]] static auto + get_provider_api_password(const provider_type &prov) -> std::string; - [[nodiscard]] static auto get_provider_display_name(const provider_type &prov) - -> std::string; + [[nodiscard]] static auto + get_provider_display_name(const provider_type &prov) -> std::string; - [[nodiscard]] static auto get_provider_name(const provider_type &prov) - -> std::string; + [[nodiscard]] static auto + get_provider_name(const provider_type &prov) -> std::string; public: app_config(const provider_type &prov, const std::string &data_directory = ""); @@ -71,7 +71,7 @@ private: bool enable_comm_duration_events_; bool enable_drive_events_; bool enable_max_cache_size_; -#ifdef _WIN32 +#if defined(_WIN32) bool enable_mount_manager_; #endif bool enable_remote_mount_; @@ -183,7 +183,7 @@ public: return encrypt_config_; } -#ifdef _WIN32 +#if defined(_WIN32) [[nodiscard]] auto get_enable_mount_manager() const -> bool { return enable_mount_manager_; } @@ -337,7 +337,7 @@ public: set_value(enable_max_cache_size_, enable_max_cache_size); } -#ifdef _WIN32 +#if defined(_WIN32) void set_enable_mount_manager(bool 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); } -#ifdef PROJECT_TESTING +#if defined(PROJECT_TESTING) void set_host_config(host_config hc) { config_changed_ = true; hc_ = std::move(hc); diff --git a/repertory/librepertory/include/common.hpp b/repertory/librepertory/include/common.hpp index 58e6a463..7370d0a5 100644 --- a/repertory/librepertory/include/common.hpp +++ b/repertory/librepertory/include/common.hpp @@ -46,10 +46,14 @@ #endif // defined(__GNUC__) // clang-format on -#ifdef __cplusplus +#if defined(__cplusplus) REPERTORY_IGNORE_WARNINGS_ENABLE() -#ifdef _WIN32 +#if defined(_WIN32) +#define WINVER 0x0602 +#define _WIN32_WINNT WINVER +#define WIN32_LEAN_AND_MEAN + #include #include #include @@ -69,20 +73,20 @@ REPERTORY_IGNORE_WARNINGS_ENABLE() #include #include #include -#ifdef __linux__ +#if defined(__linux__) #include #endif #include -#ifdef HAS_SETXATTR +#if defined(HAS_SETXATTR) #include #include #endif -#ifdef __APPLE__ +#if defined(__APPLE__) #include #include #include #endif -#if __APPLE__ +#if defined(__APPLE__) #include #include #endif @@ -134,7 +138,7 @@ template #include "sqlite3.h" #include "uuid.h" -#ifdef _WIN32 +#if defined(_WIN32) #include #include "winfsp/winfsp.hpp" #else @@ -161,7 +165,7 @@ using json = nlohmann::json; #define REPERTORY_MIN_REMOTE_VERSION "2.0.0" #define REPERTORY_W L"repertory" -#ifdef _WIN32 +#if defined(_WIN32) #define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE #define REPERTORY_API_INVALID_HANDLE static_cast(-1) using native_handle = HANDLE; @@ -173,20 +177,20 @@ using native_handle = int; constexpr const auto NANOS_PER_SECOND = 1000000000L; -#ifdef _WIN32 -#ifdef CreateDirectory +#if defined(_WIN32) +#if defined(CreateDirectory) #undef CreateDirectory #endif -#ifdef CreateFile +#if defined(CreateFile) #undef CreateFile #endif -#ifdef DeleteFile +#if defined(DeleteFile) #undef DeleteFile #endif -#ifdef RemoveDirectory +#if defined(RemoveDirectory) #undef RemoveDirectory #endif @@ -255,8 +259,8 @@ constexpr const auto NANOS_PER_SECOND = 1000000000L; #define SETATTR_WANTS_FLAGS(attr) ((attr)->valid & (1 << 31)) #endif // SETATTR_WANTS_FLAGS -#ifndef _WIN32 -#ifdef __APPLE__ +#if !defined(_WIN32) +#if defined(__APPLE__) #define G_PREFIX "org" #define G_KAUTH_FILESEC_XATTR G_PREFIX ".apple.system.Security" #define A_PREFIX "com" @@ -295,7 +299,7 @@ constexpr const auto NANOS_PER_SECOND = 1000000000L; #define WINFSP_ALLOCATION_UNIT UINT64(4096U) -#ifdef _WIN32 +#if defined(_WIN32) #define UTIME_NOW ((1l << 30) - 1l) #define UTIME_OMIT ((1l << 30) - 2l) #define CONVERT_STATUS_NOT_IMPLEMENTED(e) e @@ -346,7 +350,7 @@ using WCHAR = wchar_t; #define GENERIC_EXECUTE (0x20000000L) #define GENERIC_ALL (0x10000000L) -#define INVALID_FILE_ATTRIBUTES ((DWORD)-1) +#define INVALID_FILE_ATTRIBUTES ((DWORD) - 1) #define MAX_PATH 260 diff --git a/repertory/librepertory/include/drives/directory_iterator.hpp b/repertory/librepertory/include/drives/directory_iterator.hpp index 0756c34f..b2491971 100644 --- a/repertory/librepertory/include/drives/directory_iterator.hpp +++ b/repertory/librepertory/include/drives/directory_iterator.hpp @@ -28,7 +28,7 @@ namespace repertory { class directory_iterator final { public: -#ifndef _WIN32 +#if !defined(_WIN32) using populate_stat_callback = std::function; @@ -46,7 +46,7 @@ private: directory_item_list items_; public: -#ifndef _WIN32 +#if !defined(_WIN32) [[nodiscard]] auto fill_buffer(const remote::file_offset &offset, fuse_fill_dir_t filler_function, void *buffer, 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_directory_item(std::size_t offset, directory_item &di) - -> api_error; + [[nodiscard]] auto get_directory_item(std::size_t offset, + directory_item &di) -> api_error; [[nodiscard]] auto get_directory_item(const std::string &api_path, directory_item &di) -> api_error; @@ -71,8 +71,8 @@ public: auto operator=(const directory_iterator &iterator) noexcept -> directory_iterator &; - auto operator=(directory_iterator &&iterator) noexcept - -> directory_iterator &; + auto + operator=(directory_iterator &&iterator) noexcept -> directory_iterator &; auto operator=(directory_item_list list) noexcept -> directory_iterator &; }; diff --git a/repertory/librepertory/include/drives/fuse/fuse_base.hpp b/repertory/librepertory/include/drives/fuse/fuse_base.hpp index 8b84bbad..9b683ab9 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_base.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_base.hpp @@ -21,7 +21,7 @@ */ #ifndef INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_ #define INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_ -#ifndef _WIN32 +#if !defined(_WIN32) #include "events/event_system.hpp" #include "utils/path_utils.hpp" @@ -78,9 +78,9 @@ private: static void execute_void_callback(const std::string &function_name, const std::function &cb); - static auto execute_void_pointer_callback(const std::string &function_name, - const std::function &cb) - -> void *; + static auto + execute_void_pointer_callback(const std::string &function_name, + const std::function &cb) -> void *; void raise_fuse_event(std::string function_name, const std::string &api_path, int ret, bool disable_logging); @@ -88,7 +88,7 @@ private: private: [[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; #endif // __APPLE__ @@ -103,8 +103,8 @@ private: [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi) -> int; #else - [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid) - -> int; + [[nodiscard]] static auto chown_(const char *path, uid_t uid, + gid_t gid) -> int; #endif [[nodiscard]] static auto create_(const char *path, mode_t mode, @@ -113,15 +113,15 @@ private: static void destroy_(void *ptr); [[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset, - off_t length, struct fuse_file_info *fi) - -> int; + off_t length, + struct fuse_file_info *fi) -> int; #if FUSE_USE_VERSION < 30 [[nodiscard]] static auto fgetattr_(const char *path, struct stat *st, struct fuse_file_info *fi) -> int; #endif -#ifdef __APPLE__ +#if defined(__APPLE__) [[nodiscard]] static auto fsetattr_x_(const char *path, struct setattr_x *attr, struct fuse_file_info *fi) -> int; @@ -140,7 +140,7 @@ private: [[nodiscard]] static auto getattr_(const char *path, struct stat *st) -> int; #endif -#ifdef __APPLE__ +#if defined(__APPLE__) [[nodiscard]] static auto getxtimes_(const char *path, struct timespec *bkuptime, struct timespec *crtime) -> int; @@ -155,8 +155,8 @@ private: [[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int; - [[nodiscard]] static auto open_(const char *path, struct fuse_file_info *fi) - -> int; + [[nodiscard]] static auto open_(const char *path, + struct fuse_file_info *fi) -> int; [[nodiscard]] static auto opendir_(const char *path, struct fuse_file_info *fi) -> int; @@ -173,8 +173,8 @@ private: #else [[nodiscard]] static auto readdir_(const char *path, void *buf, fuse_fill_dir_t fuse_fill_dir, - off_t offset, struct fuse_file_info *fi) - -> int; + off_t offset, + struct fuse_file_info *fi) -> int; #endif [[nodiscard]] static auto release_(const char *path, @@ -192,8 +192,8 @@ private: [[nodiscard]] static auto rmdir_(const char *path) -> int; -#ifdef HAS_SETXATTR -#ifdef __APPLE__ +#if defined(HAS_SETXATTR) +#if defined(__APPLE__) [[nodiscard]] static auto getxattr_(const char *path, const char *name, char *value, size_t size, uint32_t position) -> int; @@ -206,28 +206,27 @@ private: [[nodiscard]] static auto listxattr_(const char *path, char *buffer, size_t size) -> int; - [[nodiscard]] static auto removexattr_(const char *path, const char *name) - -> int; + [[nodiscard]] static auto removexattr_(const char *path, + const char *name) -> int; -#ifdef __APPLE__ +#if defined(__APPLE__) [[nodiscard]] static auto setxattr_(const char *path, const char *name, const char *value, size_t size, int flags, uint32_t position) -> int; #else // __APPLE__ [[nodiscard]] static auto setxattr_(const char *path, const char *name, - const char *value, size_t size, int flags) - -> int; + const char *value, size_t size, + int flags) -> int; #endif // __APPLE__ #endif // HAS_SETXATTR -#ifdef __APPLE__ - [[nodiscard]] static auto setattr_x_(const char *path, struct setattr_x *attr) - -> int; +#if defined(__APPLE__) + [[nodiscard]] static auto setattr_x_(const char *path, + struct setattr_x *attr) -> int; - [[nodiscard]] static auto setbkuptime_(const char *path, - const struct timespec *bkuptime) - -> int; + [[nodiscard]] static auto + setbkuptime_(const char *path, const struct timespec *bkuptime) -> int; [[nodiscard]] static auto setchgtime_(const char *path, const struct timespec *chgtime) -> int; @@ -237,12 +236,12 @@ private: [[nodiscard]] static auto setvolname_(const char *volname) -> int; - [[nodiscard]] static auto statfs_x_(const char *path, struct statfs *stbuf) - -> int; + [[nodiscard]] static auto statfs_x_(const char *path, + struct statfs *stbuf) -> int; #else // __APPLE__ - [[nodiscard]] static auto statfs_(const char *path, struct statvfs *stbuf) - -> int; + [[nodiscard]] static auto statfs_(const char *path, + struct statvfs *stbuf) -> int; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 @@ -268,12 +267,12 @@ private: struct fuse_file_info *fi) -> int; protected: - [[nodiscard]] virtual auto access_impl(std::string /*api_path*/, int /*mask*/) - -> api_error { + [[nodiscard]] virtual auto access_impl(std::string /*api_path*/, + int /*mask*/) -> api_error { return api_error::not_implemented; } -#ifdef __APPLE__ +#if defined(__APPLE__) [[nodiscard]] virtual auto chflags_impl(std::string /*api_path*/, uint32_t /*flags*/) -> api_error { return api_error::not_implemented; @@ -281,10 +280,9 @@ protected: #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - [[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/, - mode_t /*mode*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + chmod_impl(std::string /*api_path*/, mode_t /*mode*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } #else @@ -295,10 +293,9 @@ protected: #endif #if FUSE_USE_VERSION >= 30 - [[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/, - gid_t /*gid*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + chown_impl(std::string /*api_path*/, uid_t /*uid*/, gid_t /*gid*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } #else @@ -308,10 +305,9 @@ protected: } #endif - [[nodiscard]] virtual auto create_impl(std::string /*api_path*/, - mode_t /*mode*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + create_impl(std::string /*api_path*/, mode_t /*mode*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } @@ -319,48 +315,43 @@ protected: [[nodiscard]] virtual auto fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/, - off_t /*length*/, struct fuse_file_info * /*fi*/) - -> api_error { + off_t /*length*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto fgetattr_impl(std::string /*api_path*/, - struct stat * /*st*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + fgetattr_impl(std::string /*api_path*/, struct stat * /*st*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } -#ifdef __APPLE__ - [[nodiscard]] virtual auto fsetattr_x_impl(std::string /*api_path*/, - struct setattr_x * /*attr*/, - struct fuse_file_info * /*fi*/) - -> api_error { +#if defined(__APPLE__) + [[nodiscard]] virtual auto + fsetattr_x_impl(std::string /*api_path*/, struct setattr_x * /*attr*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } #endif // __APPLE__ - [[nodiscard]] virtual auto fsync_impl(std::string /*api_path*/, - int /*datasync*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + fsync_impl(std::string /*api_path*/, int /*datasync*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } #if FUSE_USE_VERSION < 30 - [[nodiscard]] virtual auto ftruncate_impl(std::string /*api_path*/, - off_t /*size*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + ftruncate_impl(std::string /*api_path*/, off_t /*size*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } #endif #if FUSE_USE_VERSION >= 30 - [[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/, - struct stat * /*st*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + getattr_impl(std::string /*api_path*/, struct stat * /*st*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } #else @@ -370,18 +361,17 @@ protected: } #endif -#ifdef __APPLE__ - [[nodiscard]] virtual auto getxtimes_impl(std::string /*api_path*/, - struct timespec * /*bkuptime*/, - struct timespec * /*crtime*/) - -> api_error { +#if defined(__APPLE__) + [[nodiscard]] virtual auto + getxtimes_impl(std::string /*api_path*/, struct timespec * /*bkuptime*/, + struct timespec * /*crtime*/) -> api_error { return api_error::not_implemented; } #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) - -> void *; + virtual auto init_impl(struct fuse_conn_info *conn, + struct fuse_config *cfg) -> void *; #else virtual auto init_impl(struct fuse_conn_info *conn) -> void *; #endif @@ -391,15 +381,15 @@ protected: return api_error::not_implemented; } - [[nodiscard]] virtual auto open_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + open_impl(std::string /*api_path*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto opendir_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + opendir_impl(std::string /*api_path*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } @@ -414,8 +404,8 @@ protected: [[nodiscard]] virtual auto readdir_impl(std::string /*api_path*/, void * /*buf*/, fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/, - struct fuse_file_info * /*fi*/, fuse_readdir_flags /*flags*/) - -> api_error { + struct fuse_file_info * /*fi*/, + fuse_readdir_flags /*flags*/) -> api_error { return api_error::not_implemented; } #else @@ -427,15 +417,15 @@ protected: } #endif - [[nodiscard]] virtual auto release_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + release_impl(std::string /*api_path*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto releasedir_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + releasedir_impl(std::string /*api_path*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } @@ -446,9 +436,9 @@ protected: return api_error::not_implemented; } #else - [[nodiscard]] virtual auto rename_impl(std::string /*from_api_path*/, - std::string /*to_api_path*/) - -> api_error { + [[nodiscard]] virtual auto + rename_impl(std::string /*from_api_path*/, + std::string /*to_api_path*/) -> api_error { return api_error::not_implemented; } #endif @@ -457,8 +447,8 @@ protected: return api_error::not_implemented; } -#ifdef HAS_SETXATTR -#ifdef __APPLE__ +#if defined(HAS_SETXATTR) +#if defined(__APPLE__) [[nodiscard]] virtual auto getxattr_impl(std::string /*api_path*/, const char * /*name*/, char * /*value*/, size_t /*size*/, uint32_t /*position*/, @@ -468,8 +458,8 @@ protected: #else // __APPLE__ [[nodiscard]] virtual auto getxattr_impl(std::string /*api_path*/, const char * /*name*/, - char * /*value*/, size_t /*size*/, int & /*attribute_size*/) - -> api_error { + char * /*value*/, size_t /*size*/, + int & /*attribute_size*/) -> api_error { return api_error::not_implemented; } #endif // __APPLE__ @@ -480,13 +470,13 @@ protected: return api_error::not_implemented; } - [[nodiscard]] virtual auto removexattr_impl(std::string /*api_path*/, - const char * /*name*/) - -> api_error { + [[nodiscard]] virtual auto + removexattr_impl(std::string /*api_path*/, + const char * /*name*/) -> api_error { return api_error::not_implemented; } -#ifdef __APPLE__ +#if defined(__APPLE__) [[nodiscard]] virtual auto setxattr_impl(std::string /*api_path*/, const char * /*name*/, const char * /*value*/, @@ -495,19 +485,20 @@ protected: return api_error::not_implemented; } #else // __APPLE__ - [[nodiscard]] virtual auto - setxattr_impl(std::string /*api_path*/, const char * /*name*/, - const char * /*value*/, size_t /*size*/, int /*flags*/) - -> api_error { + [[nodiscard]] virtual auto setxattr_impl(std::string /*api_path*/, + const char * /*name*/, + const char * /*value*/, + size_t /*size*/, + int /*flags*/) -> api_error { return api_error::not_implemented; } #endif // __APPLE__ #endif // HAS_SETXATTR -#ifdef __APPLE__ - [[nodiscard]] virtual auto setattr_x_impl(std::string /*api_path*/, - struct setattr_x * /*attr*/) - -> api_error { +#if defined(__APPLE__) + [[nodiscard]] virtual auto + setattr_x_impl(std::string /*api_path*/, + struct setattr_x * /*attr*/) -> api_error { return api_error::not_implemented; } @@ -518,40 +509,39 @@ protected: } [[nodiscard]] virtual auto - setchgtime_impl(std::string /*api_path*/, const struct timespec * /*chgtime*/) - -> api_error { + setchgtime_impl(std::string /*api_path*/, + const struct timespec * /*chgtime*/) -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto setcrtime_impl(std::string /*api_path*/, - const struct timespec * /*crtime*/) - -> api_error { + [[nodiscard]] virtual auto + setcrtime_impl(std::string /*api_path*/, + const struct timespec * /*crtime*/) -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto setvolname_impl(const char * /*volname*/) - -> api_error { + [[nodiscard]] virtual auto + setvolname_impl(const char * /*volname*/) -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto statfs_x_impl(std::string /*api_path*/, - struct statfs * /*stbuf*/) - -> api_error { + [[nodiscard]] virtual auto + statfs_x_impl(std::string /*api_path*/, + struct statfs * /*stbuf*/) -> api_error { return api_error::not_implemented; } #else // __APPLE__ - [[nodiscard]] virtual auto statfs_impl(std::string /*api_path*/, - struct statvfs * /*stbuf*/) - -> api_error { + [[nodiscard]] virtual auto + statfs_impl(std::string /*api_path*/, + struct statvfs * /*stbuf*/) -> api_error { return api_error::not_implemented; } #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - [[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/, - off_t /*size*/, - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + truncate_impl(std::string /*api_path*/, off_t /*size*/, + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } #else @@ -561,22 +551,21 @@ protected: } #endif - [[nodiscard]] virtual auto unlink_impl(std::string /*api_path*/) - -> api_error { + [[nodiscard]] virtual auto + unlink_impl(std::string /*api_path*/) -> api_error { return api_error::not_implemented; } #if FUSE_USE_VERSION >= 30 - [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, - const struct timespec /*tv*/[2], - struct fuse_file_info * /*fi*/) - -> api_error { + [[nodiscard]] virtual auto + utimens_impl(std::string /*api_path*/, const struct timespec /*tv*/[2], + struct fuse_file_info * /*fi*/) -> api_error { return api_error::not_implemented; } #else - [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, - const struct timespec /*tv*/[2]) - -> api_error { + [[nodiscard]] virtual auto + utimens_impl(std::string /*api_path*/, + const struct timespec /*tv*/[2]) -> api_error { return api_error::not_implemented; } #endif @@ -584,8 +573,8 @@ protected: [[nodiscard]] virtual auto write_impl(std::string /*api_path*/, const char * /*buffer*/, size_t /*write_size*/, off_t /*write_offset*/, - struct fuse_file_info * /*fi*/, std::size_t & /*bytes_written*/) - -> api_error { + struct fuse_file_info * /*fi*/, + std::size_t & /*bytes_written*/) -> api_error { return api_error::not_implemented; } diff --git a/repertory/librepertory/include/drives/fuse/fuse_drive.hpp b/repertory/librepertory/include/drives/fuse/fuse_drive.hpp index efa91590..011a711f 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_drive.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_drive.hpp @@ -21,7 +21,7 @@ */ #ifndef 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 "file_manager/file_manager.hpp" @@ -69,96 +69,93 @@ private: void update_accessed_time(const std::string &api_path); protected: -#ifdef __APPLE__ - [[nodiscard]] auto chflags_impl(std::string api_path, uint32_t flags) - -> api_error override; +#if defined(__APPLE__) + [[nodiscard]] auto chflags_impl(std::string api_path, + uint32_t flags) -> api_error override; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + chmod_impl(std::string api_path, mode_t mode, + struct fuse_file_info *file_info) -> api_error override; #else - [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode) - -> api_error override; + [[nodiscard]] auto chmod_impl(std::string api_path, + mode_t mode) -> api_error override; #endif #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + chown_impl(std::string api_path, uid_t uid, gid_t gid, + struct fuse_file_info *file_info) -> api_error override; #else - [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid) - -> api_error override; + [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, + gid_t gid) -> api_error override; #endif - [[nodiscard]] auto create_impl(std::string api_path, mode_t mode, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + create_impl(std::string api_path, mode_t mode, + struct fuse_file_info *file_info) -> api_error override; void destroy_impl(void *ptr) override; - [[nodiscard]] auto fallocate_impl(std::string api_path, int mode, - off_t offset, off_t length, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + fallocate_impl(std::string api_path, int mode, off_t offset, off_t length, + struct fuse_file_info *file_info) -> api_error override; - [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *st, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + fgetattr_impl(std::string api_path, struct stat *st, + struct fuse_file_info *file_info) -> api_error override; -#ifdef __APPLE__ - [[nodiscard]] auto fsetattr_x_impl(std::string api_path, - struct setattr_x *attr, - struct fuse_file_info *file_info) - -> api_error override; +#if defined(__APPLE__) + [[nodiscard]] auto + fsetattr_x_impl(std::string api_path, struct setattr_x *attr, + struct fuse_file_info *file_info) -> api_error override; #endif // __APPLE__ - [[nodiscard]] auto fsync_impl(std::string api_path, int datasync, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + fsync_impl(std::string api_path, int datasync, + struct fuse_file_info *file_info) -> api_error override; #if FUSE_USE_VERSION < 30 - [[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + ftruncate_impl(std::string api_path, off_t size, + struct fuse_file_info *file_info) -> api_error override; #endif #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *st, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + getattr_impl(std::string api_path, struct stat *st, + struct fuse_file_info *file_info) -> api_error override; #else - [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *st) - -> api_error override; + [[nodiscard]] auto getattr_impl(std::string api_path, + struct stat *st) -> api_error override; #endif -#ifdef __APPLE__ - [[nodiscard]] auto getxtimes_impl(std::string api_path, - struct timespec *bkuptime, - struct timespec *crtime) - -> api_error override; +#if defined(__APPLE__) + [[nodiscard]] auto + getxtimes_impl(std::string api_path, struct timespec *bkuptime, + struct timespec *crtime) -> api_error override; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) - -> void * override; + auto init_impl(struct fuse_conn_info *conn, + struct fuse_config *cfg) -> void * override; #else auto init_impl(struct fuse_conn_info *conn) -> void * override; #endif - [[nodiscard]] auto mkdir_impl(std::string api_path, mode_t mode) - -> api_error override; + [[nodiscard]] auto mkdir_impl(std::string api_path, + mode_t mode) -> api_error override; void notify_fuse_main_exit(int &ret) override; - [[nodiscard]] auto open_impl(std::string api_path, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + open_impl(std::string api_path, + struct fuse_file_info *file_info) -> api_error override; - [[nodiscard]] auto opendir_impl(std::string api_path, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + opendir_impl(std::string api_path, + struct fuse_file_info *file_info) -> api_error override; [[nodiscard]] auto read_impl(std::string api_path, char *buffer, size_t read_size, off_t read_offset, @@ -166,30 +163,29 @@ protected: std::size_t &bytes_read) -> api_error override; #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, - fuse_fill_dir_t fuse_fill_dir, off_t offset, - struct fuse_file_info *file_info, - fuse_readdir_flags flags) - -> api_error override; + [[nodiscard]] auto + readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, + off_t offset, struct fuse_file_info *file_info, + fuse_readdir_flags flags) -> api_error override; #else - [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, - fuse_fill_dir_t fuse_fill_dir, off_t offset, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, + off_t offset, + struct fuse_file_info *file_info) -> api_error override; #endif - [[nodiscard]] auto release_impl(std::string api_path, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + release_impl(std::string api_path, + struct fuse_file_info *file_info) -> api_error override; - [[nodiscard]] auto releasedir_impl(std::string api_path, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + releasedir_impl(std::string api_path, + struct fuse_file_info *file_info) -> api_error override; #if FUSE_USE_VERSION >= 30 [[nodiscard]] auto rename_impl(std::string from_api_path, - std::string to_api_path, unsigned int flags) - -> api_error override; + std::string to_api_path, + unsigned int flags) -> api_error override; #else [[nodiscard]] auto rename_impl(std::string from_api_path, std::string to_api_path) -> api_error override; @@ -197,13 +193,13 @@ protected: [[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, char *value, size_t size, - int &attribute_size, uint32_t *position) - -> api_error; + int &attribute_size, + uint32_t *position) -> api_error; -#ifdef __APPLE__ +#if defined(__APPLE__) [[nodiscard]] auto getxattr_impl(std::string api_path, const char *name, char *value, size_t size, uint32_t position, int &attribute_size) -> api_error override; @@ -217,73 +213,71 @@ protected: size_t size, int &required_size, bool &return_size) -> api_error override; - [[nodiscard]] auto removexattr_impl(std::string api_path, const char *name) - -> api_error override; + [[nodiscard]] auto removexattr_impl(std::string api_path, + const char *name) -> api_error override; -#ifdef __APPLE__ +#if defined(__APPLE__) [[nodiscard]] auto setxattr_impl(std::string api_path, const char *name, const char *value, size_t size, int flags, uint32_t position) -> api_error override; #else // __APPLE__ [[nodiscard]] auto setxattr_impl(std::string api_path, const char *name, - const char *value, size_t size, int flags) - -> api_error override; + const char *value, size_t size, + int flags) -> api_error override; #endif // __APPLE__ #endif // HAS_SETXATTR -#ifdef __APPLE__ - [[nodiscard]] auto setattr_x_impl(std::string api_path, - struct setattr_x *attr) - -> api_error override; +#if defined(__APPLE__) + [[nodiscard]] auto + setattr_x_impl(std::string api_path, + struct setattr_x *attr) -> api_error override; - [[nodiscard]] auto setbkuptime_impl(std::string api_path, - const struct timespec *bkuptime) - -> api_error override; + [[nodiscard]] auto + setbkuptime_impl(std::string api_path, + const struct timespec *bkuptime) -> api_error override; - [[nodiscard]] auto setchgtime_impl(std::string api_path, - const struct timespec *chgtime) - -> api_error override; + [[nodiscard]] auto + setchgtime_impl(std::string api_path, + const struct timespec *chgtime) -> api_error override; - [[nodiscard]] auto setcrtime_impl(std::string api_path, - const struct timespec *crtime) - -> api_error override; + [[nodiscard]] auto + setcrtime_impl(std::string api_path, + const struct timespec *crtime) -> 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) - -> api_error override; + [[nodiscard]] auto statfs_x_impl(std::string api_path, + struct statfs *stbuf) -> api_error override; #else // __APPLE__ - [[nodiscard]] auto statfs_impl(std::string api_path, struct statvfs *stbuf) - -> api_error override; + [[nodiscard]] auto statfs_impl(std::string api_path, + struct statvfs *stbuf) -> api_error override; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto truncate_impl(std::string api_path, off_t size, - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + truncate_impl(std::string api_path, off_t size, + struct fuse_file_info *file_info) -> api_error override; #else - [[nodiscard]] auto truncate_impl(std::string api_path, off_t size) - -> api_error override; + [[nodiscard]] auto truncate_impl(std::string api_path, + off_t size) -> api_error override; #endif [[nodiscard]] auto unlink_impl(std::string api_path) -> api_error override; #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto utimens_impl(std::string api_path, - const struct timespec tv[2], - struct fuse_file_info *file_info) - -> api_error override; + [[nodiscard]] auto + utimens_impl(std::string api_path, const struct timespec tv[2], + struct fuse_file_info *file_info) -> api_error override; #else - [[nodiscard]] auto utimens_impl(std::string api_path, - const struct timespec tv[2]) - -> api_error override; + [[nodiscard]] auto + utimens_impl(std::string api_path, + const struct timespec tv[2]) -> api_error override; #endif - [[nodiscard]] auto write_impl(std::string api_path, const char *buffer, - size_t write_size, off_t write_offset, - struct fuse_file_info *file_info, - std::size_t &bytes_written) - -> api_error override; + [[nodiscard]] auto + write_impl(std::string api_path, const char *buffer, size_t write_size, + off_t write_offset, struct fuse_file_info *file_info, + std::size_t &bytes_written) -> api_error override; public: [[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 -> directory_item_list override; - [[nodiscard]] auto get_file_size(const std::string &api_path) const - -> std::uint64_t override; + [[nodiscard]] auto + get_file_size(const std::string &api_path) const -> std::uint64_t override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, - api_meta_map &meta) const - -> api_error override; + [[nodiscard]] auto + get_item_meta(const std::string &api_path, + api_meta_map &meta) const -> api_error override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, - const std::string &name, - std::string &value) const - -> api_error override; + [[nodiscard]] auto + get_item_meta(const std::string &api_path, const std::string &name, + std::string &value) const -> api_error 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, std::string &volume_label) const override; - [[nodiscard]] auto is_processing(const std::string &api_path) const - -> bool override; + [[nodiscard]] auto + is_processing(const std::string &api_path) const -> bool override; - [[nodiscard]] auto rename_directory(const std::string &from_api_path, - const std::string &to_api_path) - -> int override; + [[nodiscard]] auto + rename_directory(const std::string &from_api_path, + const std::string &to_api_path) -> int override; [[nodiscard]] auto rename_file(const std::string &from_api_path, - const std::string &to_api_path, bool overwrite) - -> int override; + const std::string &to_api_path, + bool overwrite) -> int override; void set_item_meta(const std::string &api_path, const std::string &key, const std::string &value) override; diff --git a/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp b/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp index b89d1b50..9e44c8eb 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp @@ -21,7 +21,7 @@ */ #ifndef 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/i_fuse_drive.hpp" @@ -43,17 +43,16 @@ public: auto operator=(fuse_drive_base &&) -> fuse_drive_base & = delete; protected: - [[nodiscard]] auto access_impl(std::string api_path, int mask) - -> api_error override; + [[nodiscard]] auto access_impl(std::string api_path, + int mask) -> api_error override; protected: - [[nodiscard]] auto check_access(const std::string &api_path, int mask) const - -> api_error; + [[nodiscard]] auto check_access(const std::string &api_path, + int mask) const -> api_error; - [[nodiscard]] auto - check_and_perform(const std::string &api_path, int parent_mask, - const std::function &action) - -> api_error; + [[nodiscard]] auto check_and_perform( + const std::string &api_path, int parent_mask, + const std::function &action) -> api_error; [[nodiscard]] auto get_current_gid() const -> gid_t; @@ -63,62 +62,57 @@ protected: [[nodiscard]] auto get_effective_uid() const -> uid_t; - [[nodiscard]] static auto check_open_flags(int flags, int mask, - const api_error &fail_error) - -> api_error; + [[nodiscard]] static auto + check_open_flags(int flags, int mask, + const api_error &fail_error) -> api_error; [[nodiscard]] auto check_owner(const api_meta_map &meta) const -> api_error; - [[nodiscard]] static auto check_readable(int flags, - const api_error &fail_error) - -> api_error; + [[nodiscard]] static auto + check_readable(int flags, const api_error &fail_error) -> api_error; - [[nodiscard]] static auto check_writeable(int flags, - const api_error &fail_error) - -> api_error; + [[nodiscard]] static auto + check_writeable(int flags, const api_error &fail_error) -> api_error; -#ifdef __APPLE__ - [[nodiscard]] static auto get_flags_from_meta(const api_meta_map &meta) - -> __uint32_t; +#if defined(__APPLE__) + [[nodiscard]] static auto + get_flags_from_meta(const api_meta_map &meta) -> __uint32_t; #endif // __APPLE__ - [[nodiscard]] static auto get_gid_from_meta(const api_meta_map &meta) - -> gid_t; + [[nodiscard]] static auto + get_gid_from_meta(const api_meta_map &meta) -> gid_t; - [[nodiscard]] static auto get_mode_from_meta(const api_meta_map &meta) - -> mode_t; + [[nodiscard]] static auto + get_mode_from_meta(const api_meta_map &meta) -> mode_t; static void get_timespec_from_meta(const api_meta_map &meta, const std::string &name, struct timespec &ts); - [[nodiscard]] static auto get_uid_from_meta(const api_meta_map &meta) - -> uid_t; + [[nodiscard]] static auto + get_uid_from_meta(const api_meta_map &meta) -> uid_t; -#ifdef __APPLE__ - [[nodiscard]] auto parse_xattr_parameters(const char *name, - const uint32_t &position, - std::string &attribute_name, - const std::string &api_path) - -> api_error; +#if defined(__APPLE__) + [[nodiscard]] auto + parse_xattr_parameters(const char *name, const uint32_t &position, + std::string &attribute_name, + const std::string &api_path) -> api_error; #else - [[nodiscard]] auto parse_xattr_parameters(const char *name, - std::string &attribute_name, - const std::string &api_path) - -> api_error; + [[nodiscard]] auto + parse_xattr_parameters(const char *name, std::string &attribute_name, + const std::string &api_path) -> api_error; #endif -#ifdef __APPLE__ +#if defined(__APPLE__) [[nodiscard]] auto parse_xattr_parameters(const char *name, const char *value, size_t size, const uint32_t &position, std::string &attribute_name, const std::string &api_path) -> api_error; #else - [[nodiscard]] auto parse_xattr_parameters(const char *name, const char *value, - size_t size, - std::string &attribute_name, - const std::string &api_path) - -> api_error; + [[nodiscard]] auto + parse_xattr_parameters(const char *name, const char *value, size_t size, + std::string &attribute_name, + const std::string &api_path) -> api_error; #endif static void populate_stat(const std::string &api_path, @@ -131,8 +125,8 @@ protected: struct timespec &ts); public: - [[nodiscard]] auto check_owner(const std::string &api_path) const - -> api_error override; + [[nodiscard]] auto + check_owner(const std::string &api_path) const -> api_error override; [[nodiscard]] auto check_parent_access(const std::string &api_path, int mask) const -> api_error override; diff --git a/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp b/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp index daf4f753..6aafa00e 100644 --- a/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp +++ b/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp @@ -21,7 +21,7 @@ */ #ifndef INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_ #define INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_ -#ifndef _WIN32 +#if !defined(_WIN32) #include "types/repertory.hpp" @@ -30,32 +30,29 @@ class i_fuse_drive { INTERFACE_SETUP(i_fuse_drive); public: - [[nodiscard]] virtual auto 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 + check_owner(const std::string &api_path) const -> api_error = 0; [[nodiscard]] virtual auto - get_directory_item_count(const std::string &api_path) const - -> std::uint64_t = 0; + check_parent_access(const std::string &api_path, + 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 - get_directory_items(const std::string &api_path) const - -> directory_item_list = 0; + get_file_size(const std::string &api_path) const -> std::uint64_t = 0; - [[nodiscard]] virtual auto get_file_size(const std::string &api_path) const - -> std::uint64_t = 0; + [[nodiscard]] virtual auto + 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, - api_meta_map &meta) 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_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; @@ -66,12 +63,12 @@ public: virtual void get_volume_info(UINT64 &total_size, UINT64 &free_size, std::string &volume_label) const = 0; - [[nodiscard]] virtual auto is_processing(const std::string &api_path) const - -> bool = 0; + [[nodiscard]] virtual auto + is_processing(const std::string &api_path) const -> bool = 0; - [[nodiscard]] virtual auto rename_directory(const std::string &from_api_path, - const std::string &to_api_path) - -> int = 0; + [[nodiscard]] virtual auto + rename_directory(const std::string &from_api_path, + const std::string &to_api_path) -> int = 0; [[nodiscard]] virtual auto rename_file(const std::string &from_api_path, const std::string &to_api_path, diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp index 01295866..3638f5d2 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp @@ -21,7 +21,7 @@ */ #ifndef 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/remotefuse/i_remote_instance.hpp" @@ -57,94 +57,92 @@ private: struct stat &unix_st); protected: - [[nodiscard]] auto access_impl(std::string api_path, int mask) - -> api_error override; + [[nodiscard]] auto access_impl(std::string api_path, + int mask) -> api_error override; -#ifdef __APPLE__ - [[nodiscard]] auto chflags_impl(std::string api_path, uint32_t flags) - -> api_error override; +#if defined(__APPLE__) + [[nodiscard]] auto chflags_impl(std::string api_path, + uint32_t flags) -> api_error override; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + chmod_impl(std::string api_path, mode_t mode, + struct fuse_file_info *f_info) -> api_error override; #else - [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode) - -> api_error override; + [[nodiscard]] auto chmod_impl(std::string api_path, + mode_t mode) -> api_error override; #endif #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + chown_impl(std::string api_path, uid_t uid, gid_t gid, + struct fuse_file_info *f_info) -> api_error override; #else - [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid) - -> api_error override; + [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, + gid_t gid) -> api_error override; #endif - [[nodiscard]] auto create_impl(std::string api_path, mode_t mode, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + create_impl(std::string api_path, mode_t mode, + struct fuse_file_info *f_info) -> api_error override; void destroy_impl(void * /*ptr*/) override; - [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *unix_st, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + fgetattr_impl(std::string api_path, struct stat *unix_st, + struct fuse_file_info *f_info) -> api_error override; -#ifdef __APPLE__ - [[nodiscard]] auto fsetattr_x_impl(std::string api_path, - struct setattr_x *attr, - struct fuse_file_info *f_info) - -> api_error override; +#if defined(__APPLE__) + [[nodiscard]] auto + fsetattr_x_impl(std::string api_path, struct setattr_x *attr, + struct fuse_file_info *f_info) -> api_error override; #endif // __APPLE__ - [[nodiscard]] auto fsync_impl(std::string api_path, int datasync, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + fsync_impl(std::string api_path, int datasync, + struct fuse_file_info *f_info) -> api_error override; #if FUSE_USE_VERSION < 30 - [[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + ftruncate_impl(std::string api_path, off_t size, + struct fuse_file_info *f_info) -> api_error override; #endif #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *unix_st, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + getattr_impl(std::string api_path, struct stat *unix_st, + struct fuse_file_info *f_info) -> api_error override; #else - [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *unix_st) - -> api_error override; + [[nodiscard]] auto getattr_impl(std::string api_path, + struct stat *unix_st) -> api_error override; #endif -#ifdef __APPLE__ - [[nodiscard]] auto getxtimes_impl(std::string api_path, - struct timespec *bkuptime, - struct timespec *crtime) - -> api_error override; +#if defined(__APPLE__) + [[nodiscard]] auto + getxtimes_impl(std::string api_path, struct timespec *bkuptime, + struct timespec *crtime) -> api_error override; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) - -> void * override; + auto init_impl(struct fuse_conn_info *conn, + struct fuse_config *cfg) -> void * override; #else auto init_impl(struct fuse_conn_info *conn) -> void * override; #endif - [[nodiscard]] auto mkdir_impl(std::string api_path, mode_t mode) - -> api_error override; + [[nodiscard]] auto mkdir_impl(std::string api_path, + mode_t mode) -> api_error override; void notify_fuse_main_exit(int &ret) override; - [[nodiscard]] auto open_impl(std::string api_path, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + open_impl(std::string api_path, + struct fuse_file_info *f_info) -> api_error override; - [[nodiscard]] auto opendir_impl(std::string api_path, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + opendir_impl(std::string api_path, + struct fuse_file_info *f_info) -> api_error override; [[nodiscard]] auto read_impl(std::string api_path, char *buffer, size_t read_size, off_t read_offset, @@ -152,30 +150,29 @@ protected: std::size_t &bytes_read) -> api_error override; #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, - fuse_fill_dir_t fuse_fill_dir, off_t offset, - struct fuse_file_info *f_info, - fuse_readdir_flags flags) - -> api_error override; + [[nodiscard]] auto + readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, + off_t offset, struct fuse_file_info *f_info, + fuse_readdir_flags flags) -> api_error override; #else - [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, - fuse_fill_dir_t fuse_fill_dir, off_t offset, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, + off_t offset, + struct fuse_file_info *f_info) -> api_error override; #endif - [[nodiscard]] auto release_impl(std::string api_path, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + release_impl(std::string api_path, + struct fuse_file_info *f_info) -> api_error override; - [[nodiscard]] auto releasedir_impl(std::string api_path, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + releasedir_impl(std::string api_path, + struct fuse_file_info *f_info) -> api_error override; #if FUSE_USE_VERSION >= 30 [[nodiscard]] auto rename_impl(std::string from_api_path, - std::string to_api_path, unsigned int flags) - -> api_error override; + std::string to_api_path, + unsigned int flags) -> api_error override; #else [[nodiscard]] auto rename_impl(std::string from_api_path, std::string to_api_path) -> api_error override; @@ -183,61 +180,59 @@ protected: [[nodiscard]] auto rmdir_impl(std::string api_path) -> api_error override; -#ifdef __APPLE__ - [[nodiscard]] auto setattr_x_impl(std::string api_path, - struct setattr_x *attr) - -> api_error override; +#if defined(__APPLE__) + [[nodiscard]] auto + setattr_x_impl(std::string api_path, + struct setattr_x *attr) -> api_error override; - [[nodiscard]] auto setbkuptime_impl(std::string api_path, - const struct timespec *bkuptime) - -> api_error override; + [[nodiscard]] auto + setbkuptime_impl(std::string api_path, + const struct timespec *bkuptime) -> api_error override; - [[nodiscard]] auto setchgtime_impl(std::string api_path, - const struct timespec *chgtime) - -> api_error override; + [[nodiscard]] auto + setchgtime_impl(std::string api_path, + const struct timespec *chgtime) -> api_error override; - [[nodiscard]] auto setcrtime_impl(std::string api_path, - const struct timespec *crtime) - -> api_error override; + [[nodiscard]] auto + setcrtime_impl(std::string api_path, + const struct timespec *crtime) -> api_error override; - [[nodiscard]] virtual auto setvolname_impl(const char *volname) - -> api_error override; + [[nodiscard]] virtual auto + setvolname_impl(const char *volname) -> api_error override; - [[nodiscard]] auto statfs_x_impl(std::string api_path, struct statfs *stbuf) - -> api_error override; + [[nodiscard]] auto statfs_x_impl(std::string api_path, + struct statfs *stbuf) -> api_error override; #else // __APPLE__ - [[nodiscard]] auto statfs_impl(std::string api_path, struct statvfs *stbuf) - -> api_error override; + [[nodiscard]] auto statfs_impl(std::string api_path, + struct statvfs *stbuf) -> api_error override; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto truncate_impl(std::string api_path, off_t size, - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + truncate_impl(std::string api_path, off_t size, + struct fuse_file_info *f_info) -> api_error override; #else - [[nodiscard]] auto truncate_impl(std::string api_path, off_t size) - -> api_error override; + [[nodiscard]] auto truncate_impl(std::string api_path, + off_t size) -> api_error override; #endif [[nodiscard]] auto unlink_impl(std::string api_path) -> api_error override; #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto utimens_impl(std::string api_path, - const struct timespec tv[2], - struct fuse_file_info *f_info) - -> api_error override; + [[nodiscard]] auto + utimens_impl(std::string api_path, const struct timespec tv[2], + struct fuse_file_info *f_info) -> api_error override; #else - [[nodiscard]] auto utimens_impl(std::string api_path, - const struct timespec tv[2]) - -> api_error override; + [[nodiscard]] auto + utimens_impl(std::string api_path, + const struct timespec tv[2]) -> api_error override; #endif - [[nodiscard]] auto write_impl(std::string api_path, const char *buffer, - size_t write_size, off_t write_offset, - struct fuse_file_info *f_info, - std::size_t &bytes_written) - -> api_error override; + [[nodiscard]] auto + write_impl(std::string api_path, const char *buffer, size_t write_size, + off_t write_offset, struct fuse_file_info *f_info, + std::size_t &bytes_written) -> api_error override; }; } // namespace remote_fuse } // namespace repertory diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp index c6bbb737..bc8e75f0 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp @@ -21,7 +21,7 @@ */ #ifndef 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/fuse/i_fuse_drive.hpp" @@ -46,9 +46,9 @@ private: [[nodiscard]] static auto empty_as_zero(const json &data) -> std::string; - [[nodiscard]] auto populate_file_info(const std::string &api_path, - remote::file_info &file_info) - -> packet::error_type; + [[nodiscard]] auto + populate_file_info(const std::string &api_path, + remote::file_info &file_info) -> packet::error_type; void populate_file_info(const std::string &api_path, const UINT64 &file_size, const UINT32 &attributes, @@ -72,14 +72,14 @@ public: [[nodiscard]] auto fuse_chmod(const char *path, const remote::file_mode &mode) -> packet::error_type override; - [[nodiscard]] auto fuse_chown(const char *path, const remote::user_id &uid, - const remote::group_id &gid) - -> packet::error_type override; + [[nodiscard]] auto + fuse_chown(const char *path, const remote::user_id &uid, + const remote::group_id &gid) -> packet::error_type override; [[nodiscard]] auto fuse_create(const char *path, const remote::file_mode &mode, - const remote::open_flags &flags, remote::file_handle &handle) - -> packet::error_type override; + const remote::open_flags &flags, + remote::file_handle &handle) -> 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 ;*/ - [[nodiscard]] auto fuse_fgetattr(const char *path, remote::stat &r_stat, - bool &directory, - const remote::file_handle &handle) - -> packet::error_type override; + [[nodiscard]] auto fuse_fgetattr( + const char *path, remote::stat &r_stat, bool &directory, + const remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto fuse_fsetattr_x(const char *path, - const remote::setattr_x &attr, - const remote::file_handle &handle) - -> packet::error_type override; + [[nodiscard]] auto fuse_fsetattr_x( + const char *path, const remote::setattr_x &attr, + const remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto fuse_fsync(const char *path, const std::int32_t &datasync, - const remote::file_handle &handle) - -> packet::error_type override; + [[nodiscard]] auto + fuse_fsync(const char *path, const std::int32_t &datasync, + const remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto fuse_ftruncate(const char *path, - const remote::file_offset &size, - const remote::file_handle &handle) - -> packet::error_type override; + [[nodiscard]] auto fuse_ftruncate( + const char *path, const remote::file_offset &size, + const remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto fuse_getattr(const char *path, remote::stat &r_stat, - bool &directory) - -> packet::error_type override; + [[nodiscard]] auto + fuse_getattr(const char *path, remote::stat &r_stat, + bool &directory) -> packet::error_type override; /*[[nodiscard]] packet::error_type fuse_getxattr(const char *path, const char *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) override ;*/ - [[nodiscard]] auto fuse_getxtimes(const char *path, - remote::file_time &bkuptime, - remote::file_time &crtime) - -> packet::error_type override; + [[nodiscard]] auto + fuse_getxtimes(const char *path, remote::file_time &bkuptime, + remote::file_time &crtime) -> packet::error_type override; [[nodiscard]] auto fuse_init() -> packet::error_type override; @@ -129,30 +125,28 @@ public: *buffer, const remote::file_size &size) override ;*/ [[nodiscard]] auto - fuse_mkdir(const char *path, const remote::file_mode &mode) - -> packet::error_type override; + fuse_mkdir(const char *path, + const remote::file_mode &mode) -> packet::error_type override; - [[nodiscard]] auto fuse_open(const char *path, - const remote::open_flags &flags, - remote::file_handle &handle) - -> packet::error_type override; + [[nodiscard]] auto + fuse_open(const char *path, const remote::open_flags &flags, + remote::file_handle &handle) -> packet::error_type override; [[nodiscard]] auto fuse_opendir(const char *path, remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto fuse_read(const char *path, char *buffer, - const remote::file_size &read_size, - const remote::file_offset &read_offset, - const remote::file_handle &handle) - -> packet::error_type override; + [[nodiscard]] auto + fuse_read(const char *path, char *buffer, const remote::file_size &read_size, + const remote::file_offset &read_offset, + const remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto fuse_rename(const char *from, const char *to) - -> packet::error_type override; + [[nodiscard]] auto fuse_rename(const char *from, + const char *to) -> packet::error_type override; [[nodiscard]] auto fuse_readdir(const char *path, const remote::file_offset &offset, - const remote::file_handle &handle, std::string &item_path) - -> packet::error_type override; + const remote::file_handle &handle, + std::string &item_path) -> packet::error_type override; [[nodiscard]] auto fuse_release(const char *path, const remote::file_handle &handle) @@ -166,8 +160,8 @@ public: * char *name) override * ;*/ - [[nodiscard]] auto fuse_rmdir(const char *path) - -> packet::error_type override; + [[nodiscard]] auto + fuse_rmdir(const char *path) -> packet::error_type override; [[nodiscard]] auto fuse_setattr_x(const char *path, remote::setattr_x &attr) -> packet::error_type override; @@ -184,8 +178,8 @@ public: const remote::file_time &crtime) -> packet::error_type override; - [[nodiscard]] auto fuse_setvolname(const char *volname) - -> packet::error_type override; + [[nodiscard]] auto + fuse_setvolname(const char *volname) -> packet::error_type override; /*[[nodiscard]] packet::error_type fuse_setxattr(const char *path, const char *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 std::int32_t &flags, std::uint32_t position) override ;*/ - [[nodiscard]] auto fuse_statfs(const char *path, std::uint64_t frsize, - remote::statfs &r_stat) - -> packet::error_type override; + [[nodiscard]] auto + fuse_statfs(const char *path, std::uint64_t frsize, + remote::statfs &r_stat) -> packet::error_type override; - [[nodiscard]] auto fuse_statfs_x(const char *path, std::uint64_t bsize, - remote::statfs_x &r_stat) - -> packet::error_type override; + [[nodiscard]] auto + fuse_statfs_x(const char *path, std::uint64_t bsize, + remote::statfs_x &r_stat) -> packet::error_type override; - [[nodiscard]] auto fuse_truncate(const char *path, - const remote::file_offset &size) - -> packet::error_type override; + [[nodiscard]] auto + fuse_truncate(const char *path, + const remote::file_offset &size) -> packet::error_type override; - [[nodiscard]] auto fuse_unlink(const char *path) - -> packet::error_type override; + [[nodiscard]] auto + fuse_unlink(const char *path) -> packet::error_type override; - [[nodiscard]] auto fuse_utimens(const char *path, const remote::file_time *tv, - std::uint64_t op0, std::uint64_t op1) - -> packet::error_type override; + [[nodiscard]] auto + fuse_utimens(const char *path, const remote::file_time *tv, std::uint64_t op0, + std::uint64_t op1) -> packet::error_type override; - [[nodiscard]] auto fuse_write(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) - -> packet::error_type override; + [[nodiscard]] auto + fuse_write(const char *path, const char *buffer, + const remote::file_size &write_size, + const remote::file_offset &write_offset, + const remote::file_handle &handle) -> packet::error_type override; - [[nodiscard]] auto fuse_write_base64(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) - -> packet::error_type override; + [[nodiscard]] auto fuse_write_base64( + const char *path, const char *buffer, const remote::file_size &write_size, + const remote::file_offset &write_offset, + const remote::file_handle &handle) -> packet::error_type override; void set_fuse_uid_gid(const remote::user_id &, const remote::group_id &) override {} // JSON Layer - [[nodiscard]] auto winfsp_get_dir_buffer(PVOID /*file_desc*/, - PVOID *& /*ptr*/) - -> packet::error_type override { + [[nodiscard]] auto + winfsp_get_dir_buffer(PVOID /*file_desc*/, + PVOID *& /*ptr*/) -> packet::error_type override { return STATUS_INVALID_HANDLE; } - [[nodiscard]] auto json_create_directory_snapshot(const std::string &path, - json &json_data) - -> packet::error_type override; + [[nodiscard]] auto json_create_directory_snapshot( + const std::string &path, json &json_data) -> packet::error_type override; [[nodiscard]] auto json_read_directory_snapshot( const std::string &path, const remote::file_handle &handle, std::uint32_t page, json &json_data) -> packet::error_type override; - [[nodiscard]] auto - json_release_directory_snapshot(const std::string &path, - const remote::file_handle &handle) - -> packet::error_type override; + [[nodiscard]] auto json_release_directory_snapshot( + const std::string &path, + const remote::file_handle &handle) -> packet::error_type override; // WinFSP Layer [[nodiscard]] auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) -> packet::error_type override; - [[nodiscard]] auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, - UINT32 flags, BOOLEAN &was_closed) - -> packet::error_type override; + [[nodiscard]] auto + winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags, + BOOLEAN &was_closed) -> packet::error_type override; - [[nodiscard]] auto winfsp_close(PVOID file_desc) - -> packet::error_type override; + [[nodiscard]] auto + winfsp_close(PVOID file_desc) -> packet::error_type override; [[nodiscard]] auto winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, @@ -273,63 +264,57 @@ public: remote::file_info *file_info) -> 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 - winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes, - std::uint64_t * /*security_descriptor_size*/, - std::wstring & /*str_descriptor*/) - -> packet::error_type override; + winfsp_mounted(const std::wstring &location) -> 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 + winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, + PVOID *file_desc, remote::file_info *file_info, + std::string &normalized_name) -> packet::error_type override; - [[nodiscard]] auto winfsp_mounted(const std::wstring &location) - -> packet::error_type override; + [[nodiscard]] auto + 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, - UINT32 granted_access, PVOID *file_desc, - remote::file_info *file_info, - std::string &normalized_name) - -> packet::error_type override; + [[nodiscard]] auto + winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, + PUINT32 bytes_transferred) -> packet::error_type override; - [[nodiscard]] auto 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_read_directory(PVOID file_desc, PWSTR /*pattern*/, PWSTR marker, + json &itemList) -> packet::error_type override; - [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, - UINT32 length, PUINT32 bytes_transferred) - -> 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_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( PVOID file_desc, UINT32 attributes, UINT64 creation_time, UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, remote::file_info *file_info) -> packet::error_type override; - [[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, - remote::file_info *file_info) - -> packet::error_type override; + [[nodiscard]] auto winfsp_set_file_size( + PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, + remote::file_info *file_info) -> packet::error_type override; - [[nodiscard]] auto winfsp_unmounted(const std::wstring &location) - -> packet::error_type override; + [[nodiscard]] auto + winfsp_unmounted(const std::wstring &location) -> packet::error_type override; [[nodiscard]] auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, BOOLEAN write_to_end, BOOLEAN constrained_io, - PUINT32 bytes_transferred, remote::file_info *file_info) - -> packet::error_type override; + PUINT32 bytes_transferred, + remote::file_info *file_info) -> packet::error_type override; }; } // namespace remote_fuse } // namespace repertory diff --git a/repertory/librepertory/include/drives/remote/remote_open_file_table.hpp b/repertory/librepertory/include/drives/remote/remote_open_file_table.hpp index a29b0a3e..f87be7af 100644 --- a/repertory/librepertory/include/drives/remote/remote_open_file_table.hpp +++ b/repertory/librepertory/include/drives/remote/remote_open_file_table.hpp @@ -61,27 +61,27 @@ protected: virtual void delete_open_directory(void *dir) = 0; -#ifdef _WIN32 +#if defined(_WIN32) [[nodiscard]] auto get_directory_buffer(const native_handle &handle, PVOID *&buffer) -> bool; #endif // _WIN32 - [[nodiscard]] auto get_open_file_path(const native_handle &handle) - -> std::string; + [[nodiscard]] auto + get_open_file_path(const native_handle &handle) -> std::string; - [[nodiscard]] auto get_open_info(const native_handle &handle, open_info &oi) - -> bool; + [[nodiscard]] auto get_open_info(const native_handle &handle, + open_info &oi) -> bool; - [[nodiscard]] auto has_open_directory(const std::string &client_id, void *dir) - -> bool; + [[nodiscard]] auto has_open_directory(const std::string &client_id, + void *dir) -> bool; [[nodiscard]] auto has_compat_open_info(const remote::file_handle &handle, int error_return) -> int; template - [[nodiscard]] auto has_open_info(const native_handle &handle, - const error_type &error_return) - -> error_type { + [[nodiscard]] auto + has_open_info(const native_handle &handle, + const error_type &error_return) -> error_type { recur_mutex_lock file_lock(file_mutex_); return ((file_lookup_.find(handle) == file_lookup_.end()) ? error_return : 0); @@ -106,8 +106,8 @@ protected: void set_open_info(const native_handle &handle, open_info oi); public: - [[nodiscard]] auto get_open_file_count(const std::string &file_path) const - -> std::size_t; + [[nodiscard]] auto + get_open_file_count(const std::string &file_path) const -> std::size_t; }; } // namespace repertory diff --git a/repertory/librepertory/include/drives/remote/remote_server_base.hpp b/repertory/librepertory/include/drives/remote/remote_server_base.hpp index a07794f1..d11bba41 100644 --- a/repertory/librepertory/include/drives/remote/remote_server_base.hpp +++ b/repertory/librepertory/include/drives/remote/remote_server_base.hpp @@ -137,7 +137,7 @@ public: allocation_size, &file_desc, &file_info, normalized_name, exists); if (ret == STATUS_SUCCESS) { -#ifdef _WIN32 +#if defined(_WIN32) this->set_client_id(file_desc, client_id); #else this->set_client_id( @@ -277,7 +277,7 @@ public: granted_access, &file_desc, &file_info, normalized_name); if (ret == STATUS_SUCCESS) { -#ifdef _WIN32 +#if defined(_WIN32) this->set_client_id(file_desc, client_id); #else this->set_client_id( @@ -585,7 +585,7 @@ public: remote::file_handle handle{}; if ((ret = this->fuse_create(path.data(), mode, flags, handle)) >= 0) { -#ifdef _WIN32 +#if defined(_WIN32) this->set_compat_client_id(handle, client_id); #else this->set_client_id(static_cast(handle), client_id); @@ -840,7 +840,7 @@ public: remote::file_handle handle; if ((ret = this->fuse_open(&path[0], flags, handle)) >= 0) { -#ifdef _WIN32 +#if defined(_WIN32) this->set_compat_client_id(handle, client_id); #else this->set_client_id(static_cast(handle), client_id); diff --git a/repertory/librepertory/include/drives/winfsp/i_winfsp_drive.hpp b/repertory/librepertory/include/drives/winfsp/i_winfsp_drive.hpp index 33faab46..72de1616 100644 --- a/repertory/librepertory/include/drives/winfsp/i_winfsp_drive.hpp +++ b/repertory/librepertory/include/drives/winfsp/i_winfsp_drive.hpp @@ -21,7 +21,7 @@ */ #ifndef 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/repertory.hpp" @@ -31,25 +31,22 @@ class i_winfsp_drive { INTERFACE_SETUP(i_winfsp_drive); public: - [[nodiscard]] virtual auto - get_directory_item_count(const std::string &api_path) const - -> std::uint64_t = 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 - get_directory_items(const std::string &api_path) const - -> directory_item_list = 0; + get_file_size(const std::string &api_path) const -> std::uint64_t = 0; - [[nodiscard]] virtual auto get_file_size(const std::string &api_path) const - -> std::uint64_t = 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_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, - api_meta_map &meta) const - -> 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 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, std::string &volume_label) const = 0; - [[nodiscard]] virtual auto populate_file_info(const std::string &api_path, - remote::file_info &fi) - -> api_error = 0; + [[nodiscard]] virtual auto + populate_file_info(const std::string &api_path, + remote::file_info &fi) -> api_error = 0; }; } // namespace repertory diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp index 16fc1374..bedf27df 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp @@ -40,7 +40,7 @@ private: packet_client packet_client_; private: -#ifdef _WIN32 +#if defined(_WIN32) #define to_handle(x) (x) #else 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) -> packet::error_type override; - auto json_read_directory_snapshot(const std::string &path, - const remote::file_handle &handle, - std::uint32_t page, json &json_data) - -> packet::error_type override; + auto json_read_directory_snapshot( + const std::string &path, const remote::file_handle &handle, + std::uint32_t page, json &json_data) -> packet::error_type override; auto json_release_directory_snapshot(const std::string &path, const remote::file_handle &handle) -> packet::error_type override; - auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) - -> packet::error_type override; + auto winfsp_can_delete(PVOID file_desc, + PWSTR file_name) -> packet::error_type override; auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags, BOOLEAN &was_closed) -> packet::error_type override; @@ -79,33 +78,32 @@ public: auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) -> packet::error_type override; - auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) - -> packet::error_type override; + auto winfsp_get_dir_buffer(PVOID file_desc, + PVOID *&ptr) -> packet::error_type override; auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info) -> packet::error_type override; - auto winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes, - std::uint64_t *descriptor_size, - std::wstring &string_descriptor) - -> packet::error_type override; + auto winfsp_get_security_by_name( + PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size, + std::wstring &string_descriptor) -> packet::error_type override; auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size, std::string &volume_label) -> packet::error_type override; - auto winfsp_mounted(const std::wstring &location) - -> packet::error_type override; + auto + winfsp_mounted(const std::wstring &location) -> packet::error_type override; auto winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, PVOID *file_desc, - remote::file_info *file_info, std::string &normalized_name) - -> packet::error_type override; + remote::file_info *file_info, + std::string &normalized_name) -> packet::error_type override; - auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, - BOOLEAN replace_attributes, UINT64 allocation_size, - remote::file_info *file_info) - -> packet::error_type override; + auto + winfsp_overwrite(PVOID file_desc, UINT32 attributes, + BOOLEAN replace_attributes, UINT64 allocation_size, + remote::file_info *file_info) -> packet::error_type override; auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, 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, BOOLEAN replace_if_exists) -> packet::error_type override; - auto winfsp_set_basic_info(PVOID file_desc, UINT32 attributes, - UINT64 creation_time, UINT64 last_access_time, - UINT64 last_write_time, UINT64 change_time, - remote::file_info *file_info) - -> packet::error_type override; + auto winfsp_set_basic_info( + PVOID file_desc, UINT32 attributes, UINT64 creation_time, + UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, + remote::file_info *file_info) -> packet::error_type override; - auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, - remote::file_info *file_info) - -> packet::error_type override; + auto winfsp_set_file_size( + PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, + remote::file_info *file_info) -> packet::error_type override; - auto winfsp_unmounted(const std::wstring &location) - -> packet::error_type override; + auto + winfsp_unmounted(const std::wstring &location) -> packet::error_type override; - auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, - BOOLEAN write_to_end, BOOLEAN constrained_io, - PUINT32 bytes_transferred, remote::file_info *file_info) - -> packet::error_type override; + auto + winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, + BOOLEAN write_to_end, BOOLEAN constrained_io, + PUINT32 bytes_transferred, + remote::file_info *file_info) -> packet::error_type override; }; } // namespace remote_winfsp } // namespace repertory diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp index ba4b208e..728f5b5c 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp @@ -23,7 +23,7 @@ // https://github.com/billziss-gh/winfsp/blob/master/tst/passthrough-cpp/passthrough-cpp.cpp #ifndef 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 "drives/remote/remote_server_base.hpp" @@ -42,23 +42,23 @@ public: private: [[nodiscard]] auto construct_path(std::string path) -> std::string; - [[nodiscard]] auto populate_file_info(const std::string &api_path, - remote::file_info &file_info) - -> packet::error_type; + [[nodiscard]] auto + populate_file_info(const std::string &api_path, + remote::file_info &file_info) -> packet::error_type; void populate_stat(const char *path, bool directory, remote::stat &r_stat, const struct _stat64 &unix_st); public: // FUSE Layer - auto fuse_access(const char *path, const std::int32_t &mask) - -> packet::error_type override; + auto fuse_access(const char *path, + const std::int32_t &mask) -> packet::error_type override; - auto fuse_chflags(const char *path, std::uint32_t flags) - -> packet::error_type override; + auto fuse_chflags(const char *path, + std::uint32_t flags) -> packet::error_type override; - auto fuse_chmod(const char *path, const remote::file_mode &mode) - -> packet::error_type override; + auto fuse_chmod(const char *path, + const remote::file_mode &mode) -> packet::error_type override; auto fuse_chown(const char *path, const remote::user_id &uid, const remote::group_id &gid) -> packet::error_type override; @@ -77,16 +77,16 @@ public: const remote::file_handle &handle) -> packet::error_type override; - auto fuse_fsync(const char *path, const std::int32_t &datasync, - const remote::file_handle &handle) - -> packet::error_type override; + auto + fuse_fsync(const char *path, const std::int32_t &datasync, + const remote::file_handle &handle) -> packet::error_type override; auto fuse_ftruncate(const char *path, const remote::file_offset &size, const remote::file_handle &handle) -> packet::error_type override; - auto fuse_getattr(const char *path, remote::stat &r_stat, bool &directory) - -> packet::error_type override; + auto fuse_getattr(const char *path, remote::stat &r_stat, + bool &directory) -> packet::error_type override; /*packet::error_type fuse_getxattr(const char *path, const char *name, char *value, const remote::file_size &size) override ; @@ -103,43 +103,41 @@ public: const remote::file_size &size) override ;*/ - auto fuse_mkdir(const char *path, const remote::file_mode &mode) - -> packet::error_type override; + auto fuse_mkdir(const char *path, + const remote::file_mode &mode) -> packet::error_type override; - auto fuse_opendir(const char *path, remote::file_handle &handle) - -> packet::error_type override; + auto fuse_opendir(const char *path, + remote::file_handle &handle) -> packet::error_type override; auto fuse_create(const char *path, const remote::file_mode &mode, - const remote::open_flags &flags, remote::file_handle &handle) - -> packet::error_type override; + const remote::open_flags &flags, + remote::file_handle &handle) -> packet::error_type override; auto fuse_open(const char *path, const remote::open_flags &flags, remote::file_handle &handle) -> packet::error_type override; - auto fuse_read(const char *path, char *buffer, - const remote::file_size &read_size, - const remote::file_offset &read_offset, - const remote::file_handle &handle) - -> packet::error_type override; + auto + fuse_read(const char *path, char *buffer, const remote::file_size &read_size, + const remote::file_offset &read_offset, + const remote::file_handle &handle) -> packet::error_type override; - auto fuse_rename(const char *from, const char *to) - -> packet::error_type override; + auto fuse_rename(const char *from, + const char *to) -> packet::error_type override; - auto fuse_write(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) - -> packet::error_type override; + auto + fuse_write(const char *path, const char *buffer, + const remote::file_size &write_size, + const remote::file_offset &write_offset, + const remote::file_handle &handle) -> packet::error_type override; - auto fuse_write_base64(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) - -> packet::error_type override; + auto fuse_write_base64( + const char *path, const char *buffer, const remote::file_size &write_size, + const remote::file_offset &write_offset, + const remote::file_handle &handle) -> packet::error_type override; auto fuse_readdir(const char *path, const remote::file_offset &offset, - const remote::file_handle &handle, std::string &item_path) - -> packet::error_type override; + const remote::file_handle &handle, + std::string &item_path) -> packet::error_type override; auto fuse_release(const char *path, const remote::file_handle &handle) -> packet::error_type override; @@ -152,8 +150,8 @@ public: auto fuse_rmdir(const char *path) -> packet::error_type override; - auto fuse_setattr_x(const char *path, remote::setattr_x &attr) - -> packet::error_type override; + auto fuse_setattr_x(const char *path, + remote::setattr_x &attr) -> packet::error_type override; auto fuse_setbkuptime(const char *path, const remote::file_time &bkuptime) -> packet::error_type override; @@ -186,8 +184,8 @@ public: auto fuse_unlink(const char *path) -> packet::error_type override; auto fuse_utimens(const char *path, const remote::file_time *tv, - std::uint64_t op0, std::uint64_t op1) - -> packet::error_type override; + std::uint64_t op0, + std::uint64_t op1) -> packet::error_type override; void set_fuse_uid_gid(const remote::user_id & /* uid */, const remote::group_id & /* gid */) override {} @@ -196,18 +194,17 @@ public: auto json_create_directory_snapshot(const std::string &path, json &json_data) -> packet::error_type override; - auto json_read_directory_snapshot(const std::string &path, - const remote::file_handle &handle, - std::uint32_t page, json &json_data) - -> packet::error_type override; + auto json_read_directory_snapshot( + const std::string &path, const remote::file_handle &handle, + std::uint32_t page, json &json_data) -> packet::error_type override; auto json_release_directory_snapshot(const std::string &path, const remote::file_handle &handle) -> packet::error_type override; // WinFSP Layer - auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) - -> packet::error_type override; + auto winfsp_can_delete(PVOID file_desc, + PWSTR file_name) -> packet::error_type override; auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags, BOOLEAN &was_closed) -> packet::error_type override; @@ -223,33 +220,32 @@ public: auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) -> packet::error_type override; - auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) - -> packet::error_type override; + auto winfsp_get_dir_buffer(PVOID file_desc, + PVOID *&ptr) -> packet::error_type override; auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info) -> packet::error_type override; - auto winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes, - std::uint64_t *descriptor_size, - std::wstring &string_descriptor) - -> packet::error_type override; + auto winfsp_get_security_by_name( + PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size, + std::wstring &string_descriptor) -> packet::error_type override; auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size, std::string &volume_label) -> packet::error_type override; - auto winfsp_mounted(const std::wstring &location) - -> packet::error_type override; + auto + winfsp_mounted(const std::wstring &location) -> packet::error_type override; auto winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, PVOID *file_desc, - remote::file_info *file_info, std::string &normalized_name) - -> packet::error_type override; + remote::file_info *file_info, + std::string &normalized_name) -> packet::error_type override; - auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, - BOOLEAN replace_attributes, UINT64 allocation_size, - remote::file_info *file_info) - -> packet::error_type override; + auto + winfsp_overwrite(PVOID file_desc, UINT32 attributes, + BOOLEAN replace_attributes, UINT64 allocation_size, + remote::file_info *file_info) -> packet::error_type override; auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, 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, BOOLEAN replace_if_exists) -> packet::error_type override; - auto winfsp_set_basic_info(PVOID file_desc, UINT32 attributes, - UINT64 creation_time, UINT64 last_access_time, - UINT64 last_write_time, UINT64 change_time, - remote::file_info *file_info) - -> packet::error_type override; + auto winfsp_set_basic_info( + PVOID file_desc, UINT32 attributes, UINT64 creation_time, + UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, + remote::file_info *file_info) -> packet::error_type override; - auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, - remote::file_info *file_info) - -> packet::error_type override; + auto winfsp_set_file_size( + PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, + remote::file_info *file_info) -> packet::error_type override; - auto winfsp_unmounted(const std::wstring &location) - -> packet::error_type override; + auto + winfsp_unmounted(const std::wstring &location) -> packet::error_type override; - auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, - BOOLEAN write_to_end, BOOLEAN constrained_io, - PUINT32 bytes_transferred, remote::file_info *file_info) - -> packet::error_type override; + auto + winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, + BOOLEAN write_to_end, BOOLEAN constrained_io, + PUINT32 bytes_transferred, + remote::file_info *file_info) -> packet::error_type override; }; } // namespace remote_winfsp } // namespace repertory diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp index 55ba875c..a02ba6e0 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp @@ -21,7 +21,7 @@ */ #ifndef 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 "events/event_system.hpp" @@ -75,8 +75,8 @@ private: static void set_file_info(FileInfo &dest, const remote::file_info &src); public: - auto CanDelete(PVOID file_node, PVOID file_desc, PWSTR file_name) - -> NTSTATUS override; + auto CanDelete(PVOID file_node, PVOID file_desc, + PWSTR file_name) -> NTSTATUS override; VOID Cleanup(PVOID file_node, PVOID file_desc, PWSTR file_name, ULONG flags) override; @@ -88,11 +88,11 @@ public: UINT64 allocation_size, PVOID *file_node, PVOID *file_desc, OpenFileInfo *ofi) -> NTSTATUS override; - auto Flush(PVOID file_node, PVOID file_desc, FileInfo *file_info) - -> NTSTATUS override; + auto Flush(PVOID file_node, PVOID file_desc, + FileInfo *file_info) -> NTSTATUS override; - auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *file_info) - -> NTSTATUS override; + auto GetFileInfo(PVOID file_node, PVOID file_desc, + FileInfo *file_info) -> NTSTATUS override; auto GetSecurityByName(PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor, @@ -107,8 +107,8 @@ public: auto Mounted(PVOID host) -> NTSTATUS override; auto Open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, - PVOID *file_node, PVOID *file_desc, OpenFileInfo *ofi) - -> NTSTATUS override; + PVOID *file_node, PVOID *file_desc, + OpenFileInfo *ofi) -> NTSTATUS override; auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, UINT64 allocation_size, @@ -122,8 +122,8 @@ public: PULONG bytes_transferred) -> NTSTATUS override; auto Rename(PVOID file_node, PVOID file_desc, PWSTR file_name, - PWSTR new_file_name, BOOLEAN replace_if_exists) - -> NTSTATUS override; + PWSTR new_file_name, + BOOLEAN replace_if_exists) -> NTSTATUS override; auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes, UINT64 creation_time, UINT64 last_access_time, @@ -131,15 +131,15 @@ public: FileInfo *file_info) -> NTSTATUS override; auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, FileInfo *file_info) - -> NTSTATUS override; + BOOLEAN set_allocation_size, + FileInfo *file_info) -> NTSTATUS override; VOID Unmounted(PVOID host) override; auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, - PULONG bytes_transferred, FileInfo *file_info) - -> NTSTATUS override; + PULONG bytes_transferred, + FileInfo *file_info) -> NTSTATUS override; void shutdown() { ::GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); } diff --git a/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp b/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp index 2e1e4d6e..dfeac2a0 100644 --- a/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp +++ b/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp @@ -21,7 +21,7 @@ */ #ifndef INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_ #define INCLUDE_DRIVES_WINFSP_WINFSP_DRIVE_HPP_ -#ifdef _WIN32 +#if defined(_WIN32) #include "drives/eviction.hpp" #include "drives/winfsp/i_winfsp_drive.hpp" @@ -75,8 +75,8 @@ private: std::unique_ptr remote_server_; private: - static auto parse_mount_location(const std::wstring &mount_location) - -> std::string; + static auto + parse_mount_location(const std::wstring &mount_location) -> std::string; void populate_file_info(const std::string &api_path, std::uint64_t file_size, const api_meta_map &meta, @@ -89,8 +89,8 @@ private: const FSP_FSCTL_FILE_INFO &src); public: - auto CanDelete(PVOID file_node, PVOID file_desc, PWSTR file_name) - -> NTSTATUS override; + auto CanDelete(PVOID file_node, PVOID file_desc, + PWSTR file_name) -> NTSTATUS override; VOID Cleanup(PVOID file_node, PVOID file_desc, PWSTR file_name, ULONG flags) override; @@ -102,8 +102,8 @@ public: UINT64 allocation_size, PVOID *file_node, PVOID *file_desc, OpenFileInfo *ofi) -> NTSTATUS override; - auto Flush(PVOID file_node, PVOID file_desc, FileInfo *file_info) - -> NTSTATUS override; + auto Flush(PVOID file_node, PVOID file_desc, + FileInfo *file_info) -> NTSTATUS override; [[nodiscard]] auto get_directory_item_count(const std::string &api_path) const -> std::uint64_t override; @@ -111,25 +111,24 @@ public: [[nodiscard]] auto get_directory_items(const std::string &api_path) const -> directory_item_list override; - auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *file_info) - -> NTSTATUS override; + auto GetFileInfo(PVOID file_node, PVOID file_desc, + FileInfo *file_info) -> NTSTATUS override; - [[nodiscard]] auto get_file_size(const std::string &api_path) const - -> std::uint64_t override; + [[nodiscard]] auto + get_file_size(const std::string &api_path) const -> std::uint64_t override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, - api_meta_map &meta) const - -> api_error override; + [[nodiscard]] auto + get_item_meta(const std::string &api_path, + api_meta_map &meta) const -> api_error override; - [[nodiscard]] auto get_item_meta(const std::string &api_path, - const std::string &name, - std::string &value) const - -> api_error override; + [[nodiscard]] auto + get_item_meta(const std::string &api_path, const std::string &name, + std::string &value) const -> api_error override; - [[nodiscard]] auto get_security_by_name(PWSTR file_name, PUINT32 attributes, - PSECURITY_DESCRIPTOR descriptor, - std::uint64_t *descriptor_size) - -> NTSTATUS override; + [[nodiscard]] auto + get_security_by_name(PWSTR file_name, PUINT32 attributes, + PSECURITY_DESCRIPTOR descriptor, + std::uint64_t *descriptor_size) -> NTSTATUS override; auto GetSecurityByName(PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor, @@ -153,16 +152,16 @@ public: auto Mounted(PVOID host) -> NTSTATUS override; auto Open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, - PVOID *file_node, PVOID *file_desc, OpenFileInfo *ofi) - -> NTSTATUS override; + PVOID *file_node, PVOID *file_desc, + OpenFileInfo *ofi) -> NTSTATUS override; auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, UINT64 allocation_size, FileInfo *file_info) -> NTSTATUS override; - [[nodiscard]] auto populate_file_info(const std::string &api_path, - remote::file_info &file_info) - -> api_error override; + [[nodiscard]] auto + populate_file_info(const std::string &api_path, + remote::file_info &file_info) -> api_error override; auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, ULONG length, PULONG bytes_transferred) -> NTSTATUS override; @@ -172,8 +171,8 @@ public: PULONG bytes_transferred) -> NTSTATUS override; auto Rename(PVOID file_node, PVOID file_desc, PWSTR file_name, - PWSTR new_file_name, BOOLEAN replace_if_exists) - -> NTSTATUS override; + PWSTR new_file_name, + BOOLEAN replace_if_exists) -> NTSTATUS override; auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes, UINT64 creation_time, UINT64 last_access_time, @@ -181,15 +180,15 @@ public: FileInfo *file_info) -> NTSTATUS override; auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, FileInfo *file_info) - -> NTSTATUS override; + BOOLEAN set_allocation_size, + FileInfo *file_info) -> NTSTATUS override; VOID Unmounted(PVOID host) override; auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, - PULONG bytes_transferred, FileInfo *file_info) - -> NTSTATUS override; + PULONG bytes_transferred, + FileInfo *file_info) -> NTSTATUS override; void shutdown(); diff --git a/repertory/librepertory/include/events/consumers/console_consumer.hpp b/repertory/librepertory/include/events/consumers/console_consumer.hpp index c115ab60..3ea36fbe 100644 --- a/repertory/librepertory/include/events/consumers/console_consumer.hpp +++ b/repertory/librepertory/include/events/consumers/console_consumer.hpp @@ -36,8 +36,8 @@ public: private: void process_event(const event &e) { -#ifdef _WIN32 -#ifdef _DEBUG +#if defined(_WIN32) +#if defined(_DEBUG) OutputDebugString((e.get_single_line() + "\n").c_str()); #endif #endif diff --git a/repertory/librepertory/include/events/events.hpp b/repertory/librepertory/include/events/events.hpp index 70b88618..8b1f9bb3 100644 --- a/repertory/librepertory/include/events/events.hpp +++ b/repertory/librepertory/include/events/events.hpp @@ -289,7 +289,7 @@ E_SIMPLE1(service_started, debug, true, ); E_SIMPLE(unmount_requested, normal, true); -#ifndef _WIN32 +#if !defined(_WIN32) E_SIMPLE2(unmount_result, normal, true, std::string, location, loc, E_STRING, std::string, result, res, E_STRING diff --git a/repertory/librepertory/include/file_manager/file_manager.hpp b/repertory/librepertory/include/file_manager/file_manager.hpp index 16f8651b..2a4e8647 100644 --- a/repertory/librepertory/include/file_manager/file_manager.hpp +++ b/repertory/librepertory/include/file_manager/file_manager.hpp @@ -57,8 +57,8 @@ public: open_file_base(const 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=(const open_file_base &) noexcept - -> open_file_base & = delete; + auto + operator=(const open_file_base &) noexcept -> open_file_base & = delete; public: class download final { @@ -168,14 +168,14 @@ public: [[nodiscard]] auto get_filesystem_item() const -> filesystem_item override; - [[nodiscard]] auto get_handles() const - -> std::vector override; + [[nodiscard]] auto + get_handles() const -> std::vector override; - [[nodiscard]] auto get_open_data() const - -> std::map override; + [[nodiscard]] auto + get_open_data() const -> std::map override; - [[nodiscard]] auto get_open_data(std::uint64_t handle) const - -> open_file_data override; + [[nodiscard]] auto + get_open_data(std::uint64_t handle) const -> open_file_data override; [[nodiscard]] auto get_open_file_count() const -> std::size_t override; @@ -261,8 +261,8 @@ public: public: auto close() -> bool override; - [[nodiscard]] auto get_read_state() const - -> boost::dynamic_bitset<> override; + [[nodiscard]] auto + get_read_state() const -> boost::dynamic_bitset<> 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; } - [[nodiscard]] auto native_operation(native_operation_callback callback) - -> api_error override; + [[nodiscard]] auto + native_operation(native_operation_callback callback) -> api_error override; - [[nodiscard]] auto native_operation(std::uint64_t new_file_size, - native_operation_callback callback) - -> api_error override; + [[nodiscard]] auto + native_operation(std::uint64_t new_file_size, + native_operation_callback callback) -> api_error override; void remove(std::uint64_t handle) override; [[nodiscard]] auto read(std::size_t read_size, std::uint64_t read_offset, data_buffer &data) -> api_error override; - [[nodiscard]] auto resize(std::uint64_t new_file_size) - -> api_error override; + [[nodiscard]] auto + resize(std::uint64_t new_file_size) -> api_error override; [[nodiscard]] auto write(std::uint64_t write_offset, const data_buffer &data, @@ -350,8 +350,8 @@ public: return last_chunk_; } - [[nodiscard]] auto get_read_state() const - -> boost::dynamic_bitset<> override; + [[nodiscard]] auto + get_read_state() const -> boost::dynamic_bitset<> 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; } - [[nodiscard]] auto native_operation(native_operation_callback callback) - -> api_error override; + [[nodiscard]] auto + native_operation(native_operation_callback callback) -> api_error override; - [[nodiscard]] auto native_operation(std::uint64_t, - native_operation_callback) - -> api_error override { + [[nodiscard]] auto + native_operation(std::uint64_t, + native_operation_callback) -> api_error override { return api_error::not_supported; } @@ -385,8 +385,8 @@ public: void set_api_path(const std::string &api_path) override; - [[nodiscard]] auto write(std::uint64_t, const data_buffer &, std::size_t &) - -> api_error override { + [[nodiscard]] auto write(std::uint64_t, const data_buffer &, + std::size_t &) -> api_error override { return api_error::not_supported; } }; @@ -530,10 +530,10 @@ public: [[nodiscard]] auto has_no_open_file_handles() const -> bool override; - [[nodiscard]] auto is_processing(const std::string &api_path) const - -> bool override; + [[nodiscard]] auto + is_processing(const std::string &api_path) const -> bool override; -#ifdef PROJECT_TESTING +#if defined(PROJECT_TESTING) [[nodiscard]] auto open(std::shared_ptr of, const open_file_data &ofd, std::uint64_t &handle, std::shared_ptr &file) -> api_error; @@ -544,13 +544,13 @@ public: [[nodiscard]] auto remove_file(const std::string &api_path) -> api_error; - [[nodiscard]] auto rename_directory(const std::string &from_api_path, - const std::string &to_api_path) - -> api_error; + [[nodiscard]] auto + rename_directory(const std::string &from_api_path, + const std::string &to_api_path) -> api_error; [[nodiscard]] auto rename_file(const std::string &from_api_path, - const std::string &to_api_path, bool overwrite) - -> api_error; + const std::string &to_api_path, + bool overwrite) -> api_error; void start(); diff --git a/repertory/librepertory/include/platform/unix_platform.hpp b/repertory/librepertory/include/platform/unix_platform.hpp index d5bc5d56..2528df54 100644 --- a/repertory/librepertory/include/platform/unix_platform.hpp +++ b/repertory/librepertory/include/platform/unix_platform.hpp @@ -21,7 +21,7 @@ */ #ifndef INCLUDE_PLATFORM_UNIXPLATFORM_HPP_ #define INCLUDE_PLATFORM_UNIXPLATFORM_HPP_ -#ifndef _WIN32 +#if !defined(_WIN32) #include "types/repertory.hpp" @@ -51,9 +51,8 @@ private: [[nodiscard]] auto get_lock_file() -> std::string; private: - [[nodiscard]] static auto wait_for_lock(int fd, - std::uint8_t retry_count = 30u) - -> int; + [[nodiscard]] static auto + wait_for_lock(int fd, std::uint8_t retry_count = 30u) -> int; public: [[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 set_mount_state(bool active, - const std::string &mount_location, int pid) - -> bool; + const std::string &mount_location, + int pid) -> bool; }; [[nodiscard]] auto create_meta_attributes( diff --git a/repertory/librepertory/include/platform/win32_platform.hpp b/repertory/librepertory/include/platform/win32_platform.hpp index 51c6df8e..e6f0c2dd 100644 --- a/repertory/librepertory/include/platform/win32_platform.hpp +++ b/repertory/librepertory/include/platform/win32_platform.hpp @@ -21,7 +21,7 @@ */ #ifndef INCLUDE_PLATFORM_WINPLATFORM_HPP_ #define INCLUDE_PLATFORM_WINPLATFORM_HPP_ -#ifdef _WIN32 +#if defined(_WIN32) #include "app_config.hpp" #include "types/repertory.hpp" @@ -54,8 +54,8 @@ private: DWORD mutex_state_ = WAIT_FAILED; public: - [[nodiscard]] auto get_mount_state(const provider_type &pt, json &mount_state) - -> bool; + [[nodiscard]] auto get_mount_state(const provider_type &pt, + json &mount_state) -> bool; [[nodiscard]] auto get_mount_state(json &mount_state) -> bool; diff --git a/repertory/librepertory/include/types/remote.hpp b/repertory/librepertory/include/types/remote.hpp index 25420c67..627252f0 100644 --- a/repertory/librepertory/include/types/remote.hpp +++ b/repertory/librepertory/include/types/remote.hpp @@ -25,7 +25,7 @@ #define PACKET_SERVICE_FUSE 1U #define PACKET_SERVICE_WINFSP 2U -#ifdef _WIN32 +#if defined(_WIN32) #define PACKET_SERVICE_FLAGS PACKET_SERVICE_WINFSP #else #define PACKET_SERVICE_FLAGS PACKET_SERVICE_FUSE @@ -65,14 +65,14 @@ enum class open_flags : std::uint32_t { dsync = 131072U, }; -inline auto operator|(const open_flags &flag_1, const open_flags &flag_2) - -> open_flags { +inline auto operator|(const open_flags &flag_1, + const open_flags &flag_2) -> open_flags { using t = std::underlying_type_t; return static_cast(static_cast(flag_1) | static_cast(flag_2)); } -#ifdef __GNUG__ +#if defined(__GNUG__) __attribute__((unused)) #endif inline auto @@ -81,7 +81,7 @@ operator|=(open_flags &flag_1, const open_flags &flag_2) -> open_flags & { return flag_1; } -#ifdef __GNUG__ +#if defined(__GNUG__) __attribute__((unused)) #endif inline auto @@ -149,11 +149,11 @@ struct statfs_x : public statfs { }; #pragma pack() -#ifndef _WIN32 +#if !defined(_WIN32) [[nodiscard]] auto create_open_flags(std::uint32_t flags) -> open_flags; -[[nodiscard]] auto create_os_open_flags(const open_flags &flags) - -> std::uint32_t; +[[nodiscard]] auto +create_os_open_flags(const open_flags &flags) -> std::uint32_t; #endif } // namespace repertory::remote diff --git a/repertory/librepertory/include/types/repertory.hpp b/repertory/librepertory/include/types/repertory.hpp index 2c08cff2..ba63d17b 100644 --- a/repertory/librepertory/include/types/repertory.hpp +++ b/repertory/librepertory/include/types/repertory.hpp @@ -98,8 +98,8 @@ enum class api_error { [[nodiscard]] auto api_error_from_string(std::string_view s) -> api_error; -[[nodiscard]] auto api_error_to_string(const api_error &error) - -> const std::string &; +[[nodiscard]] auto +api_error_to_string(const api_error &error) -> const std::string &; enum class download_type { direct, fallback, ring_buffer }; @@ -145,7 +145,7 @@ enum class provider_type : std::size_t { unknown, }; -#ifdef _WIN32 +#if defined(_WIN32) struct open_file_data { void *directory_buffer{}; }; @@ -229,7 +229,7 @@ struct host_config { } }; -#ifdef __GNUG__ +#if defined(__GNUG__) __attribute__((unused)) #endif static void @@ -244,7 +244,7 @@ to_json(json &j, const host_config &hc) { {"TimeoutMs", hc.timeout_ms}}; } -#ifdef __GNUG__ +#if defined(__GNUG__) __attribute__((unused)) #endif static void diff --git a/repertory/librepertory/include/types/s3.hpp b/repertory/librepertory/include/types/s3.hpp index 8b211d7e..badbcae5 100644 --- a/repertory/librepertory/include/types/s3.hpp +++ b/repertory/librepertory/include/types/s3.hpp @@ -29,7 +29,7 @@ namespace repertory { namespace utils::aws { -#if _WIN32 +#if defined(_WIN32) [[nodiscard]] inline auto format_time(std::uint64_t t) -> std::uint64_t { FILETIME ft{}; utils::unix_time_to_filetime(t, ft); @@ -75,7 +75,7 @@ struct head_object_result { if (not date.empty()) { struct tm tm1 {}; // 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); #else strptime(date.c_str(), "%a, %d %b %Y %H:%M:%S %Z", &tm1); diff --git a/repertory/librepertory/include/utils/com_init_wrapper.hpp b/repertory/librepertory/include/utils/com_init_wrapper.hpp index c42e311e..81484928 100644 --- a/repertory/librepertory/include/utils/com_init_wrapper.hpp +++ b/repertory/librepertory/include/utils/com_init_wrapper.hpp @@ -21,7 +21,7 @@ */ #ifndef INCLUDE_UTILS_COM_INIT_WRAPPER_HPP_ #define INCLUDE_UTILS_COM_INIT_WRAPPER_HPP_ -#ifdef _WIN32 +#if defined(_WIN32) namespace repertory { class com_init_wrapper { diff --git a/repertory/librepertory/include/utils/native_file.hpp b/repertory/librepertory/include/utils/native_file.hpp index a79bca3c..0488c89d 100644 --- a/repertory/librepertory/include/utils/native_file.hpp +++ b/repertory/librepertory/include/utils/native_file.hpp @@ -39,12 +39,12 @@ public: return std::shared_ptr(new native_file(handle)); } - [[nodiscard]] static auto clone(const native_file_ptr &ptr) - -> native_file_ptr; + [[nodiscard]] static auto + clone(const native_file_ptr &ptr) -> native_file_ptr; [[nodiscard]] static auto create_or_open(const std::string &source_path, - bool read_only, native_file_ptr &ptr) - -> api_error; + bool read_only, + native_file_ptr &ptr) -> api_error; [[nodiscard]] static auto create_or_open(const std::string &source_path, native_file_ptr &ptr) -> api_error; @@ -66,7 +66,7 @@ private: private: bool auto_close{false}; -#ifdef _WIN32 +#if defined(_WIN32) std::recursive_mutex read_write_mutex_; #endif @@ -85,7 +85,7 @@ public: [[nodiscard]] auto get_handle() -> native_handle; -#ifdef _WIN32 +#if defined(_WIN32) [[nodiscard]] auto read_bytes(char *buffer, std::size_t read_size, std::uint64_t read_offset, std::size_t &bytes_read) -> bool; @@ -98,7 +98,7 @@ public: [[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, std::uint64_t write_offset, std::size_t &bytes_written) -> bool; diff --git a/repertory/librepertory/include/utils/path_utils.hpp b/repertory/librepertory/include/utils/path_utils.hpp index 1fc80641..d5ca6452 100644 --- a/repertory/librepertory/include/utils/path_utils.hpp +++ b/repertory/librepertory/include/utils/path_utils.hpp @@ -23,7 +23,7 @@ #define INCLUDE_UTILS_PATH_UTILS_HPP_ namespace repertory::utils::path { -#ifdef _WIN32 +#if defined(_WIN32) static const std::string directory_seperator = "\\"; static const std::string not_directory_seperator = "/"; #else @@ -34,9 +34,8 @@ static const std::string not_directory_seperator = "\\"; // Prototypes [[nodiscard]] auto absolute(std::string path) -> std::string; -[[nodiscard]] auto combine(std::string path, - const std::vector &paths) - -> std::string; +[[nodiscard]] auto +combine(std::string path, const std::vector &paths) -> 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; -#ifndef _WIN32 +#if !defined(_WIN32) [[nodiscard]] auto get_parent_directory(std::string path) -> std::string; #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; -#ifndef _WIN32 +#if !defined(_WIN32) [[nodiscard]] auto resolve(std::string path) -> std::string; #endif diff --git a/repertory/librepertory/include/utils/unix/unix_utils.hpp b/repertory/librepertory/include/utils/unix/unix_utils.hpp index 5549ca40..e5391313 100644 --- a/repertory/librepertory/include/utils/unix/unix_utils.hpp +++ b/repertory/librepertory/include/utils/unix/unix_utils.hpp @@ -21,13 +21,13 @@ */ #ifndef INCLUDE_UTILS_UNIX_UNIX_UTILS_HPP_ #define INCLUDE_UTILS_UNIX_UNIX_UTILS_HPP_ -#ifndef _WIN32 +#if !defined(_WIN32) #include "types/remote.hpp" #include "types/repertory.hpp" namespace repertory::utils { -#if __linux__ +#if defined(__linux__) inline const std::array attribute_namespaces = { "security", "system", @@ -36,7 +36,7 @@ inline const std::array attribute_namespaces = { }; #endif -#if __APPLE__ +#if defined(__APPLE__) template [[nodiscard]] auto convert_to_uint64(const t *ptr) -> std::uint64_t; #else @@ -49,8 +49,8 @@ template [[nodiscard]] auto get_thread_id() -> std::uint64_t; -[[nodiscard]] auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) - -> bool; +[[nodiscard]] auto is_uid_member_of_group(const uid_t &uid, + const gid_t &gid) -> bool; 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_time_to_windows_time(const remote::file_time &file_time) - -> UINT64; +[[nodiscard]] auto +unix_time_to_windows_time(const remote::file_time &file_time) -> UINT64; void use_getpwuid(uid_t uid, std::function callback); @@ -67,11 +67,11 @@ void windows_create_to_unix(const UINT32 &create_options, const UINT32 &granted_access, std::uint32_t &flags, remote::file_mode &mode); -[[nodiscard]] auto windows_time_to_unix_time(std::uint64_t win_time) - -> remote::file_time; +[[nodiscard]] auto +windows_time_to_unix_time(std::uint64_t win_time) -> remote::file_time; // template implementations -#if __APPLE__ +#if defined(__APPLE__) template [[nodiscard]] auto convert_to_uint64(const t *v) -> std::uint64_t { return static_cast(reinterpret_cast(v)); diff --git a/repertory/librepertory/include/utils/windows/windows_utils.hpp b/repertory/librepertory/include/utils/windows/windows_utils.hpp index 471d855b..fb6719b3 100644 --- a/repertory/librepertory/include/utils/windows/windows_utils.hpp +++ b/repertory/librepertory/include/utils/windows/windows_utils.hpp @@ -21,30 +21,30 @@ */ #ifndef INCLUDE_UTILS_WINDOWS_WINDOWS_UTILS_HPP_ #define INCLUDE_UTILS_WINDOWS_WINDOWS_UTILS_HPP_ -#ifdef _WIN32 +#if defined(_WIN32) #include "types/remote.hpp" #include "types/repertory.hpp" namespace repertory::utils { -[[nodiscard]] auto filetime_to_unix_time(const FILETIME &ft) - -> remote::file_time; +[[nodiscard]] auto +filetime_to_unix_time(const FILETIME &ft) -> remote::file_time; [[nodiscard]] auto get_last_error_code() -> DWORD; [[nodiscard]] auto get_local_app_data_directory() -> const std::string &; -[[nodiscard]] auto get_accessed_time_from_meta(const api_meta_map &meta) - -> std::uint64_t; +[[nodiscard]] auto +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) - -> std::uint64_t; +[[nodiscard]] auto +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) - -> std::uint64_t; +[[nodiscard]] auto +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) - -> std::uint64_t; +[[nodiscard]] auto +get_written_time_from_meta(const api_meta_map &meta) -> 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); -[[nodiscard]] auto time64_to_unix_time(const __time64_t &t) - -> remote::file_time; +[[nodiscard]] auto +time64_to_unix_time(const __time64_t &t) -> remote::file_time; } // namespace repertory::utils #endif // _WIN32 diff --git a/repertory/librepertory/src/app_config.cpp b/repertory/librepertory/src/app_config.cpp index 0247135a..02a9f5e2 100644 --- a/repertory/librepertory/src/app_config.cpp +++ b/repertory/librepertory/src/app_config.cpp @@ -68,7 +68,7 @@ app_config::app_config(const provider_type &prov, enable_comm_duration_events_(false), enable_drive_events_(false), enable_max_cache_size_(false), -#ifdef _WIN32 +#if defined(_WIN32) enable_mount_manager_(false), #endif 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) -> std::string { -#ifdef _WIN32 +#if defined(_WIN32) auto data_directory = utils::path::combine( utils::get_local_app_data_directory(), {REPERTORY_DATA_NAME, app_config::get_provider_name(prov)}); #else -#ifdef __APPLE__ +#if defined(__APPLE__) auto data_directory = utils::path::resolve( std::string("~/Library/Application Support/") + REPERTORY_DATA_NAME + '/' + app_config::get_provider_name(prov)); @@ -201,7 +201,7 @@ auto app_config::get_json() const -> json { {"EnableChunkDownloaderTimeout", enable_chunk_downloader_timeout_}, {"EnableCommDurationEvents", enable_comm_duration_events_}, {"EnableDriveEvents", enable_drive_events_}, -#ifdef _WIN32 +#if defined(_WIN32) {"EnableMountManager", enable_mount_manager_}, #endif {"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) -> std::string { -#ifdef _WIN32 +#if defined(_WIN32) auto api_file = utils::path::combine(utils::get_local_app_data_directory(), {get_provider_display_name(prov), "apipassword"}); #else -#ifdef __APPLE__ +#if defined(__APPLE__) auto api_file = utils::path::combine(utils::path::resolve("~"), {"/Library/Application Support", @@ -387,7 +387,7 @@ auto app_config::get_value_by_name(const std::string &name) -> std::string { } if (name == "EnableMaxCacheSize") { return utils::string::from_bool(get_enable_max_cache_size()); -#ifdef _WIN32 +#if defined(_WIN32) } if (name == "EnableMountManager") { return std::to_string(get_enable_mount_manager()); @@ -617,7 +617,7 @@ auto app_config::load() -> bool { ret); get_value(json_document, "EnableMaxCacheSize", enable_max_cache_size_, ret); -#ifdef _WIN32 +#if defined(_WIN32) get_value(json_document, "EnableMountManager", enable_mount_manager_, ret); #endif @@ -765,7 +765,7 @@ auto app_config::set_value_by_name(const std::string &name, if (name == "EnableMaxCacheSize") { set_enable_max_cache_size(utils::string::to_bool(value)); return utils::string::from_bool(get_enable_max_cache_size()); -#ifdef _WIN32 +#if defined(_WIN32) } if (name == "EnableMountManager") { set_enable_mount_manager(utils::string::to_bool(value)); diff --git a/repertory/librepertory/src/drives/directory_iterator.cpp b/repertory/librepertory/src/drives/directory_iterator.cpp index 79ee877b..b3dc5fb1 100644 --- a/repertory/librepertory/src/drives/directory_iterator.cpp +++ b/repertory/librepertory/src/drives/directory_iterator.cpp @@ -25,12 +25,10 @@ #include "utils/path_utils.hpp" namespace repertory { -#ifndef _WIN32 -auto directory_iterator::fill_buffer(const remote::file_offset &offset, - fuse_fill_dir_t filler_function, - void *buffer, - populate_stat_callback populate_stat) - -> int { +#if !defined(_WIN32) +auto directory_iterator::fill_buffer( + const remote::file_offset &offset, fuse_fill_dir_t filler_function, + void *buffer, populate_stat_callback populate_stat) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); if (offset < items_.size()) { diff --git a/repertory/librepertory/src/drives/eviction.cpp b/repertory/librepertory/src/drives/eviction.cpp index ef3c4097..a8b553e6 100644 --- a/repertory/librepertory/src/drives/eviction.cpp +++ b/repertory/librepertory/src/drives/eviction.cpp @@ -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_modified_time(file_path, reference_time); if (ret) { -#ifdef _WIN32 +#if defined(_WIN32) const auto now = std::chrono::system_clock::now(); const auto delay = std::chrono::minutes(config_.get_eviction_delay_mins()); diff --git a/repertory/librepertory/src/drives/fuse/fuse_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_base.cpp index 1155e298..7d6c463e 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_base.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _WIN32 +#if !defined(_WIN32) #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_.read = fuse_base::read_; fuse_ops_.write = fuse_base::write_; -#ifndef __APPLE__ +#if !defined(__APPLE__) fuse_ops_.statfs = fuse_base::statfs_; #endif // __APPLE__ fuse_ops_.release = fuse_base::release_; fuse_ops_.fsync = fuse_base::fsync_; -#if HAS_SETXATTR +#if defined(HAS_SETXATTR) fuse_ops_.setxattr = fuse_base::setxattr_; fuse_ops_.getxattr = fuse_base::getxattr_; fuse_ops_.listxattr = fuse_base::listxattr_; @@ -81,7 +81,7 @@ fuse_base::fuse_base(app_config &config) : config_(config) { fuse_ops_.flag_reserved = 0; #endif fuse_ops_.fallocate = fuse_base::fallocate_; -#ifdef __APPLE__ +#if defined(__APPLE__) fuse_ops_.chflags = fuse_base::chflags_; fuse_ops_.fsetattr_x = fuse_base::fsetattr_x_; 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 { constexpr const auto *function_name = static_cast(__FUNCTION__); @@ -121,8 +121,8 @@ auto fuse_base::chflags_(const char *path, uint32_t flags) -> int { #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 -auto fuse_base::chmod_(const char *path, mode_t mode, struct fuse_file_info *fi) - -> int { +auto fuse_base::chmod_(const char *path, mode_t mode, + struct fuse_file_info *fi) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); return instance().execute_callback( @@ -264,7 +264,7 @@ auto fuse_base::fgetattr_(const char *path, struct stat *st, } #endif -#ifdef __APPLE__ +#if defined(__APPLE__) auto fuse_base::fsetattr_x_(const char *path, struct setattr_x *attr, struct fuse_file_info *fi) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); @@ -319,7 +319,7 @@ auto fuse_base::getattr_(const char *path, struct stat *st) -> int { } #endif -#ifdef __APPLE__ +#if defined(__APPLE__) auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime, struct timespec *crtime) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); @@ -332,8 +332,8 @@ auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime, #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 -auto fuse_base::init_(struct fuse_conn_info *conn, struct fuse_config *cfg) - -> void * { +auto fuse_base::init_(struct fuse_conn_info *conn, + struct fuse_config *cfg) -> void * { constexpr const auto *function_name = static_cast(__FUNCTION__); 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(); repertory::project_initialize(); -#ifdef __APPLE__ +#if defined(__APPLE__) conn->want |= FUSE_CAP_VOL_RENAME; conn->want |= FUSE_CAP_XTIMES; #endif // __APPLE__ @@ -459,8 +459,8 @@ auto fuse_base::read_(const char *path, char *buffer, size_t read_size, #if FUSE_USE_VERSION >= 30 auto fuse_base::readdir_(const char *path, void *buf, fuse_fill_dir_t fuse_fill_dir, off_t offset, - struct fuse_file_info *fi, fuse_readdir_flags flags) - -> int { + struct fuse_file_info *fi, + fuse_readdir_flags flags) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); 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) - -> int { +auto fuse_base::releasedir_(const char *path, + struct fuse_file_info *fi) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); 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 -auto fuse_base::rename_(const char *from, const char *to, unsigned int flags) - -> int { +auto fuse_base::rename_(const char *from, const char *to, + unsigned int flags) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); return instance().execute_callback( @@ -536,8 +536,8 @@ auto fuse_base::rmdir_(const char *path) -> int { }); } -#ifdef HAS_SETXATTR -#ifdef __APPLE__ +#if defined(HAS_SETXATTR) +#if defined(__APPLE__) auto fuse_base::getxattr_(const char *path, const char *name, char *value, size_t size, uint32_t position) -> int { constexpr const auto *function_name = static_cast(__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, size_t size, int flags, uint32_t position) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); @@ -735,7 +735,7 @@ void fuse_base::shutdown() { std::to_string(res)); } -#ifdef __APPLE__ +#if defined(__APPLE__) auto fuse_base::setattr_x_(const char *path, struct setattr_x *attr) -> int { constexpr const auto *function_name = static_cast(__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) - -> int { +auto fuse_base::setbkuptime_(const char *path, + const struct timespec *bkuptime) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); 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) - -> int { +auto fuse_base::setchgtime_(const char *path, + const struct timespec *chgtime) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); 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) - -> int { +auto fuse_base::setcrtime_(const char *path, + const struct timespec *crtime) -> int { constexpr const auto *function_name = static_cast(__FUNCTION__); 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 { -#if __APPLE__ +#if defined(__APPLE__) const auto cmd = "umount \"" + mount_location + "\" >/dev/null 2>&1"; #else #if FUSE_USE_VERSION >= 30 diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp index 0ceaea9f..a59612ea 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _WIN32 +#if !defined(_WIN32) #include "drives/fuse/fuse_drive.hpp" @@ -49,7 +49,7 @@ fuse_drive::fuse_drive(app_config &config, lock_data &lock_data, i_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) { return check_and_perform(api_path, X_OK, [&](api_meta_map &) -> api_error { 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*/) -> api_error { #else -auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid) - -> api_error { +auto fuse_drive::chown_impl(std::string api_path, uid_t uid, + gid_t gid) -> api_error { #endif return check_and_perform(api_path, X_OK, [&](api_meta_map &meta) -> api_error { @@ -163,7 +163,7 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode, std::shared_ptr open_file; if (is_create_op) { const auto now = utils::get_file_time_now(); -#ifdef __APPLE__ +#if defined(__APPLE__) const auto osx_flags = static_cast(file_info->flags); #else 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; -#ifdef __APPLE__ +#if defined(__APPLE__) fstore_t fstore = {0}; if (not(mode & PREALLOCATE)) { if (mode & ALLOCATECONTIG) { @@ -332,7 +332,7 @@ auto fuse_drive::fgetattr_impl(std::string api_path, struct stat *st, return api_error::success; } -#ifdef __APPLE__ +#if defined(__APPLE__) auto fuse_drive::fsetattr_x_impl(std::string api_path, struct setattr_x *attr, struct fuse_file_info *file_info) -> 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 { if (handle != REPERTORY_INVALID_HANDLE) { -#ifdef __APPLE__ +#if defined(__APPLE__) if ((datasync == 0 ? fsync(handle) : fcntl(handle, F_FULLFSYNC)) == -1) { #else // __APPLE__ 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*/) -> api_error { #else -auto fuse_drive::getattr_impl(std::string api_path, struct stat *st) - -> api_error { +auto fuse_drive::getattr_impl(std::string api_path, + struct stat *st) -> api_error { #endif const auto parent = utils::path::get_parent_api_path(api_path); @@ -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()); } -#ifdef __APPLE__ +#if defined(__APPLE__) auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime, struct timespec *crtime) -> api_error { if (not(bkuptime && crtime)) { @@ -522,8 +522,8 @@ auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime, #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 -auto fuse_drive::init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) - -> void * { +auto fuse_drive::init_impl(struct fuse_conn_info *conn, + struct fuse_config *cfg) -> void * { #else void *fuse_drive::init_impl(struct fuse_conn_info *conn) { #endif @@ -747,9 +747,8 @@ auto fuse_drive::release_impl(std::string /*api_path*/, return api_error::success; } -auto fuse_drive::releasedir_impl(std::string /*api_path*/, - struct fuse_file_info *file_info) - -> api_error { +auto fuse_drive::releasedir_impl( + std::string /*api_path*/, struct fuse_file_info *file_info) -> api_error { auto *iter = reinterpret_cast(file_info->fh); if (iter == nullptr) { 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, - const std::string &to_api_path, bool overwrite) - -> int { + const std::string &to_api_path, + bool overwrite) -> int { const auto res = fm_->rename_file(from_api_path, to_api_path, overwrite); errno = std::abs(utils::from_api_error(res)); return (res == api_error::success) ? 0 : -1; @@ -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, unsigned int /*flags*/) -> api_error { #else -auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path) - -> api_error { +auto fuse_drive::rename_impl(std::string from_api_path, + std::string to_api_path) -> api_error { #endif auto res = check_parent_access(to_api_path, W_OK | X_OK); if (res != api_error::success) { @@ -826,12 +825,12 @@ auto fuse_drive::rmdir_impl(std::string api_path) -> api_error { return api_error::success; } -#ifdef HAS_SETXATTR +#if defined(HAS_SETXATTR) auto fuse_drive::getxattr_common(std::string api_path, const char *name, char *value, size_t size, int &attribute_size, uint32_t *position) -> api_error { std::string attribute_name; -#ifdef __APPLE__ +#if defined(__APPLE__) auto res = parse_xattr_parameters(name, value, size, *position, attribute_name, api_path); #else // __APPLE__ @@ -881,7 +880,7 @@ auto fuse_drive::getxattr_common(std::string api_path, const char *name, return res; } -#ifdef __APPLE__ +#if defined(__APPLE__) auto fuse_drive::getxattr_impl(std::string api_path, const char *name, char *value, size_t size, uint32_t position, int &attribute_size) -> api_error { @@ -890,15 +889,15 @@ auto fuse_drive::getxattr_impl(std::string api_path, const char *name, } #else // __APPLE__ auto fuse_drive::getxattr_impl(std::string api_path, const char *name, - char *value, size_t size, int &attribute_size) - -> api_error { + char *value, size_t size, + int &attribute_size) -> api_error { return getxattr_common(api_path, name, value, size, attribute_size, nullptr); } #endif // __APPLE__ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size, - int &required_size, bool &return_size) - -> api_error { + int &required_size, + bool &return_size) -> api_error { const auto check_size = (size == 0); auto res = check_parent_access(api_path, X_OK); @@ -911,7 +910,7 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size, for (const auto &meta_item : meta) { if (utils::collection_excludes(META_USED_NAMES, meta_item.first)) { auto attribute_name = meta_item.first; -#ifdef __APPLE__ +#if defined(__APPLE__) if (attribute_name != G_KAUTH_FILESEC_XATTR) { #endif 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(attribute_name_size); -#ifdef __APPLE__ +#if defined(__APPLE__) } #endif } @@ -937,10 +936,10 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size, return res; } -auto fuse_drive::removexattr_impl(std::string api_path, const char *name) - -> api_error { +auto fuse_drive::removexattr_impl(std::string api_path, + const char *name) -> api_error { std::string attribute_name; -#ifdef __APPLE__ +#if defined(__APPLE__) auto res = parse_xattr_parameters(name, 0, attribute_name, api_path); #else 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, const char *value, size_t size, int flags, uint32_t position) -> api_error { #else // __APPLE__ auto fuse_drive::setxattr_impl(std::string api_path, const char *name, - const char *value, size_t size, int flags) - -> api_error { + const char *value, size_t size, + int flags) -> api_error { #endif std::string attribute_name; -#ifdef __APPLE__ +#if defined(__APPLE__) auto res = parse_xattr_parameters(name, value, size, position, attribute_name, api_path); #else // __APPLE__ @@ -991,7 +990,7 @@ auto fuse_drive::setxattr_impl(std::string api_path, const char *name, if (utils::string::contains(attribute_name, " .") || utils::string::contains(attribute_name, ". ") -#ifndef __APPLE__ +#if !defined(__APPLE__) || utils::collection_excludes(utils::attribute_namespaces, attribute_namespace) #endif @@ -1039,9 +1038,9 @@ void fuse_drive::set_item_meta(const std::string &api_path, } } -#ifdef __APPLE__ -auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr) - -> api_error { +#if defined(__APPLE__) +auto fuse_drive::setattr_x_impl(std::string api_path, + struct setattr_x *attr) -> api_error { bool exists{}; auto res = provider_.is_file(api_path, exists); if (res != api_error::success) { @@ -1140,9 +1139,8 @@ auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr) return api_error::success; } -auto fuse_drive::setbkuptime_impl(std::string api_path, - const struct timespec *bkuptime) - -> api_error { +auto fuse_drive::setbkuptime_impl( + std::string api_path, const struct timespec *bkuptime) -> api_error { return check_and_perform( api_path, X_OK, [&](api_meta_map &meta) -> api_error { const auto nanos = @@ -1178,8 +1176,8 @@ auto fuse_drive::setvolname_impl(const char * /*volname*/) -> api_error { return api_error::success; } -auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf) - -> api_error { +auto fuse_drive::statfs_x_impl(std::string /*api_path*/, + struct statfs *stbuf) -> api_error { if (statfs(&config_.get_cache_directory()[0], stbuf) != 0) { return api_error::os_error; } @@ -1204,8 +1202,8 @@ auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf) return api_error::success; } #else // __APPLE__ -auto fuse_drive::statfs_impl(std::string /*api_path*/, struct statvfs *stbuf) - -> api_error { +auto fuse_drive::statfs_impl(std::string /*api_path*/, + struct statvfs *stbuf) -> api_error { if (statvfs(config_.get_cache_directory().data(), stbuf) != 0) { return api_error::os_error; } @@ -1286,8 +1284,8 @@ auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2], struct fuse_file_info * /*file_info*/) -> api_error { #else -auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2]) - -> api_error { +auto fuse_drive::utimens_impl(std::string api_path, + const struct timespec tv[2]) -> api_error { #endif api_meta_map meta; auto res = provider_.get_item_meta(api_path, meta); diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp index d72c4bdb..839a1189 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _WIN32 +#if !defined(_WIN32) #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); } -auto fuse_drive_base::check_access(const std::string &api_path, int mask) const - -> api_error { +auto fuse_drive_base::check_access(const std::string &api_path, + int mask) const -> api_error { api_meta_map meta; const auto res = get_item_meta(api_path, meta); if (res != api_error::success) { @@ -126,9 +126,8 @@ auto fuse_drive_base::check_and_perform( return action(meta); } -auto fuse_drive_base::check_open_flags(int flags, int mask, - const api_error &fail_error) - -> api_error { +auto fuse_drive_base::check_open_flags( + int flags, int mask, const api_error &fail_error) -> api_error { 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; } -auto fuse_drive_base::check_readable(int flags, const api_error &fail_error) - -> api_error { +auto fuse_drive_base::check_readable(int flags, + const api_error &fail_error) -> api_error { const auto mode = (flags & O_ACCMODE); 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(); } -#ifdef __APPLE__ +#if defined(__APPLE__) auto fuse_drive_base::get_flags_from_meta(const api_meta_map &meta) -> __uint32_t { 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(utils::string::to_uint32(meta.at(META_UID))); } -#ifdef __APPLE__ -auto fuse_drive_base::parse_xattr_parameters(const char *name, - const uint32_t &position, - std::string &attribute_name, - const std::string &api_path) - -> api_error { +#if defined(__APPLE__) +auto fuse_drive_base::parse_xattr_parameters( + const char *name, const uint32_t &position, std::string &attribute_name, + const std::string &api_path) -> api_error { #else -auto fuse_drive_base::parse_xattr_parameters(const char *name, - std::string &attribute_name, - const std::string &api_path) - -> api_error { +auto fuse_drive_base::parse_xattr_parameters( + const char *name, std::string &attribute_name, + const std::string &api_path) -> api_error { #endif auto res = api_path.empty() ? api_error::bad_address : 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); -#ifdef __APPLE__ +#if defined(__APPLE__) if (attribute_name == A_KAUTH_FILESEC_XATTR) { char new_name[MAXPATHLEN] = {0}; 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; } -#ifdef __APPLE__ +#if defined(__APPLE__) auto fuse_drive_base::parse_xattr_parameters( const char *name, const char *value, size_t size, const uint32_t &position, std::string &attribute_name, const std::string &api_path) -> api_error { auto res = parse_xattr_parameters(name, position, attribute_name, api_path); #else -auto fuse_drive_base::parse_xattr_parameters(const char *name, - const char *value, size_t size, - std::string &attribute_name, - const std::string &api_path) - -> api_error { +auto fuse_drive_base::parse_xattr_parameters( + const char *name, const char *value, size_t size, + std::string &attribute_name, const std::string &api_path) -> api_error { auto res = parse_xattr_parameters(name, attribute_name, api_path); #endif 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_mode = (directory ? S_IFDIR : S_IFREG) | get_mode_from_meta(meta); st->st_uid = get_uid_from_meta(meta); -#ifdef __APPLE__ +#if defined(__APPLE__) st->st_blksize = 0; st->st_flags = get_flags_from_meta(meta); diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp index 7d4d3003..fe6830c9 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _WIN32 +#if !defined(_WIN32) #include "drives/fuse/remotefuse/remote_fuse_drive.hpp" @@ -38,13 +38,13 @@ #include "utils/utils.hpp" namespace repertory::remote_fuse { -auto remote_fuse_drive::access_impl(std::string api_path, int mask) - -> api_error { +auto remote_fuse_drive::access_impl(std::string api_path, + int mask) -> api_error { return utils::to_api_error( remote_instance_->fuse_access(api_path.c_str(), mask)); } -#ifdef __APPLE__ +#if defined(__APPLE__) api_error remote_fuse_drive::chflags_impl(std::string api_path, uint32_t flags) { 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*/) -> api_error { #else -auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode) - -> api_error { +auto remote_fuse_drive::chmod_impl(std::string api_path, + mode_t mode) -> api_error { #endif return utils::to_api_error(remote_instance_->fuse_chmod( api_path.c_str(), static_cast(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*/) -> api_error { #else -auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid) - -> api_error { +auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, + gid_t gid) -> api_error { #endif return utils::to_api_error( remote_instance_->fuse_chown(api_path.c_str(), uid, gid)); @@ -114,10 +114,9 @@ void remote_fuse_drive::destroy_impl(void *ptr) { fuse_base::destroy_impl(ptr); } -auto remote_fuse_drive::fgetattr_impl(std::string api_path, - struct stat *unix_st, - struct fuse_file_info *f_info) - -> api_error { +auto remote_fuse_drive::fgetattr_impl( + std::string api_path, struct stat *unix_st, + struct fuse_file_info *f_info) -> api_error { remote::stat r_stat{}; auto directory = false; @@ -130,7 +129,7 @@ auto remote_fuse_drive::fgetattr_impl(std::string api_path, return utils::to_api_error(res); } -#ifdef __APPLE__ +#if defined(__APPLE__) api_error remote_fuse_drive::fsetattr_x_impl(std::string api_path, struct setattr_x *attr, 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*/) -> api_error { #else -auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st) - -> api_error { +auto remote_fuse_drive::getattr_impl(std::string api_path, + struct stat *unix_st) -> api_error { #endif bool directory = false; remote::stat r_stat{}; @@ -192,7 +191,7 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st) return utils::to_api_error(res); } -#ifdef __APPLE__ +#if defined(__APPLE__) api_error remote_fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime, struct timespec *crtime) { @@ -259,8 +258,8 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * { return ret; } -auto remote_fuse_drive::mkdir_impl(std::string api_path, mode_t mode) - -> api_error { +auto remote_fuse_drive::mkdir_impl(std::string api_path, + mode_t mode) -> api_error { return utils::to_api_error(remote_instance_->fuse_mkdir( api_path.c_str(), static_cast(mode))); } @@ -282,9 +281,8 @@ auto remote_fuse_drive::open_impl(std::string api_path, f_info->fh)); } -auto remote_fuse_drive::opendir_impl(std::string api_path, - struct fuse_file_info *f_info) - -> api_error { +auto remote_fuse_drive::opendir_impl( + std::string api_path, struct fuse_file_info *f_info) -> api_error { return utils::to_api_error( remote_instance_->fuse_opendir(api_path.c_str(), f_info->fh)); @@ -294,7 +292,7 @@ void remote_fuse_drive::populate_stat(const remote::stat &r_stat, bool directory, struct stat &unix_st) { memset(&unix_st, 0, sizeof(struct stat)); -#ifdef __APPLE__ +#if defined(__APPLE__) unix_st.st_blksize = 0; 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 -auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf, - fuse_fill_dir_t fuse_fill_dir, - off_t offset, - struct fuse_file_info *f_info, - fuse_readdir_flags /*flags*/) - -> api_error { +auto remote_fuse_drive::readdir_impl( + std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, + off_t offset, struct fuse_file_info *f_info, + fuse_readdir_flags /*flags*/) -> api_error { #else -auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf, - fuse_fill_dir_t fuse_fill_dir, - off_t offset, - struct fuse_file_info *f_info) - -> api_error { +auto remote_fuse_drive::readdir_impl( + std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, + off_t offset, struct fuse_file_info *f_info) -> api_error { #endif std::string item_path; int res = 0; @@ -403,16 +397,14 @@ auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf, return utils::to_api_error(res); } -auto remote_fuse_drive::release_impl(std::string api_path, - struct fuse_file_info *f_info) - -> api_error { +auto remote_fuse_drive::release_impl( + std::string api_path, struct fuse_file_info *f_info) -> api_error { return utils::to_api_error( remote_instance_->fuse_release(api_path.c_str(), f_info->fh)); } -auto remote_fuse_drive::releasedir_impl(std::string api_path, - struct fuse_file_info *f_info) - -> api_error { +auto remote_fuse_drive::releasedir_impl( + std::string api_path, struct fuse_file_info *f_info) -> api_error { return utils::to_api_error( remote_instance_->fuse_releasedir(api_path.c_str(), f_info->fh)); } @@ -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())); } -#ifdef __APPLE__ +#if defined(__APPLE__) api_error remote_fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr) { 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); } #else // __APPLE__ -auto remote_fuse_drive::statfs_impl(std::string api_path, struct statvfs *stbuf) - -> api_error { +auto remote_fuse_drive::statfs_impl(std::string api_path, + struct statvfs *stbuf) -> api_error { auto res = statvfs(config_.get_data_directory().c_str(), stbuf); if (res == 0) { remote::statfs r_stat{}; @@ -536,8 +528,8 @@ auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size, struct fuse_file_info * /*f_info*/) -> api_error { #else -auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size) - -> api_error { +auto remote_fuse_drive::truncate_impl(std::string api_path, + off_t size) -> api_error { #endif return utils::to_api_error(remote_instance_->fuse_truncate( api_path.c_str(), static_cast(size))); @@ -548,10 +540,9 @@ auto remote_fuse_drive::unlink_impl(std::string api_path) -> api_error { } #if FUSE_USE_VERSION >= 30 -auto remote_fuse_drive::utimens_impl(std::string api_path, - const struct timespec tv[2], - struct fuse_file_info * /*f_info*/) - -> api_error { +auto remote_fuse_drive::utimens_impl( + std::string api_path, const struct timespec tv[2], + struct fuse_file_info * /*f_info*/) -> api_error { #else auto remote_fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2]) -> api_error { diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp index 6895c76e..b923ba8a 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _WIN32 +#if !defined(_WIN32) #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, remote::stat &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_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; } -auto remote_server::fuse_chflags(const char *path, std::uint32_t flags) - -> packet::error_type { +auto remote_server::fuse_chflags(const char *path, + std::uint32_t flags) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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 &length, const remote::file_handle &handle) { const auto file_path = ConstructPath(path); auto ret = HasOpenFileInfo(handle, -EBADF); if (ret == 0) { -#ifdef __APPLE__ +#if defined(__APPLE__) ret = STATUS_NOT_IMPLEMENTED; fstore_t fstore = {0}; @@ -298,10 +298,9 @@ length); ret = ((res < 0) ? -errno : 0); #endif return ret; }*/ -auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, - bool &directory, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_fgetattr( + const char *path, remote::stat &r_stat, bool &directory, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::fuse_fsetattr_x(const char *path, - const remote::setattr_x &attr, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_fsetattr_x( + const char *path, const remote::setattr_x &attr, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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(handle), EBADF); if (res == 0) { -#ifdef __APPLE__ +#if defined(__APPLE__) res = datasync ? fcntl(static_cast(handle), F_FULLFSYNC) : fsync(static_cast(handle)); #else @@ -439,10 +437,9 @@ auto remote_server::fuse_fsync(const char *path, const std::int32_t &datasync, return ret; } -auto remote_server::fuse_ftruncate(const char *path, - const remote::file_offset &size, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_ftruncate( + const char *path, const remote::file_offset &size, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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 = utils::path::get_parent_api_path(api_path); -#if __APPLE__ || !HAS_SETXATTR +#if defined(__APPLE__) || !defined(HAS_SETXATTR) auto ret = STATUS_NOT_IMPLEMENTED; #else auto found = false; @@ -524,7 +521,8 @@ filePath, ret); return ret; packet::error_type remote_server::fuse_getxattrOSX(const char *path, const char *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: Use iterator cache 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; }*/ -auto remote_server::fuse_getxtimes(const char *path, - remote::file_time &bkuptime, - remote::file_time &crtime) - -> packet::error_type { +auto remote_server::fuse_getxtimes( + const char *path, remote::file_time &bkuptime, + remote::file_time &crtime) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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 *buffer, const remote::file_size &size) { const auto file_path = -ConstructPath(path); #ifdef HAS_SETXATTR #ifdef __APPLE__ const auto res = -listxattr(file_path.c_str(), buffer, size, FSOPT_NOFOLLOW); #else const auto res -= listxattr(file_path.c_str(), buffer, size); #endif auto ret = ((res < 0) ? --errno : 0); #else auto ret = STATUS_NOT_IMPLEMENTED; #endif +ConstructPath(path); #if defined(HAS_SETXATTR) #if defined(__APPLE__) const auto +res = listxattr(file_path.c_str(), buffer, size, FSOPT_NOFOLLOW); #else const +auto res = listxattr(file_path.c_str(), buffer, size); #endif auto ret = ((res < +0) ? -errno : 0); #else auto ret = STATUS_NOT_IMPLEMENTED; #endif RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); return ret; }*/ @@ -636,11 +633,10 @@ auto remote_server::fuse_opendir(const char *path, remote::file_handle &handle) return ret; } -auto remote_server::fuse_read(const char *path, char *buffer, - const remote::file_size &read_size, - const remote::file_offset &read_offset, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_read( + const char *path, char *buffer, const remote::file_size &read_size, + const remote::file_offset &read_offset, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto file_path = construct_path(path); @@ -661,8 +657,8 @@ auto remote_server::fuse_read(const char *path, char *buffer, return static_cast(ret); } -auto remote_server::fuse_rename(const char *from, const char *to) - -> packet::error_type { +auto remote_server::fuse_rename(const char *from, + const char *to) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto from_path = utils::path::combine(mount_location_, {from}); @@ -700,9 +696,8 @@ auto remote_server::fuse_readdir(const char *path, return ret; } -auto remote_server::fuse_release(const char *path, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_release( + const char *path, const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); packet::error_type ret = 0; @@ -719,9 +714,8 @@ auto remote_server::fuse_release(const char *path, return ret; } -auto remote_server::fuse_releasedir(const char *path, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_releasedir( + const char *path, const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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 -char *name) { const auto file_path = ConstructPath(path); #ifdef HAS_SETXATTR -#ifdef __APPLE__ - const auto res = removexattr(file_path.c_str(), name, FSOPT_NOFOLLOW); -#else - const auto res = removexattr(file_path.c_str(), name); -#endif - auto ret = ((res < 0) ? -errno : 0); -#else - auto ret = STATUS_NOT_IMPLEMENTED; -#endif +char *name) { const auto file_path = ConstructPath(path); #if +defined(HAS_SETXATTR) #if defined(__APPLE__) const auto res = +removexattr(file_path.c_str(), name, FSOPT_NOFOLLOW); #else const auto res = +removexattr(file_path.c_str(), name); #endif auto ret = ((res < 0) ? -errno : +0); #else auto ret = STATUS_NOT_IMPLEMENTED; #endif RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); return ret; }*/ @@ -778,9 +767,8 @@ auto remote_server::fuse_setattr_x(const char *path, remote::setattr_x &attr) return ret; } -auto remote_server::fuse_setbkuptime(const char *path, - const remote::file_time &bkuptime) - -> packet::error_type { +auto remote_server::fuse_setbkuptime( + const char *path, const remote::file_time &bkuptime) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto api_path = utils::path::create_api_path(path); @@ -799,9 +787,8 @@ auto remote_server::fuse_setbkuptime(const char *path, return ret; } -auto remote_server::fuse_setchgtime(const char *path, - const remote::file_time &chgtime) - -> packet::error_type { +auto remote_server::fuse_setchgtime( + const char *path, const remote::file_time &chgtime) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto api_path = utils::path::create_api_path(path); @@ -820,9 +807,8 @@ auto remote_server::fuse_setchgtime(const char *path, return ret; } -auto remote_server::fuse_setcrtime(const char *path, - const remote::file_time &crtime) - -> packet::error_type { +auto remote_server::fuse_setcrtime( + const char *path, const remote::file_time &crtime) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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 *name, const char *value, const remote::file_size &size, const std::int32_t -&flags) { const auto file_path = ConstructPath(path); #if __APPLE__ || -!HAS_SETXATTR auto ret = STATUS_NOT_IMPLEMENTED; #else const auto res = +&flags) { const auto file_path = ConstructPath(path); #if defined(__APPLE__{} || +!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) ? -errno : 0); #endif RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); return ret; @@ -860,8 +846,9 @@ ret); return ret; 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 &flags, const std::uint32_t &position) { const auto file_path = -ConstructPath(path); #if __APPLE__ && HAS_SETXATTR const auto res = -setxattr(file_path.c_str(), name, value, size, position, flags); auto ret = +ConstructPath(path); #if defined(__APPLE__) && defined(HAS_SETXATTR) const auto +res = setxattr(file_path.c_str(), name, value, size, position, flags); auto ret += ((res < 0) ? -errno : 0); #else auto ret = STATUS_NOT_IMPLEMENTED; #endif RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); return ret; @@ -912,9 +899,8 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize, return 0; } -auto remote_server::fuse_truncate(const char *path, - const remote::file_offset &size) - -> packet::error_type { +auto remote_server::fuse_truncate( + const char *path, const remote::file_offset &size) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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, - std::uint64_t op0, std::uint64_t op1) - -> packet::error_type { + std::uint64_t op0, + std::uint64_t op1) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::fuse_write(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_write( + const char *path, const char *buffer, const remote::file_size &write_size, + const remote::file_offset &write_offset, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto file_path = construct_path(path); @@ -999,8 +984,8 @@ auto remote_server::fuse_write_base64( } // WinFSP Layer -auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR file_name) - -> packet::error_type { +auto remote_server::winfsp_can_delete(PVOID file_desc, + PWSTR file_name) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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, - UINT32 flags, BOOLEAN &was_closed) - -> packet::error_type { + UINT32 flags, + BOOLEAN &was_closed) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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, UINT64 /*allocation_size*/, PVOID *file_desc, remote::file_info *file_info, - std::string &normalized_name, BOOLEAN &exists) - -> packet::error_type { + std::string &normalized_name, + BOOLEAN &exists) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::winfsp_get_file_info(PVOID file_desc, - remote::file_info *file_info) - -> packet::error_type { +auto remote_server::winfsp_get_file_info( + PVOID file_desc, remote::file_info *file_info) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto handle = reinterpret_cast(file_desc); @@ -1218,10 +1202,9 @@ auto remote_server::winfsp_get_security_by_name( return ret; } -auto remote_server::winfsp_get_volume_info(UINT64 &total_size, - UINT64 &free_size, - std::string &volume_label) - -> packet::error_type { +auto remote_server::winfsp_get_volume_info( + UINT64 &total_size, UINT64 &free_size, + std::string &volume_label) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, - UINT32 granted_access, PVOID *file_desc, - remote::file_info *file_info, - std::string &normalized_name) - -> packet::error_type { +auto remote_server::winfsp_open( + PWSTR file_name, UINT32 create_options, UINT32 granted_access, + PVOID *file_desc, remote::file_info *file_info, + std::string &normalized_name) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, - BOOLEAN replace_attributes, - UINT64 /*allocation_size*/, - remote::file_info *file_info) - -> packet::error_type { +auto remote_server::winfsp_overwrite( + PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, + UINT64 /*allocation_size*/, + remote::file_info *file_info) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto handle = reinterpret_cast(file_desc); @@ -1397,10 +1378,9 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/, return ret; } -auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, - PWSTR new_file_name, - BOOLEAN replace_if_exists) - -> packet::error_type { +auto remote_server::winfsp_rename( + PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name, + BOOLEAN replace_if_exists) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto relative_path = utils::string::to_utf8(file_name); @@ -1489,10 +1469,9 @@ auto remote_server::winfsp_set_basic_info( return ret; } -auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, - remote::file_info *file_info) - -> packet::error_type { +auto remote_server::winfsp_set_file_size( + PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, + remote::file_info *file_info) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto handle = reinterpret_cast(file_desc); @@ -1526,12 +1505,10 @@ auto remote_server::winfsp_unmounted(const std::wstring &location) return STATUS_SUCCESS; } -auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, - UINT32 length, BOOLEAN write_to_end, - BOOLEAN constrained_io, - PUINT32 bytes_transferred, - remote::file_info *file_info) - -> packet::error_type { +auto remote_server::winfsp_write( + PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, + BOOLEAN write_to_end, BOOLEAN constrained_io, PUINT32 bytes_transferred, + remote::file_info *file_info) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); *bytes_transferred = 0; @@ -1578,9 +1555,8 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, return ret; } -auto remote_server::json_create_directory_snapshot(const std::string &path, - json &json_data) - -> packet::error_type { +auto remote_server::json_create_directory_snapshot( + const std::string &path, json &json_data) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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( - const std::string &path, const remote::file_handle &handle) - -> packet::error_type { + const std::string &path, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto file_path = construct_path(path); diff --git a/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp b/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp index 84c4f07d..e55962e6 100644 --- a/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp +++ b/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp @@ -46,7 +46,7 @@ void remote_open_file_table::close_all(const std::string &client_id) { compat_lock.unlock(); for (auto &handle : compat_handles) { -#ifdef _WIN32 +#if defined(_WIN32) _close(static_cast(handle)); #else close(static_cast(handle)); @@ -64,7 +64,7 @@ void remote_open_file_table::close_all(const std::string &client_id) { file_lock.unlock(); for (auto &handle : handles) { -#ifdef _WIN32 +#if defined(_WIN32) ::CloseHandle(handle); #else 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, PVOID *&buffer) -> bool { 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--; } if (not file_lookup_[handle].count) { -#ifdef _WIN32 +#if defined(_WIN32) if (file_lookup_[handle].directory_buffer) { FspFileSystemDeleteDirectoryBuffer( &file_lookup_[handle].directory_buffer); diff --git a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp index b5c5d284..245becc2 100644 --- a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp +++ b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp @@ -203,7 +203,7 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options, set_open_info( to_handle(*file_desc), open_info{0, "", nullptr, utils::string::to_utf8(file_name)}); -#ifdef _WIN32 +#if defined(_WIN32) if (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, [[maybe_unused]] PVOID *&ptr) -> packet::error_type { -#ifdef _WIN32 +#if defined(_WIN32) if (get_directory_buffer(reinterpret_cast(file_desc), ptr)) { 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); if (ret == STATUS_SUCCESS) { ret = response.decode(buffer, *bytes_transferred); -#ifdef _WIN32 +#if defined(_WIN32) if ((ret == STATUS_SUCCESS) && (not *bytes_transferred || (*bytes_transferred != length))) { ::SetLastError(ERROR_HANDLE_EOF); @@ -555,7 +555,7 @@ auto remote_client::winfsp_write( return ret; } -#ifndef _WIN32 +#if !defined(_WIN32) auto remote_client::to_handle(PVOID file_desc) -> native_handle { return static_cast(reinterpret_cast(file_desc)); } diff --git a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp index 3a9c0947..bf6c459e 100644 --- a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp +++ b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp @@ -21,7 +21,7 @@ */ // 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 -#ifdef _WIN32 +#if defined(_WIN32) #include "drives/winfsp/remotewinfsp/remote_server.hpp" @@ -39,7 +39,7 @@ #include "utils/file_utils.hpp" #include "utils/path_utils.hpp" -#ifndef _SH_DENYNO +#if !defined(_SH_DENYNO) #define _SH_DENYRW 0x10 // deny read/write mode #define _SH_DENYWR 0x20 // deny write mode #define _SH_DENYRD 0x30 // deny read mode @@ -129,10 +129,9 @@ auto remote_server::fuse_chmod(const char *path, return ret; } -auto remote_server::fuse_chown(const char *path, - const remote::user_id & /*uid*/, - const remote::group_id & /*gid*/) - -> packet::error_type { +auto remote_server::fuse_chown( + const char *path, const remote::user_id & /*uid*/, + const remote::group_id & /*gid*/) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto file_path = construct_path(path); @@ -160,10 +159,9 @@ construct_path(path); auto res = HasOpenFileCompatInfo(handle, EBADF); if (res return ret; }*/ -auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, - bool &directory, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_fgetattr( + const char *path, remote::stat &r_stat, bool &directory, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::fuse_fsetattr_x(const char *path, - const remote::setattr_x & /*attr*/, - const remote::file_handle & /*handle*/) - -> packet::error_type { +auto remote_server::fuse_fsetattr_x( + const char *path, const remote::setattr_x & /*attr*/, + const remote::file_handle & /*handle*/) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto file_path = construct_path(path); @@ -196,10 +193,9 @@ auto remote_server::fuse_fsetattr_x(const char *path, return ret; } -auto remote_server::fuse_fsync(const char *path, - const std::int32_t & /*datasync*/, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_fsync( + const char *path, const std::int32_t & /*datasync*/, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto file_path = construct_path(path); @@ -224,10 +220,9 @@ auto remote_server::fuse_fsync(const char *path, return ret; } -auto remote_server::fuse_ftruncate(const char *path, - const remote::file_offset &size, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_ftruncate( + const char *path, const remote::file_offset &size, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; }*/ -auto remote_server::fuse_getxtimes(const char *path, - remote::file_time & /*bkuptime*/, - remote::file_time & /*crtime*/) - -> packet::error_type { +auto remote_server::fuse_getxtimes( + const char *path, remote::file_time & /*bkuptime*/, + remote::file_time & /*crtime*/) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::fuse_read(const char *path, char *buffer, - const remote::file_size &read_size, - const remote::file_offset &read_offset, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_read( + const char *path, char *buffer, const remote::file_size &read_size, + const remote::file_offset &read_offset, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto file_path = construct_path(path); @@ -464,8 +457,8 @@ auto remote_server::fuse_read(const char *path, char *buffer, return ret; } -auto remote_server::fuse_rename(const char *from, const char *to) - -> packet::error_type { +auto remote_server::fuse_rename(const char *from, + const char *to) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::fuse_write(const char *path, const char *buffer, - const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_write( + const char *path, const char *buffer, const remote::file_size &write_size, + const remote::file_offset &write_offset, + const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto file_path = construct_path(path); @@ -553,9 +545,8 @@ auto remote_server::fuse_readdir(const char *path, return ret; } -auto remote_server::fuse_release(const char *path, - const remote::file_handle &handle) - -> packet::error_type { +auto remote_server::fuse_release( + const char *path, const remote::file_handle &handle) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto file_path = construct_path(path); @@ -595,9 +586,8 @@ auto remote_server::fuse_rmdir(const char *path) -> packet::error_type { return ret; } -auto remote_server::fuse_setattr_x(const char *path, - remote::setattr_x & /*attr*/) - -> packet::error_type { +auto remote_server::fuse_setattr_x( + const char *path, remote::setattr_x & /*attr*/) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::fuse_truncate(const char *path, - const remote::file_offset &size) - -> packet::error_type { +auto remote_server::fuse_truncate( + const char *path, const remote::file_offset &size) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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, - std::uint64_t op0, std::uint64_t op1) - -> packet::error_type { + std::uint64_t op0, + std::uint64_t op1) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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 -auto remote_server::json_create_directory_snapshot(const std::string &path, - json &json_data) - -> packet::error_type { +auto remote_server::json_create_directory_snapshot( + const std::string &path, json &json_data) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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( - const std::string &path, const remote::file_handle & /*handle*/) - -> packet::error_type { + const std::string &path, + const remote::file_handle & /*handle*/) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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*/, - UINT32 flags, BOOLEAN &was_closed) - -> packet::error_type { + UINT32 flags, + BOOLEAN &was_closed) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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, UINT64 /*allocation_size*/, PVOID *file_desc, remote::file_info *file_info, - std::string &normalized_name, BOOLEAN &exists) - -> packet::error_type { + std::string &normalized_name, + BOOLEAN &exists) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::winfsp_get_file_info(PVOID file_desc, - remote::file_info *file_info) - -> packet::error_type { +auto remote_server::winfsp_get_file_info( + PVOID file_desc, remote::file_info *file_info) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); auto *handle = reinterpret_cast(file_desc); @@ -1020,11 +1007,9 @@ auto remote_server::winfsp_get_file_info(PVOID file_desc, return ret; } -auto remote_server::winfsp_get_security_by_name(PWSTR file_name, - PUINT32 attributes, - std::uint64_t *descriptor_size, - std::wstring &string_descriptor) - -> packet::error_type { +auto remote_server::winfsp_get_security_by_name( + PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size, + std::wstring &string_descriptor) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::winfsp_get_volume_info(UINT64 &total_size, - UINT64 &free_size, - std::string &volume_label) - -> packet::error_type { +auto remote_server::winfsp_get_volume_info( + UINT64 &total_size, UINT64 &free_size, + std::string &volume_label) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, - UINT32 granted_access, PVOID *file_desc, - remote::file_info *file_info, - std::string &normalized_name) - -> packet::error_type { +auto remote_server::winfsp_open( + PWSTR file_name, UINT32 create_options, UINT32 granted_access, + PVOID *file_desc, remote::file_info *file_info, + std::string &normalized_name) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, - BOOLEAN replace_attributes, - UINT64 /*allocation_size*/, - remote::file_info *file_info) - -> packet::error_type { +auto remote_server::winfsp_overwrite( + PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, + UINT64 /*allocation_size*/, + remote::file_info *file_info) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); auto *handle = reinterpret_cast(file_desc); @@ -1234,10 +1216,9 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/, return ret; } -auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, - PWSTR new_file_name, - BOOLEAN replace_if_exists) - -> packet::error_type { +auto remote_server::winfsp_rename( + PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name, + BOOLEAN replace_if_exists) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); const auto from_path = utils::string::from_utf8(utils::path::combine( @@ -1289,10 +1270,9 @@ auto remote_server::winfsp_set_basic_info( return ret; } -auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, - remote::file_info *file_info) - -> packet::error_type { +auto remote_server::winfsp_set_file_size( + PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, + remote::file_info *file_info) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); auto *handle = reinterpret_cast(file_desc); @@ -1335,12 +1315,10 @@ auto remote_server::winfsp_unmounted(const std::wstring &location) return STATUS_SUCCESS; } -auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, - UINT32 length, BOOLEAN /*write_to_end*/, - BOOLEAN constrained_io, - PUINT32 bytes_transferred, - remote::file_info *file_info) - -> packet::error_type { +auto remote_server::winfsp_write( + PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, + BOOLEAN /*write_to_end*/, BOOLEAN constrained_io, PUINT32 bytes_transferred, + remote::file_info *file_info) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); auto *handle = reinterpret_cast(file_desc); diff --git a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp index 45f4456e..ef0d0b03 100644 --- a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp +++ b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef _WIN32 +#if defined(_WIN32) #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, PSECURITY_DESCRIPTOR /*descriptor*/, UINT64 allocation_size, PVOID * /*file_node*/, - PVOID *file_desc, OpenFileInfo *ofi) - -> NTSTATUS { + PVOID *file_desc, + OpenFileInfo *ofi) -> NTSTATUS { remote::file_info fi{}; std::string normalized_name; BOOLEAN exists = 0; @@ -159,10 +159,9 @@ auto remote_winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc, return ret; } -auto remote_winfsp_drive::GetSecurityByName(PWSTR file_name, PUINT32 attributes, - PSECURITY_DESCRIPTOR descriptor, - SIZE_T *descriptor_size) - -> NTSTATUS { +auto remote_winfsp_drive::GetSecurityByName( + PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor, + SIZE_T *descriptor_size) -> NTSTATUS { std::wstring string_descriptor; std::uint64_t sds = descriptor_size ? *descriptor_size : 0; 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, UINT32 granted_access, PVOID * /*file_node*/, - PVOID *file_desc, OpenFileInfo *ofi) - -> NTSTATUS { + PVOID *file_desc, + OpenFileInfo *ofi) -> NTSTATUS { remote::file_info fi{}; std::string normalize_name; 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, UINT32 attributes, BOOLEAN replace_attributes, - UINT64 allocation_size, FileInfo *file_info) - -> NTSTATUS { + UINT64 allocation_size, + FileInfo *file_info) -> NTSTATUS { remote::file_info fi{}; const auto ret = remote_instance_->winfsp_overwrite( 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, UINT64 last_access_time, UINT64 last_write_time, - UINT64 change_time, FileInfo *file_info) - -> NTSTATUS { + UINT64 change_time, + FileInfo *file_info) -> NTSTATUS { remote::file_info fi{}; const auto ret = remote_instance_->winfsp_set_basic_info( 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, PVOID buffer, UINT64 offset, ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, - PULONG bytes_transferred, FileInfo *file_info) - -> NTSTATUS { + PULONG bytes_transferred, + FileInfo *file_info) -> NTSTATUS { remote::file_info fi{}; const auto ret = remote_instance_->winfsp_write( file_desc, buffer, offset, length, write_to_end, constrained_io, diff --git a/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp b/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp index d2cf527f..724eeea3 100644 --- a/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp +++ b/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef _WIN32 +#if defined(_WIN32) #include "drives/winfsp/winfsp_drive.hpp" diff --git a/repertory/librepertory/src/events/consumers/logging_consumer.cpp b/repertory/librepertory/src/events/consumers/logging_consumer.cpp index 81809185..703de59e 100644 --- a/repertory/librepertory/src/events/consumers/logging_consumer.cpp +++ b/repertory/librepertory/src/events/consumers/logging_consumer.cpp @@ -171,7 +171,7 @@ void logging_consumer::process_event(const event &event) { void logging_consumer::reopen_log_file() { close_log_file(); -#ifdef _WIN32 +#if defined(_WIN32) log_file_ = _fsopen(&log_path_[0], "a+", _SH_DENYWR); #else log_file_ = fopen(&log_path_[0], "a+"); diff --git a/repertory/librepertory/src/platform/unix_platform.cpp b/repertory/librepertory/src/platform/unix_platform.cpp index 3b05d62d..59dafd12 100644 --- a/repertory/librepertory/src/platform/unix_platform.cpp +++ b/repertory/librepertory/src/platform/unix_platform.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _WIN32 +#if !defined(_WIN32) #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 { -#ifdef __APPLE__ +#if defined(__APPLE__) return utils::path::resolve("~/Library/Application Support/" + std::string(REPERTORY_DATA_NAME) + "/state"); #else diff --git a/repertory/librepertory/src/platform/win32_platform.cpp b/repertory/librepertory/src/platform/win32_platform.cpp index d5f387d7..5fe32fd6 100644 --- a/repertory/librepertory/src/platform/win32_platform.cpp +++ b/repertory/librepertory/src/platform/win32_platform.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef _WIN32 +#if defined(_WIN32) #include "platform/win32_platform.hpp" @@ -27,8 +27,8 @@ #include "utils/error_utils.hpp" namespace repertory { -auto lock_data::get_mount_state(const provider_type & /*pt*/, json &mount_state) - -> bool { +auto lock_data::get_mount_state(const provider_type & /*pt*/, + json &mount_state) -> bool { const auto ret = get_mount_state(mount_state); if (ret) { const auto mount_id = diff --git a/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp b/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp index 8501e070..439b119e 100644 --- a/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp +++ b/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp @@ -66,11 +66,10 @@ const std::map sql_create_tables = { namespace repertory { encrypt_provider::encrypt_provider(app_config &config) : config_(config) {} -auto encrypt_provider::create_api_file(const std::string &api_path, - bool directory, - const std::string &source_path) - -> api_file { -#ifdef _WIN32 +auto encrypt_provider::create_api_file( + const std::string &api_path, bool directory, + const std::string &source_path) -> api_file { +#if defined(_WIN32) struct _stat64 buf {}; _stat64(source_path.c_str(), &buf); #else @@ -87,7 +86,7 @@ auto encrypt_provider::create_api_file(const std::string &api_path, : utils::encryption::encrypting_reader::calculate_encrypted_size( source_path); file.source_path = source_path; -#ifdef __APPLE__ +#if defined(__APPLE__) file.changed_date = buf.st_ctimespec.tv_nsec + (buf.st_ctimespec.tv_sec * NANOS_PER_SECOND); 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); file.modified_date = buf.st_mtimespec.tv_nsec + (buf.st_mtimespec.tv_sec * NANOS_PER_SECOND); -#elif _WIN32 +#elif defined(_WIN32) FILETIME ft{}; utils::unix_time_to_filetime(utils::time64_to_unix_time(buf.st_atime), ft); 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, const api_file &file) { -#ifdef _WIN32 +#if defined(_WIN32) struct _stat64 buf {}; _stat64(file.source_path.c_str(), &buf); #else @@ -138,11 +137,11 @@ void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory, #endif meta[META_ACCESSED] = std::to_string(file.accessed_date); -#ifdef _WIN32 +#if defined(_WIN32) meta[META_ATTRIBUTES] = std::to_string(::GetFileAttributesA(file.source_path.c_str())); #endif -#ifdef __APPLE__ +#if defined(__APPLE__) meta[META_BACKUP]; #endif 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_MODE] = std::to_string(buf.st_mode); meta[META_MODIFIED] = std::to_string(file.modified_date); -#ifdef __APPLE__ +#if defined(__APPLE__) meta[META_OSXFLAGS]; #endif meta[META_SIZE] = std::to_string(file.file_size); @@ -214,9 +213,8 @@ auto encrypt_provider::do_fs_operation( return callback(cfg, source_path); } -auto encrypt_provider::get_api_path_from_source(const std::string &source_path, - std::string &api_path) const - -> api_error { +auto encrypt_provider::get_api_path_from_source( + const std::string &source_path, std::string &api_path) const -> api_error { constexpr const auto *function_name = static_cast(__FUNCTION__); try { @@ -284,9 +282,8 @@ auto encrypt_provider::get_directory_item_count( return count; } -auto encrypt_provider::get_directory_items(const std::string &api_path, - directory_item_list &list) const - -> api_error { +auto encrypt_provider::get_directory_items( + const std::string &api_path, directory_item_list &list) const -> api_error { constexpr const auto *function_name = static_cast(__FUNCTION__); 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; } -auto encrypt_provider::get_file_size(const std::string &api_path, - std::uint64_t &file_size) const - -> api_error { +auto encrypt_provider::get_file_size( + const std::string &api_path, std::uint64_t &file_size) const -> api_error { constexpr const auto *function_name = static_cast(__FUNCTION__); try { @@ -474,10 +470,9 @@ auto encrypt_provider::get_file_size(const std::string &api_path, return api_error::error; } -auto encrypt_provider::get_filesystem_item(const std::string &api_path, - bool directory, - filesystem_item &fsi) const - -> api_error { +auto encrypt_provider::get_filesystem_item( + const std::string &api_path, bool directory, + filesystem_item &fsi) const -> api_error { auto result = db::db_select{*db_, source_table} .column("source_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); } -auto encrypt_provider::get_filesystem_item_and_file(const std::string &api_path, - api_file &file, - filesystem_item &fsi) const - -> api_error { +auto encrypt_provider::get_filesystem_item_and_file( + const std::string &api_path, api_file &file, + filesystem_item &fsi) const -> api_error { bool exists{}; auto res = is_directory(api_path, exists); if (res != api_error::success) { @@ -658,8 +652,8 @@ auto encrypt_provider::is_directory(const std::string &api_path, return api_error::success; } -auto encrypt_provider::is_file(const std::string &api_path, bool &exists) const - -> api_error { +auto encrypt_provider::is_file(const std::string &api_path, + bool &exists) const -> api_error { auto result = db::db_select{*db_, source_table} .column("source_path") .where("api_path") diff --git a/repertory/librepertory/src/types/remote.cpp b/repertory/librepertory/src/types/remote.cpp index f04bee5b..57e24bf2 100644 --- a/repertory/librepertory/src/types/remote.cpp +++ b/repertory/librepertory/src/types/remote.cpp @@ -22,7 +22,7 @@ #include "types/remote.hpp" namespace repertory::remote { -#ifndef _WIN32 +#if !defined(_WIN32) auto create_open_flags(std::uint32_t flags) -> open_flags { 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_CLOEXEC, open_flags::clo_exec); 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); #endif 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); #endif 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); #endif 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_NONBLOCK, open_flags::non_blocking); -#ifdef O_PATH +#if defined(O_PATH) set_if_has_flag(O_PATH, open_flags::path); #endif 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); #endif 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::clo_exec, O_CLOEXEC); 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); #endif 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); #endif 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); #endif 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::non_blocking, O_NONBLOCK); -#ifdef O_PATH +#if defined(O_PATH) set_if_has_flag(open_flags::path, O_PATH); #endif 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); #endif set_if_has_flag(open_flags::truncate, O_TRUNC); diff --git a/repertory/librepertory/src/utils/cli_utils.cpp b/repertory/librepertory/src/utils/cli_utils.cpp index 4b3a8c3c..ceeff2eb 100644 --- a/repertory/librepertory/src/utils/cli_utils.cpp +++ b/repertory/librepertory/src/utils/cli_utils.cpp @@ -50,8 +50,8 @@ void get_api_authentication_data(std::string &user, std::string &password, } } -[[nodiscard]] auto get_provider_type_from_args(std::vector args) - -> provider_type { +[[nodiscard]] auto +get_provider_type_from_args(std::vector args) -> provider_type { #if defined(REPERTORY_ENABLE_S3) if (has_option(args, options::s3_option)) { return provider_type::s3; @@ -67,8 +67,8 @@ void get_api_authentication_data(std::string &user, std::string &password, return provider_type::sia; } -auto has_option(std::vector args, const std::string &option_name) - -> bool { +auto has_option(std::vector args, + const std::string &option_name) -> bool { return std::find_if(args.begin(), args.end(), [&option_name](const auto &value) -> bool { return option_name == value; @@ -80,8 +80,8 @@ auto has_option(std::vector args, const option &opt) -> bool { } auto parse_option(std::vector args, - const std::string &option_name, std::uint8_t count) - -> std::vector { + const std::string &option_name, + std::uint8_t count) -> std::vector { std::vector ret; auto found{false}; for (std::size_t i = 0U; not found && (i < args.size()); i++) { @@ -119,10 +119,9 @@ auto parse_string_option(std::vector args, const option &opt, return ret; } -auto parse_drive_options(std::vector args, - [[maybe_unused]] provider_type &prov, - [[maybe_unused]] std::string &data_directory) - -> std::vector { +auto parse_drive_options( + std::vector args, [[maybe_unused]] provider_type &prov, + [[maybe_unused]] std::string &data_directory) -> std::vector { // Strip out options from command line const auto &option_list = options::option_list; std::vector drive_args; @@ -140,7 +139,7 @@ auto parse_drive_options(std::vector args, (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(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(1U)) #endif // REPERTORY_ENABLE_S3 @@ -150,7 +149,7 @@ auto parse_drive_options(std::vector args, } } -#ifndef _WIN32 +#if !defined(_WIN32) std::vector fuse_flags_list; for (std::size_t i = 1; i < drive_args.size(); i++) { if (drive_args.at(i).find("-o") == 0) { @@ -219,7 +218,7 @@ auto parse_drive_options(std::vector args, } #endif -#ifdef __APPLE__ +#if defined(__APPLE__) { auto it = std::remove_if( fuse_flags_list.begin(), fuse_flags_list.end(), diff --git a/repertory/librepertory/src/utils/file_utils.cpp b/repertory/librepertory/src/utils/file_utils.cpp index 84ad3ce7..8ceb89ad 100644 --- a/repertory/librepertory/src/utils/file_utils.cpp +++ b/repertory/librepertory/src/utils/file_utils.cpp @@ -31,7 +31,7 @@ namespace repertory::utils::file { auto calculate_used_space(std::string path, bool recursive) -> std::uint64_t { path = utils::path::absolute(path); std::uint64_t ret{}; -#ifdef _WIN32 +#if defined(_WIN32) WIN32_FIND_DATA fd{}; const auto search = utils::path::combine(path, {"*.*"}); 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() { -#ifdef _WIN32 +#if defined(_WIN32) std::string file_name; file_name.resize(MAX_PATH); ::GetModuleFileNameA(nullptr, &file_name[0u], @@ -91,7 +91,7 @@ void change_to_process_directory() { #else std::string path; path.resize(PATH_MAX + 1); -#ifdef __APPLE__ +#if defined(__APPLE__) proc_pidpath(getpid(), &path[0u], path.size()); #else 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; } -auto copy_directory_recursively(std::string from_path, std::string to_path) - -> bool { +auto copy_directory_recursively(std::string from_path, + std::string to_path) -> bool { from_path = utils::path::absolute(from_path); to_path = utils::path::absolute(to_path); auto ret = create_full_directory_path(to_path); if (ret) { -#ifdef _WIN32 +#if defined(_WIN32) WIN32_FIND_DATA fd{}; const auto search = utils::path::combine(from_path, {"*.*"}); 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 { -#ifdef _WIN32 +#if defined(_WIN32) const auto unicode_path = utils::string::from_utf8(utils::path::absolute(path)); return is_directory(path) || @@ -196,7 +196,7 @@ auto delete_directory(std::string path, bool recursive) -> bool { } path = utils::path::absolute(path); -#ifdef _WIN32 +#if defined(_WIN32) return (not is_directory(path) || utils::retryable_action([&]() -> bool { 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 { path = utils::path::absolute(path); -#ifdef _WIN32 +#if defined(_WIN32) WIN32_FIND_DATA fd{}; 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 { path = utils::path::absolute(path); -#ifdef _WIN32 +#if defined(_WIN32) return (not is_file(path) || utils::retryable_action([&]() -> bool { const auto ret = !!::DeleteFileA(path.c_str()); 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 { -#ifdef _WIN32 +#if defined(_WIN32) ULARGE_INTEGER li{}; ::GetDiskFreeSpaceEx(path.c_str(), &li, nullptr, nullptr); return li.QuadPart; #endif -#ifdef __linux__ +#if defined(__linux__) std::uint64_t ret = 0; struct statfs64 st {}; 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; #endif -#if __APPLE__ +#if defined(__APPLE__) struct statvfs st {}; statvfs(path.c_str(), &st); 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 { -#ifdef _WIN32 +#if defined(_WIN32) ULARGE_INTEGER li{}; ::GetDiskFreeSpaceEx(path.c_str(), nullptr, &li, nullptr); return li.QuadPart; #endif -#ifdef __linux__ +#if defined(__linux__) std::uint64_t ret = 0; struct statfs64 st {}; 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; #endif -#if __APPLE__ +#if defined(__APPLE__) struct statvfs st {}; statvfs(path.c_str(), &st); return st.f_blocks * st.f_frsize; #endif } -auto get_directory_files(std::string path, bool oldest_first, bool recursive) - -> std::deque { +auto get_directory_files(std::string path, bool oldest_first, + bool recursive) -> std::deque { path = utils::path::absolute(path); std::deque ret; std::unordered_map lookup; -#ifdef _WIN32 +#if defined(_WIN32) WIN32_FIND_DATA fd{}; const auto search = utils::path::combine(path, {"*.*"}); 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()) { struct stat st {}; stat(lookup_path.c_str(), &st); -#ifdef __APPLE__ +#if defined(__APPLE__) lookup[lookup_path] = static_cast( (st.st_mtimespec.tv_sec * NANOS_PER_SECOND) + st.st_mtimespec.tv_nsec); @@ -433,18 +433,18 @@ auto get_directory_files(std::string path, bool oldest_first, bool recursive) return ret; } -auto get_accessed_time(const std::string &path, std::uint64_t &accessed) - -> bool { +auto get_accessed_time(const std::string &path, + std::uint64_t &accessed) -> bool { auto ret = false; accessed = 0; -#ifdef _WIN32 +#if defined(_WIN32) struct _stat64 st {}; if (_stat64(path.c_str(), &st) != -1) { accessed = static_cast(st.st_atime); #else struct stat st {}; if (stat(path.c_str(), &st) != -1) { -#ifdef __APPLE__ +#if defined(__APPLE__) accessed = static_cast( st.st_atimespec.tv_nsec + (st.st_atimespec.tv_sec * NANOS_PER_SECOND)); #else @@ -458,18 +458,18 @@ auto get_accessed_time(const std::string &path, std::uint64_t &accessed) return ret; } -auto get_modified_time(const std::string &path, std::uint64_t &modified) - -> bool { +auto get_modified_time(const std::string &path, + std::uint64_t &modified) -> bool { auto ret = false; modified = 0u; -#ifdef _WIN32 +#if defined(_WIN32) struct _stat64 st {}; if (_stat64(path.c_str(), &st) != -1) { modified = static_cast(st.st_mtime); #else struct stat st {}; if (stat(path.c_str(), &st) != -1) { -#ifdef __APPLE__ +#if defined(__APPLE__) modified = static_cast( st.st_mtimespec.tv_nsec + (st.st_mtimespec.tv_sec * NANOS_PER_SECOND)); #else @@ -487,11 +487,11 @@ auto get_file_size(std::string path, std::uint64_t &file_size) -> bool { file_size = 0u; path = utils::path::finalize(path); -#ifdef _WIN32 +#if defined(_WIN32) struct _stat64 st {}; if (_stat64(path.c_str(), &st) != 0) { #else -#if __APPLE__ +#if defined(__APPLE__) struct stat st {}; if (stat(path.c_str(), &st) != 0) { #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 { -#ifdef _WIN32 +#if defined(_WIN32) return ::PathIsDirectory(path.c_str()) != 0; #else struct stat st {}; @@ -519,7 +519,7 @@ auto is_directory(const std::string &path) -> bool { } auto is_file(const std::string &path) -> bool { -#ifdef _WIN32 +#if defined(_WIN32) return (::PathFileExists(path.c_str()) && not ::PathIsDirectory(path.c_str())); #else @@ -535,7 +535,7 @@ auto is_modified_date_older_than(const std::string &path, if (get_modified_time(path, modified)) { const auto seconds = std::chrono::duration_cast(hours); -#ifdef _WIN32 +#if defined(_WIN32) return (std::chrono::system_clock::from_time_t( static_cast(modified)) + seconds) < std::chrono::system_clock::now(); @@ -557,7 +557,7 @@ auto move_file(std::string from, std::string to) -> bool { return false; } -#ifdef _WIN32 +#if defined(_WIN32) const bool ret = ::MoveFile(from.c_str(), to.c_str()) != 0; #else 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 ret = false; -#ifdef _WIN32 +#if defined(_WIN32) SYSTEMTIME st{}; ::GetSystemTime(&st); diff --git a/repertory/librepertory/src/utils/native_file.cpp b/repertory/librepertory/src/utils/native_file.cpp index 2b830db5..4b364710 100644 --- a/repertory/librepertory/src/utils/native_file.cpp +++ b/repertory/librepertory/src/utils/native_file.cpp @@ -38,14 +38,14 @@ native_file::~native_file() { auto native_file::clone(const native_file_ptr &ptr) -> native_file_ptr { std::string source_path; -#ifdef _WIN32 +#if defined(_WIN32) source_path.resize(MAX_PATH + 1); ::GetFinalPathNameByHandleA(ptr->get_handle(), source_path.data(), MAX_PATH + 1, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS); #else source_path.resize(PATH_MAX + 1); -#ifdef __APPLE__ +#if defined(__APPLE__) fcntl(ptr->get_handle(), F_GETPATH, source_path.data()); #else 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, native_file_ptr &ptr) -> api_error { -#ifdef _WIN32 +#if defined(_WIN32) auto handle = read_only ? ::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); } -auto native_file::open(const std::string &source_path, native_file_ptr &ptr) - -> api_error { +auto native_file::open(const std::string &source_path, + native_file_ptr &ptr) -> api_error { return open(source_path, false, ptr); } auto native_file::open(const std::string &source_path, bool read_only, native_file_ptr &ptr) -> api_error { -#ifdef _WIN32 +#if defined(_WIN32) auto handle = read_only ? ::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 { -#ifdef _WIN32 +#if defined(_WIN32) LARGE_INTEGER li{}; li.QuadPart = static_cast(file_size); return (::SetFilePointerEx(handle_, li, nullptr, FILE_BEGIN) && ::SetEndOfFile(handle_)); #endif -#ifdef __linux__ +#if defined(__linux__) return (fallocate(handle_, 0, 0, static_cast(file_size)) >= 0); #endif -#ifdef __APPLE__ +#if defined(__APPLE__) return (ftruncate(handle_, file_size) >= 0); #endif } void native_file::close() { if (handle_ != REPERTORY_INVALID_HANDLE) { -#ifdef WIN32 +#if defined(_WIN32) ::CloseHandle(handle_); #else ::close(handle_); @@ -183,7 +183,7 @@ auto native_file::copy_from(const std::string &path) -> bool { } void native_file::flush() { -#ifdef _WIN32 +#if defined(_WIN32) recur_mutex_lock l(read_write_mutex_); ::FlushFileBuffers(handle_); #else @@ -193,13 +193,13 @@ void native_file::flush() { auto native_file::get_file_size(std::uint64_t &file_size) -> bool { auto ret = false; -#ifdef _WIN32 +#if defined(_WIN32) LARGE_INTEGER li{}; if ((ret = ::GetFileSizeEx(handle_, &li) && (li.QuadPart >= 0))) { file_size = static_cast(li.QuadPart); } #else -#if __APPLE__ +#if defined(__APPLE__) struct stat unix_st {}; if (fstat(handle_, &unix_st) >= 0) { #else @@ -215,10 +215,10 @@ auto native_file::get_file_size(std::uint64_t &file_size) -> bool { return ret; } -#ifdef _WIN32 +#if defined(_WIN32) auto native_file::read_bytes(char *buffer, std::size_t read_size, - std::uint64_t read_offset, std::size_t &bytes_read) - -> bool { + std::uint64_t read_offset, + std::size_t &bytes_read) -> bool { recur_mutex_lock l(read_write_mutex_); auto ret = false; @@ -244,8 +244,8 @@ auto native_file::read_bytes(char *buffer, std::size_t read_size, } #else auto native_file::read_bytes(char *buffer, std::size_t read_size, - std::uint64_t read_offset, std::size_t &bytes_read) - -> bool { + std::uint64_t read_offset, + std::size_t &bytes_read) -> bool { bytes_read = 0U; ssize_t result = 0; do { @@ -260,7 +260,7 @@ auto native_file::read_bytes(char *buffer, std::size_t read_size, } #endif auto native_file::truncate(std::uint64_t file_size) -> bool { -#ifdef _WIN32 +#if defined(_WIN32) recur_mutex_lock l(read_write_mutex_); LARGE_INTEGER li{}; li.QuadPart = static_cast(file_size); @@ -271,7 +271,7 @@ auto native_file::truncate(std::uint64_t file_size) -> bool { #endif } -#ifdef _WIN32 +#if defined(_WIN32) auto native_file::write_bytes(const char *buffer, std::size_t write_size, std::uint64_t write_offset, std::size_t &bytes_written) -> bool { diff --git a/repertory/librepertory/src/utils/path_utils.cpp b/repertory/librepertory/src/utils/path_utils.cpp index ce2accc0..62a32726 100644 --- a/repertory/librepertory/src/utils/path_utils.cpp +++ b/repertory/librepertory/src/utils/path_utils.cpp @@ -28,7 +28,7 @@ namespace repertory::utils::path { auto absolute(std::string path) -> std::string { -#ifdef _WIN32 +#if defined(_WIN32) if (not path.empty() && ::PathIsRelative(&path[0u])) { std::string temp; temp.resize(MAX_PATH + 1); @@ -56,8 +56,8 @@ auto absolute(std::string path) -> std::string { return finalize(path); } -auto combine(std::string path, const std::vector &paths) - -> std::string { +auto combine(std::string path, + const std::vector &paths) -> std::string { return finalize( std::accumulate(paths.begin(), paths.end(), path, [](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); } -#ifdef _WIN32 +#if defined(_WIN32) if ((path.size() >= 2u) && (path[1u] == ':')) { 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; } -#ifndef _WIN32 +#if !defined(_WIN32) auto get_parent_directory(std::string path) -> std::string { auto ret = std::string(dirname(&path[0u])); if (ret == ".") { @@ -141,7 +141,7 @@ auto get_parent_directory(std::string path) -> std::string { #endif auto is_ads_file_path([[maybe_unused]] const std::string &path) -> bool { -#ifdef _WIN32 +#if defined(_WIN32) return utils::string::contains(path, ":"); #else return false; @@ -161,7 +161,7 @@ auto is_trash_directory(std::string path) -> bool { auto remove_file_name(std::string path) -> std::string { path = finalize(path); -#ifdef _WIN32 +#if defined(_WIN32) ::PathRemoveFileSpec(&path[0u]); path = path.c_str(); #else @@ -178,7 +178,7 @@ auto remove_file_name(std::string path) -> std::string { return path; } -#ifndef _WIN32 +#if !defined(_WIN32) auto resolve(std::string path) -> std::string { std::string home{}; use_getpwuid(getuid(), [&home](struct passwd *pw) { @@ -193,7 +193,7 @@ auto resolve(std::string path) -> std::string { #endif auto strip_to_file_name(std::string path) -> std::string { -#ifdef _WIN32 +#if defined(_WIN32) return ::PathFindFileName(&path[0u]); #else return utils::string::contains(path, "/") ? basename(&path[0u]) : path; diff --git a/repertory/librepertory/src/utils/unix/unix_utils.cpp b/repertory/librepertory/src/utils/unix/unix_utils.cpp index eb04219e..ea6396ef 100644 --- a/repertory/librepertory/src/utils/unix/unix_utils.cpp +++ b/repertory/librepertory/src/utils/unix/unix_utils.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _WIN32 +#if !defined(_WIN32) #include "utils/unix/unix_utils.hpp" @@ -27,7 +27,7 @@ #include "utils/utils.hpp" namespace repertory::utils { -#ifndef __APPLE__ +#if !defined(__APPLE__) auto convert_to_uint64(const pthread_t &thread) -> std::uint64_t { return static_cast(thread); } @@ -48,7 +48,7 @@ auto from_api_error(const api_error &err) -> int { case api_error::directory_not_found: return -ENOTDIR; case api_error::download_failed: -#ifdef __APPLE__ +#if defined(__APPLE__) return -EBADMSG; #else return -EREMOTEIO; @@ -84,13 +84,13 @@ auto from_api_error(const api_error &err) -> int { case api_error::xattr_exists: return -EEXIST; case api_error::xattr_not_found: -#ifdef __APPLE__ +#if defined(__APPLE__) return -ENOATTR; #else return -ENODATA; #endif case api_error::xattr_too_big: -#ifdef __APPLE__ +#if defined(__APPLE__) return -ENAMETOOLONG; #else return -E2BIG; @@ -112,7 +112,7 @@ auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool { int group_count{}; if (getgrouplist(pass->pw_name, pass->pw_gid, nullptr, &group_count) < 0) { groups.resize(static_cast(group_count)); -#ifdef __APPLE__ +#if defined(__APPLE__) getgrouplist(pass->pw_name, pass->pw_gid, reinterpret_cast(groups.data()), &group_count); #else @@ -142,7 +142,7 @@ auto to_api_error(int err) -> api_error { return api_error::directory_not_empty; case ENOTDIR: return api_error::directory_not_found; -#ifdef __APPLE__ +#if defined(__APPLE__) case EBADMSG: return api_error::download_failed; #else @@ -173,14 +173,14 @@ auto to_api_error(int err) -> api_error { return api_error::upload_failed; case ERANGE: return api_error::xattr_buffer_small; -#ifdef __APPLE__ +#if defined(__APPLE__) case ENOATTR: return api_error::xattr_not_found; #else case ENODATA: return api_error::xattr_not_found; #endif -#ifdef __APPLE__ +#if defined(__APPLE__) case ENAMETOOLONG: return api_error::xattr_too_big; #else diff --git a/repertory/librepertory/src/utils/utils.cpp b/repertory/librepertory/src/utils/utils.cpp index 7c47a8ab..01a580be 100644 --- a/repertory/librepertory/src/utils/utils.cpp +++ b/repertory/librepertory/src/utils/utils.cpp @@ -59,8 +59,8 @@ auto calculate_read_size(const uint64_t &total_size, std::size_t read_size, : read_size); } -auto compare_version_strings(std::string version1, std::string version2) - -> int { +auto compare_version_strings(std::string version1, + std::string version2) -> int { if (utils::string::contains(version1, "-")) { 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]); struct tm tm1 {}; -#ifdef _WIN32 +#if defined(_WIN32) utils::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1); #else 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); } -auto download_type_from_string(std::string type, - const download_type &default_type) - -> download_type { +auto download_type_from_string( + std::string type, const download_type &default_type) -> download_type { type = utils::string::to_lower(utils::string::trim(type)); if (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/ auto filetime_to_unix_time(const FILETIME &ft) -> remote::file_time { 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 { -#ifdef _WIN32 +#if defined(_WIN32) SYSTEMTIME st{}; ::GetSystemTime(&st); FILETIME ft{}; @@ -228,7 +227,7 @@ void get_local_time_now(struct tm &local_time) { const auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); -#ifdef _WIN32 +#if defined(_WIN32) localtime_s(&local_time, &now); #else 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 { -#ifdef _WIN32 +#if defined(_WIN32) return static_cast( std::chrono::system_clock::to_time_t(std::chrono::system_clock::now())); #else -#if __APPLE__ +#if defined(__APPLE__) return std::chrono::nanoseconds( std::chrono::system_clock::now().time_since_epoch()) .count(); @@ -280,7 +279,7 @@ auto get_time_now() -> std::uint64_t { auto reset_curl(CURL *curl_handle) -> CURL * { curl_easy_reset(curl_handle); -#if __APPLE__ +#if defined(__APPLE__) curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); #endif return curl_handle; diff --git a/repertory/librepertory/src/utils/windows/windows_utils.cpp b/repertory/librepertory/src/utils/windows/windows_utils.cpp index 10626e8e..b7a61ed0 100644 --- a/repertory/librepertory/src/utils/windows/windows_utils.cpp +++ b/repertory/librepertory/src/utils/windows/windows_utils.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef _WIN32 +#if defined(_WIN32) #include "utils/windows/windows_utils.hpp" @@ -27,7 +27,7 @@ #include "utils/com_init_wrapper.hpp" #include "utils/string_utils.hpp" -#ifndef STATUS_DEVICE_INSUFFICIENT_RESOURCES +#if !defined(STATUS_DEVICE_INSUFFICIENT_RESOURCES) #define STATUS_DEVICE_INSUFFICIENT_RESOURCES static_cast(0xC0000468L) #endif diff --git a/repertory/repertory/include/cli/help.hpp b/repertory/repertory/include/cli/help.hpp index 3fe06c13..f4845105 100644 --- a/repertory/repertory/include/cli/help.hpp +++ b/repertory/repertory/include/cli/help.hpp @@ -71,7 +71,7 @@ template inline void help(std::vector args) { << std::endl; std::cout << " -pw,--password Specify API password" << std::endl; -#ifndef _WIN32 +#if !defined(_WIN32) #if defined(REPERTORY_ENABLE_S3) std::cout << " -o s3 Enables S3 mode for " "'fstab' mounts" diff --git a/repertory/repertory/include/cli/mount.hpp b/repertory/repertory/include/cli/mount.hpp index bed44d00..8c188b31 100644 --- a/repertory/repertory/include/cli/mount.hpp +++ b/repertory/repertory/include/cli/mount.hpp @@ -32,7 +32,7 @@ #include "utils/file_utils.hpp" #include "utils/string_utils.hpp" -#ifdef _WIN32 +#if defined(_WIN32) #include "drives/winfsp/remotewinfsp/remote_client.hpp" #include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp" #include "drives/winfsp/winfsp_drive.hpp" @@ -84,7 +84,7 @@ mount(std::vector args, std::string data_directory, ? exit_code::success : exit_code::file_creation_failed; } else { -#ifdef _WIN32 +#if defined(_WIN32) if (utils::cli::has_option(args, utils::cli::options::hidden_option)) { ::ShowWindow(::GetConsoleWindow(), SW_HIDE); } @@ -92,7 +92,7 @@ mount(std::vector args, std::string data_directory, const auto drive_args = utils::cli::parse_drive_options(args, prov, data_directory); app_config config(prov, data_directory); -#ifdef _WIN32 +#if defined(_WIN32) if (config.get_enable_mount_manager() && not utils::is_process_elevated()) { com_init_wrapper cw; diff --git a/repertory/repertory/main.cpp b/repertory/repertory/main.cpp index 4047cd51..829aae09 100644 --- a/repertory/repertory/main.cpp +++ b/repertory/repertory/main.cpp @@ -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)) { std::string data; res = utils::cli::parse_string_option( diff --git a/repertory/repertory_test/include/fixtures/winfsp_fixture.hpp b/repertory/repertory_test/include/fixtures/winfsp_fixture.hpp index 168f1e79..ebc8179c 100644 --- a/repertory/repertory_test/include/fixtures/winfsp_fixture.hpp +++ b/repertory/repertory_test/include/fixtures/winfsp_fixture.hpp @@ -19,9 +19,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef REPERTORY_WINFSP_FIXTURE_H -#define REPERTORY_WINFSP_FIXTURE_H -#if _WIN32 +#ifndef REPERTORY_WINFSP_FIXTURE_HPP +#define REPERTORY_WINFSP_FIXTURE_HPP +#if defined(_WIN32) #include "test_common.hpp" @@ -47,7 +47,7 @@ protected: void SetUp() override { if (PROVIDER_INDEX != 0) { if (PROVIDER_INDEX == 1) { -#ifdef REPERTORY_ENABLE_S3 +#if defined(REPERTORY_ENABLE_S3) EXPECT_TRUE(utils::file::delete_directory_recursively( "./winfsp_test" + std::to_string(PROVIDER_INDEX))); @@ -145,4 +145,4 @@ protected: } // namespace repertory #endif -#endif // REPERTORY_WINFSP_FIXTURE_H +#endif // REPERTORY_WINFSP_FIXTURE_HPP diff --git a/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp b/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp index 03d3c17c..0ea317b5 100644 --- a/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp +++ b/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp @@ -21,7 +21,7 @@ */ #ifndef TESTS_MOCKS_MOCK_FUSE_DRIVE_HPP_ #define TESTS_MOCKS_MOCK_FUSE_DRIVE_HPP_ -#ifndef _WIN32 +#if !defined(_WIN32) #include "test_common.hpp" @@ -47,8 +47,8 @@ public: return api_error::success; } - auto check_parent_access(const std::string &, int) const - -> api_error override { + auto check_parent_access(const std::string &, + int) const -> api_error override { return api_error::success; } @@ -83,8 +83,8 @@ public: return 0U; } - auto get_item_meta(const std::string &api_path, api_meta_map &meta) const - -> api_error override { + auto get_item_meta(const std::string &api_path, + api_meta_map &meta) const -> api_error override { meta = const_cast(this)->meta_[api_path]; return api_error::success; } @@ -123,8 +123,8 @@ public: } auto rename_file(const std::string &from_api_path, - const std::string &to_api_path, bool overwrite) - -> int override { + const std::string &to_api_path, + bool overwrite) -> int override { const auto from_file_path = utils::path::combine(mount_location_, {from_api_path}); const auto to_file_path = diff --git a/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp b/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp index 8ff52680..106fe875 100644 --- a/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp +++ b/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp @@ -21,7 +21,7 @@ */ #ifndef TESTS_MOCKS_MOCK_WINFSP_DRIVE_HPP_ #define TESTS_MOCKS_MOCK_WINFSP_DRIVE_HPP_ -#ifdef _WIN32 +#if defined(_WIN32) #include "test_common.hpp" @@ -40,9 +40,8 @@ private: const std::string mount_location_; public: - [[nodiscard]] auto - get_directory_item_count(const std::string & /*api_path*/) const - -> std::uint64_t override { + [[nodiscard]] auto get_directory_item_count( + const std::string & /*api_path*/) const -> std::uint64_t override { return 1; } @@ -72,8 +71,8 @@ public: return 0; } - auto get_item_meta(const std::string & /*api_path*/, api_meta_map &meta) const - -> api_error override { + auto get_item_meta(const std::string & /*api_path*/, + api_meta_map &meta) const -> api_error override { return api_error::error; } @@ -83,10 +82,10 @@ public: return api_error::error; } - auto get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes, - PSECURITY_DESCRIPTOR descriptor, - std::uint64_t *descriptor_size) - -> NTSTATUS override { + auto + get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes, + PSECURITY_DESCRIPTOR descriptor, + std::uint64_t *descriptor_size) -> NTSTATUS override { auto ret = STATUS_SUCCESS; if (attributes) { diff --git a/repertory/repertory_test/include/test_common.hpp b/repertory/repertory_test/include/test_common.hpp index b77a584a..d1bda59b 100644 --- a/repertory/repertory_test/include/test_common.hpp +++ b/repertory/repertory_test/include/test_common.hpp @@ -22,7 +22,7 @@ #ifndef TESTS_TEST_COMMON_HPP_ #define TESTS_TEST_COMMON_HPP_ -#ifdef U +#if defined(U) #undef U #endif @@ -44,15 +44,14 @@ using ::testing::_; using namespace ::testing; namespace repertory { -[[nodiscard]] auto create_random_file(std::string path, std::size_t size) - -> native_file_ptr; +[[nodiscard]] auto create_random_file(std::string path, + std::size_t size) -> native_file_ptr; void delete_generated_files(); -[[nodiscard]] auto -generate_test_file_name(const std::string &directory, - const std::string &file_name_no_extension) - -> std::string; +[[nodiscard]] auto generate_test_file_name( + const std::string &directory, + const std::string &file_name_no_extension) -> std::string; template static void decrypt_and_verify(const T &buffer, const std::string &token, diff --git a/repertory/repertory_test/main.cpp b/repertory/repertory_test/main.cpp index a86f0c90..3eea32c7 100644 --- a/repertory/repertory_test/main.cpp +++ b/repertory/repertory_test/main.cpp @@ -21,13 +21,13 @@ */ #include "initialize.hpp" #include "test_common.hpp" -#ifdef _WIN32 +#if defined(_WIN32) #include "utils/cli_utils.hpp" #endif // _WIN32 using namespace repertory; -#ifdef _WIN32 +#if defined(_WIN32) std::size_t PROVIDER_INDEX{0U}; #endif // _WIN32 @@ -36,7 +36,7 @@ auto main(int argc, char **argv) -> int { return -1; } -#ifdef _WIN32 +#if defined(_WIN32) std::vector args; { auto args_span = std::span(argv, static_cast(argc)); diff --git a/repertory/repertory_test/src/config_test.cpp b/repertory/repertory_test/src/config_test.cpp index 64d53737..3086949f 100644 --- a/repertory/repertory_test/src/config_test.cpp +++ b/repertory/repertory_test/src/config_test.cpp @@ -49,7 +49,7 @@ const auto DEFAULT_SIA_CONFIG = "{\n" " \"EnableCommDurationEvents\": false,\n" " \"EnableDriveEvents\": false,\n" " \"EnableMaxCacheSize\": false,\n" -#ifdef _WIN32 +#if defined(_WIN32) " \"EnableMountManager\": false,\n" #endif " \"EventLevel\": \"normal\",\n" @@ -97,7 +97,7 @@ const auto DEFAULT_S3_CONFIG = "{\n" " \"EnableCommDurationEvents\": false,\n" " \"EnableDriveEvents\": false,\n" " \"EnableMaxCacheSize\": false,\n" -#ifdef _WIN32 +#if defined(_WIN32) " \"EnableMountManager\": false,\n" #endif " \"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()); } } -#ifdef _WIN32 +#if defined(_WIN32) TEST_F(config_test, enable_mount_manager) { bool original_value; { @@ -575,14 +575,14 @@ TEST_F(config_test, default_data_directory) { app_config::default_data_directory(provider_type::sia), }; -#ifdef _WIN32 +#if defined(_WIN32) const auto local_app_data = utils::get_environment_variable("localappdata"); #endif -#if __linux__ +#if defined(__linux__) const auto local_app_data = utils::path::combine(utils::get_environment_variable("HOME"), {".local"}); #endif -#ifdef __APPLE__ +#if defined(__APPLE__) const auto local_app_data = utils::path::combine( utils::get_environment_variable("HOME"), {"Library/Application Support"}); #endif diff --git a/repertory/repertory_test/src/file_manager_open_file_test.cpp b/repertory/repertory_test/src/file_manager_open_file_test.cpp index d165665a..6dc1d45f 100644 --- a/repertory/repertory_test/src/file_manager_open_file_test.cpp +++ b/repertory/repertory_test/src/file_manager_open_file_test.cpp @@ -588,7 +588,7 @@ TEST(open_file, can_add_handle) { {"filesystem_item_opened", "filesystem_item_handle_opened"}); file_manager::open_file o(test_chunk_size, 0U, fsi, mp, um); -#ifdef _WIN32 +#if defined(_WIN32) o.add(1u, {}); EXPECT_EQ(nullptr, o.get_open_data(1u).directory_buffer); #else @@ -653,7 +653,7 @@ TEST(open_file, can_remove_handle) { }); file_manager::open_file o(test_chunk_size, 0U, fsi, mp, um); -#ifdef _WIN32 +#if defined(_WIN32) o.add(1u, {}); #else o.add(1u, O_RDWR | O_SYNC); diff --git a/repertory/repertory_test/src/file_manager_test.cpp b/repertory/repertory_test/src/file_manager_test.cpp index 97400aa6..9f216e17 100644 --- a/repertory/repertory_test/src/file_manager_test.cpp +++ b/repertory/repertory_test/src/file_manager_test.cpp @@ -39,7 +39,7 @@ #include "utils/utils.hpp" namespace repertory { -#ifdef PROJECT_ENABLE_TESTING +#if defined(PROJECT_ENABLE_TESTING) auto file_manager::open(std::shared_ptr of, const open_file_data &ofd, std::uint64_t &handle, std::shared_ptr &f) -> api_error { @@ -154,7 +154,7 @@ TEST(file_manager, can_create_and_close_file) { EXPECT_STREQ("1", ee.get_handle().get().c_str()); }); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.create("/test_create.txt", meta, {}, handle, f)); #else @@ -270,7 +270,7 @@ TEST(file_manager, can_open_and_close_file) { }); std::shared_ptr f; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open("/test_open.txt", false, {}, handle, f)); #else @@ -360,7 +360,7 @@ TEST(file_manager, can_open_and_close_multiple_handles_for_same_file) { std::array handles; for (std::uint8_t i = 0u; i < handles.size(); i++) { std::shared_ptr f; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open("/test_open.txt", false, {}, handles[i], f)); #else @@ -440,7 +440,7 @@ TEST(file_manager, download_is_stored_after_write_if_partially_downloaded) { std::uint64_t handle{}; std::shared_ptr f; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open("/test_write_partial_download.txt", false, {}, handle, f)); #else @@ -602,7 +602,7 @@ TEST(file_manager, upload_occurs_after_write_if_fully_downloaded) { std::uint64_t handle{}; std::shared_ptr f; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open("/test_write_full_download.txt", false, {}, handle, f)); #else @@ -712,7 +712,7 @@ TEST(file_manager, can_evict_file) { return api_error::success; }); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.create("/test_evict.txt", meta, {}, handle, f)); #else @@ -843,7 +843,7 @@ TEST(file_manager, evict_file_fails_if_file_is_open) { std::uint64_t handle{}; std::shared_ptr f{}; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open("/test_open.txt", false, {}, handle, f)); #else @@ -978,7 +978,7 @@ TEST(file_manager, evict_file_fails_if_file_is_uploading) { return api_error::success; }); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.create("/test_evict.txt", meta, {}, handle, f)); #else @@ -1081,7 +1081,7 @@ TEST(file_manager, evict_file_fails_if_file_is_modified) { std::uint64_t handle{}; std::shared_ptr f; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f)); #else 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::shared_ptr f; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f)); #else 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::shared_ptr f; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::error, fm.create("/test_create.txt", meta, {}, handle, f)); #else @@ -1230,7 +1230,7 @@ TEST(file_manager, create_fails_if_provider_create_is_unsuccessful) { std::uint64_t handle{}; std::shared_ptr f{}; api_meta_map meta{}; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::error, fm.create("/test_create.txt", meta, {}, handle, f)); #else @@ -1319,7 +1319,7 @@ TEST(file_manager, std::uint64_t handle{}; std::shared_ptr f{}; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open(non_writeable, {}, handle, f)); EXPECT_CALL(*non_writeable, get_open_data()) .WillOnce([&handle]() -> std::map { @@ -1404,7 +1404,7 @@ TEST(file_manager, open_file_fails_if_provider_get_filesystem_item_fails) { std::uint64_t handle{}; std::shared_ptr f{}; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::error, fm.open(of, {}, handle, f)); #else 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::shared_ptr f{}; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::error, fm.open(of, {}, handle, f)); #else 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::shared_ptr f{}; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f)); #else 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::shared_ptr f{}; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f)); #else 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::shared_ptr f{}; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f)); #else 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::shared_ptr f; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(api_error::success, fm.open("/test_download_timeout.txt", false, {}, handle, f)); #else diff --git a/repertory/repertory_test/src/fuse_drive_test.cpp b/repertory/repertory_test/src/fuse_drive_test.cpp index da250257..261b1e94 100644 --- a/repertory/repertory_test/src/fuse_drive_test.cpp +++ b/repertory/repertory_test/src/fuse_drive_test.cpp @@ -34,7 +34,7 @@ #include "utils/file_utils.hpp" #include "utils/utils.hpp" -#ifndef ACCESSPERMS +#if !defined(ACCESSPERMS) #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */ #endif @@ -278,7 +278,7 @@ static void test_ftruncate(const std::string &file_path) { close(fd); } -#ifndef __APPLE__ +#if !defined(__APPLE__) static void test_fallocate(const std::string & /* api_path */, const std::string &file_path) { 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)); -#ifndef __APPLE__ +#if !defined(__APPLE__) EXPECT_EQ(-1, fallocate(fd, 0, 0, 16)); #endif @@ -536,7 +536,7 @@ TEST(fuse_drive, all_tests) { switch (idx) { case 0U: { -#ifdef REPERTORY_ENABLE_S3 +#if defined(REPERTORY_ENABLE_S3) config_ptr = std::make_unique(provider_type::s3, cfg_directory); { @@ -623,7 +623,7 @@ TEST(fuse_drive, all_tests) { test_ftruncate(file_path); unlink_file_and_test(file_path); -#ifndef __APPLE__ +#if !defined(__APPLE__) file_path = create_file_and_test(mount_location, "fallocate_file_test"); test_fallocate(utils::path::create_api_path("fallocate_file_test"), file_path); diff --git a/repertory/repertory_test/src/lock_data_test.cpp b/repertory/repertory_test/src/lock_data_test.cpp index c2aed1a5..08fe4845 100644 --- a/repertory/repertory_test/src/lock_data_test.cpp +++ b/repertory/repertory_test/src/lock_data_test.cpp @@ -40,7 +40,7 @@ TEST(lock_data, lock_and_unlock) { EXPECT_EQ(lock_result::success, l.grab_lock(10)); }).join(); -#ifdef _WIN32 +#if defined(_WIN32) lock_data l2(provider_type::remote, "1"); EXPECT_EQ(lock_result::success, l2.grab_lock()); @@ -49,7 +49,7 @@ TEST(lock_data, lock_and_unlock) { #endif } -#ifdef _WIN32 +#if defined(_WIN32) TEST(lock_data, set_and_unset_mount_state) { lock_data l(provider_type::sia, "1"); EXPECT_TRUE(l.set_mount_state(true, "C:", 99)); diff --git a/repertory/repertory_test/src/path_utils_test.cpp b/repertory/repertory_test/src/path_utils_test.cpp index 3f5dc082..96f36600 100644 --- a/repertory/repertory_test/src/path_utils_test.cpp +++ b/repertory/repertory_test/src/path_utils_test.cpp @@ -27,21 +27,21 @@ namespace repertory { TEST(path_utils, combine) { auto s = utils::path::combine(R"(\test\path)", {}); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_STREQ(R"(\test\path)", s.c_str()); #else EXPECT_STREQ("/test/path", s.c_str()); #endif s = utils::path::combine(R"(\test)", {R"(\path)"}); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_STREQ(R"(\test\path)", s.c_str()); #else EXPECT_STREQ("/test/path", s.c_str()); #endif s = utils::path::combine(R"(\test)", {R"(\path)", R"(\again\)"}); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_STREQ(R"(\test\path\again)", s.c_str()); #else EXPECT_STREQ("/test/path/again", s.c_str()); @@ -82,49 +82,49 @@ TEST(path_utils, finalize) { EXPECT_STREQ("", s.c_str()); s = utils::path::finalize(R"(\)"); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_STREQ(R"(\)", s.c_str()); #else EXPECT_STREQ("/", s.c_str()); #endif s = utils::path::finalize("/"); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_STREQ(R"(\)", s.c_str()); #else EXPECT_STREQ("/", s.c_str()); #endif s = utils::path::finalize(R"(\\)"); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_STREQ(R"(\)", s.c_str()); #else EXPECT_STREQ("/", s.c_str()); #endif s = utils::path::finalize("//"); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_STREQ(R"(\)", s.c_str()); #else EXPECT_STREQ("/", s.c_str()); #endif s = utils::path::finalize("/cow///moose/////dog/chicken"); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str()); #else EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str()); #endif s = utils::path::finalize("\\cow\\\\\\moose\\\\\\\\dog\\chicken/"); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str()); #else EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str()); #endif s = utils::path::finalize("/cow\\\\/moose\\\\/\\dog\\chicken\\"); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str()); #else EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str()); diff --git a/repertory/repertory_test/src/providers_test.cpp b/repertory/repertory_test/src/providers_test.cpp index bca1c1cd..b59c71c7 100644 --- a/repertory/repertory_test/src/providers_test.cpp +++ b/repertory/repertory_test/src/providers_test.cpp @@ -36,7 +36,7 @@ #include "gtest/gtest.h" namespace { -#ifdef _WIN32 +#if defined(_WIN32) using gid_t = std::uint32_t; using uid_t = std::uint32_t; 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_STREQ("/test.txt", file->api_path.c_str()); EXPECT_STREQ("/", file->api_parent.c_str()); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(std::size_t(47U), file->size); #else 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_STREQ("/sub10/moose.txt", file2->api_path.c_str()); EXPECT_STREQ("/sub10", file2->api_parent.c_str()); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(std::size_t(46U), file2->size); #else 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("/", file.api_parent.c_str()); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(std::size_t(47U), file.file_size); #else EXPECT_EQ(std::size_t(46U), file.file_size); diff --git a/repertory/repertory_test/src/remote_fuse_test.cpp b/repertory/repertory_test/src/remote_fuse_test.cpp index 7625f8c8..482bc150 100644 --- a/repertory/repertory_test/src/remote_fuse_test.cpp +++ b/repertory/repertory_test/src/remote_fuse_test.cpp @@ -21,7 +21,7 @@ */ #include "test_common.hpp" -#ifdef _WIN32 +#if defined(_WIN32) #define NOT_IMPLEMENTED STATUS_NOT_IMPLEMENTED #include "drives/winfsp/i_winfsp_drive.hpp" #include "drives/winfsp/remotewinfsp/remote_server.hpp" @@ -37,7 +37,7 @@ #include "utils/utils.hpp" using namespace repertory; -#ifdef _WIN32 +#if defined(_WIN32) using namespace repertory::remote_winfsp; #else using namespace repertory::remote_fuse; @@ -77,7 +77,7 @@ static void chflags_test(repertory::remote_fuse::remote_client &client) { EXPECT_EQ(0, ret); if (ret == 0) { 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)); #else 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); if (ret == 0) { 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)); #else 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); if (ret == 0) { 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)); #else 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_FALSE(directory); -#ifdef _WIN32 +#if defined(_WIN32) struct _stat64 st1 {}; _stat64(&test_file[0], &st1); #else @@ -244,7 +244,7 @@ static void fsetattr_x_test(repertory::remote_fuse::remote_client &client) { EXPECT_EQ(0, ret); if (ret == 0) { remote::setattr_x attr{}; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_fsetattr_x(api_path.c_str(), attr, handle)); #else @@ -319,7 +319,7 @@ static void getattr_test(repertory::remote_fuse::remote_client &client) { remote::stat st{}; EXPECT_EQ(0, client.fuse_getattr(api_path.c_str(), st, directory)); EXPECT_FALSE(directory); -#ifdef _WIN32 +#if defined(_WIN32) struct _stat64 st1 {}; _stat64(&test_file[0], &st1); #else @@ -355,7 +355,7 @@ api_path = test_file.substr(mount_location_.size()); api_path.c_str(), 0, remote::open_flags::Create | remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) { 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", nullptr, 0)); #else EXPECT_EQ(-EACCES, client.fuse_getxattr(api_path.c_str(), "test", nullptr, 0)); #endif @@ -396,7 +396,7 @@ static void getxtimes_test(repertory::remote_fuse::remote_client &client) { if (ret == 0) { remote::file_time bkuptime = 0; remote::file_time crtime = 0; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_getxtimes(api_path.c_str(), bkuptime, crtime)); #else @@ -423,7 +423,7 @@ api_path = test_file.substr(mount_location_.size()); api_path.c_str(), 0, remote::open_flags::Create | remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) { 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, 0)); #else EXPECT_EQ(-EIO, client.fuse_listxattr(api_path.c_str(), nullptr, 0)); #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()); EXPECT_TRUE(utils::file::delete_directory(test_directory)); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0)); #else 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)); remote::file_handle handle; -#ifdef _WIN32 +#if defined(_WIN32) const auto ret = client.fuse_create( api_path.c_str(), 0, 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()); EXPECT_TRUE(utils::file::delete_directory(test_directory)); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0)); #else 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()); EXPECT_TRUE(utils::file::delete_directory(test_directory)); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0)); #else 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 | remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) { 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(), "test")); #else EXPECT_EQ(-EACCES, client.fuse_removexattr(api_path.c_str(), "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)); remote::file_handle handle; -#ifdef _WIN32 +#if defined(_WIN32) const auto ret = client.fuse_create( api_path.c_str(), 0, 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()); EXPECT_TRUE(utils::file::delete_directory(test_directory)); -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0)); #else 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)); remote::setattr_x attr{}; -#ifdef _WIN32 +#if defined(_WIN32) EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setattr_x(api_path.c_str(), attr)); #else 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)); 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)); #else 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)); 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)); #else 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)); 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)); #else 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 | remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) { 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_setxattr(api_path.c_str(), "test", "moose", 5, 0)); #else @@ -796,7 +796,7 @@ remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) { utils::file::retry_delete_file(test_file); }*/ -#ifdef _WIN32 +#if defined(_WIN32) static void test_statfs(repertory::remote_fuse::remote_client &client, const i_winfsp_drive &drive) { #else @@ -823,7 +823,7 @@ static void test_statfs(repertory::remote_fuse::remote_client &client, EXPECT_EQ(st.f_favail, st.f_ffree); } -#ifdef _WIN32 +#if defined(_WIN32) static void statfs_x_test(repertory::remote_fuse::remote_client &client, const i_winfsp_drive &drive) { #else @@ -860,7 +860,7 @@ static void truncate_test(repertory::remote_fuse::remote_client &client) { EXPECT_TRUE(utils::file::retry_delete_file(test_file)); remote::file_handle handle; -#ifdef _WIN32 +#if defined(_WIN32) const auto ret = client.fuse_create( api_path.c_str(), 0, 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); event_system::instance().start(); -#ifdef _WIN32 +#if defined(_WIN32) mount_location_ = std::string(__FILE__).substr(0, 2); mock_winfsp_drive drive(mount_location_); remote_server server(config, drive, mount_location_); diff --git a/repertory/repertory_test/src/remote_winfsp_test.cpp b/repertory/repertory_test/src/remote_winfsp_test.cpp index 09ea70af..f925622f 100644 --- a/repertory/repertory_test/src/remote_winfsp_test.cpp +++ b/repertory/repertory_test/src/remote_winfsp_test.cpp @@ -24,7 +24,7 @@ #include "drives/winfsp/i_winfsp_drive.hpp" #include "drives/winfsp/remotewinfsp/remote_client.hpp" #include "events/consumers/console_consumer.hpp" -#ifdef _WIN32 +#if defined(_WIN32) #include "drives/winfsp/remotewinfsp/remote_server.hpp" #include "mocks/mock_winfsp_drive.hpp" #else @@ -409,7 +409,7 @@ static void set_basic_info_test(remote_client &client) { EXPECT_EQ(STATUS_SUCCESS, ret); const auto attributes = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE; -#ifdef _WIN32 +#if defined(_WIN32) SYSTEMTIME st{}; ::GetSystemTime(&st); @@ -493,7 +493,7 @@ TEST(remote_winfsp, all_tests) { config.set_event_level(event_level::verbose); event_system::instance().start(); -#ifdef _WIN32 +#if defined(_WIN32) mount_location_ = std::string(__FILE__).substr(0, 2); mock_winfsp_drive drive(mount_location_); remote_server server(config, drive, mount_location_); diff --git a/repertory/repertory_test/src/utils_test.cpp b/repertory/repertory_test/src/utils_test.cpp index 424116c9..d1d73c57 100644 --- a/repertory/repertory_test/src/utils_test.cpp +++ b/repertory/repertory_test/src/utils_test.cpp @@ -27,7 +27,7 @@ #include "utils/utils.hpp" namespace repertory { -#ifdef _WIN32 +#if defined(_WIN32) TEST(utils, convert_api_date) { LARGE_INTEGER li{}; li.QuadPart = utils::convert_api_date("2009-10-12T17:50:30.111Z"); diff --git a/repertory/repertory_test/src/winfsp_test.cpp b/repertory/repertory_test/src/winfsp_test.cpp index b8e5ed3e..8f9fb368 100644 --- a/repertory/repertory_test/src/winfsp_test.cpp +++ b/repertory/repertory_test/src/winfsp_test.cpp @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#if _WIN32 +#if defined(_WIN32) #include "test_common.hpp" @@ -333,7 +333,7 @@ TEST_F(winfsp_test, all_tests) { return; } -#ifndef REPERTORY_ENABLE_S3 +#if !defined(REPERTORY_ENABLE_S3) if (PROVIDER_INDEX == 1U) { return; }