From 87d336141ce2e1e1d0935e9a7c1acf13241fa1a8 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 25 Jul 2025 07:51:03 -0500 Subject: [PATCH] v2.0.6-release (#50) Reviewed-on: https://git.fifthgrid.com/BlockStorage/repertory/pulls/50 --- .cspell/words.txt | 3 + .vimspector.json | 36 - CHANGELOG.md | 24 + README.md | 2 +- cmake/hashes.cmake | 26 +- cmake/libraries/winfsp.cmake | 4 +- cmake/versions.cmake | 33 +- config.sh | 7 +- docker/aarch64/alpine | 2 +- docker/x86_64/alpine | 2 +- docker/x86_64/mingw64 | 8 +- .../include/comm/curl/curl_comm.hpp | 217 +- .../include/comm/curl/curl_shared.hpp | 67 + .../comm/curl/requests/http_delete.hpp | 10 +- .../include/comm/curl/requests/http_get.hpp | 8 +- .../include/comm/curl/requests/http_head.hpp | 8 +- .../include/comm/curl/requests/http_post.hpp | 10 +- .../comm/curl/requests/http_put_file.hpp | 11 +- .../comm/curl/requests/http_request_base.hpp | 2 + .../librepertory/include/comm/i_http_comm.hpp | 27 +- .../include/comm/packet/client_pool.hpp | 2 +- repertory/librepertory/include/common.hpp | 17 +- .../include/drives/directory_iterator.hpp | 10 +- .../include/drives/fuse/fuse_base.hpp | 347 +- .../include/drives/fuse/fuse_drive.hpp | 298 +- .../include/drives/fuse/fuse_drive_base.hpp | 85 +- .../include/drives/fuse/i_fuse_drive.hpp | 52 +- .../drives/fuse/remotefuse/remote_client.hpp | 138 +- .../drives/fuse/remotefuse/remote_server.hpp | 3 +- .../drives/remote/remote_server_base.hpp | 3017 ++++++----- .../winfsp/remotewinfsp/i_remote_instance.hpp | 109 +- .../winfsp/remotewinfsp/remote_client.hpp | 120 +- .../winfsp/remotewinfsp/remote_server.hpp | 258 +- .../events/consumers/logging_consumer.hpp | 5 +- .../include/events/event_system.hpp | 4 +- .../include/events/types/curl_error.hpp | 15 +- .../include/events/types/debug_log.hpp | 4 +- .../events/types/directory_remove_failed.hpp | 4 +- .../events/types/directory_removed.hpp | 4 +- .../types/directory_removed_externally.hpp | 4 +- .../include/events/types/download_begin.hpp | 4 +- .../include/events/types/download_end.hpp | 4 +- .../events/types/download_progress.hpp | 4 +- .../events/types/download_restore_failed.hpp | 4 +- .../events/types/download_restored.hpp | 4 +- .../types/download_resume_add_failed.hpp | 4 +- .../events/types/download_resume_added.hpp | 4 +- .../events/types/download_resume_removed.hpp | 4 +- .../events/types/download_type_selected.hpp | 4 +- .../events/types/drive_mount_failed.hpp | 4 +- .../events/types/drive_mount_result.hpp | 4 +- .../include/events/types/drive_mounted.hpp | 4 +- .../events/types/drive_stop_timed_out.hpp | 4 +- .../events/types/drive_unmount_pending.hpp | 4 +- .../include/events/types/drive_unmounted.hpp | 4 +- .../events/types/event_level_changed.hpp | 4 +- .../include/events/types/file_pinned.hpp | 4 +- .../events/types/file_remove_failed.hpp | 4 +- .../include/events/types/file_removed.hpp | 4 +- .../events/types/file_removed_externally.hpp | 4 +- .../include/events/types/file_unpinned.hpp | 4 +- .../events/types/file_upload_completed.hpp | 4 +- .../events/types/file_upload_failed.hpp | 4 +- .../events/types/file_upload_not_found.hpp | 4 +- .../events/types/file_upload_queued.hpp | 4 +- .../events/types/file_upload_removed.hpp | 4 +- .../events/types/file_upload_retry.hpp | 4 +- .../events/types/filesystem_item_added.hpp | 4 +- .../events/types/filesystem_item_closed.hpp | 4 +- .../events/types/filesystem_item_evicted.hpp | 4 +- .../types/filesystem_item_handle_closed.hpp | 4 +- .../types/filesystem_item_handle_opened.hpp | 4 +- .../events/types/filesystem_item_opened.hpp | 4 +- .../include/events/types/fuse_args_parsed.hpp | 4 +- .../include/events/types/fuse_event.hpp | 4 +- .../include/events/types/info_log.hpp | 68 + .../events/types/invalid_cache_size.hpp | 4 +- .../include/events/types/item_timeout.hpp | 4 +- .../events/types/max_cache_size_reached.hpp | 4 +- .../events/types/orphaned_file_detected.hpp | 4 +- .../types/orphaned_file_processing_failed.hpp | 4 +- .../types/orphaned_source_file_detected.hpp | 4 +- .../types/orphaned_source_file_removed.hpp | 4 +- .../events/types/packet_client_timeout.hpp | 4 +- .../events/types/polling_item_begin.hpp | 4 +- .../include/events/types/polling_item_end.hpp | 4 +- .../events/types/provider_invalid_version.hpp | 4 +- .../include/events/types/provider_offline.hpp | 4 +- .../events/types/provider_upload_begin.hpp | 4 +- .../events/types/provider_upload_end.hpp | 4 +- .../events/types/remote_server_event.hpp | 4 +- .../events/types/repertory_exception.hpp | 4 +- .../events/types/service_start_begin.hpp | 4 +- .../events/types/service_start_end.hpp | 4 +- .../events/types/service_stop_begin.hpp | 4 +- .../include/events/types/service_stop_end.hpp | 4 +- .../include/events/types/trace_log.hpp | 68 + .../events/types/unmount_requested.hpp | 4 +- .../include/events/types/unmount_result.hpp | 4 +- .../include/events/types/warn_log.hpp | 68 + .../include/events/types/winfsp_event.hpp | 4 +- .../include/file_manager/cache_size_mgr.hpp | 2 +- .../include/file_manager/file_manager.hpp | 2 +- .../include/file_manager/open_file_base.hpp | 4 +- .../include/file_manager/ring_buffer_base.hpp | 2 +- .../providers/encrypt/encrypt_provider.hpp | 2 + .../include/providers/s3/s3_provider.hpp | 5 +- .../include/providers/sia/sia_provider.hpp | 16 +- .../include/rpc/server/server.hpp | 7 +- .../librepertory/include/types/remote.hpp | 21 +- .../librepertory/include/types/repertory.hpp | 201 +- repertory/librepertory/include/types/s3.hpp | 8 +- .../librepertory/include/utils/cli_utils.hpp | 56 +- .../include/utils/error_utils.hpp | 8 +- .../include/utils/unix/unix_utils.hpp | 2 +- .../include/utils/windows/windows_utils.hpp | 18 +- .../librepertory/src/comm/curl/curl_comm.cpp | 64 +- .../src/comm/curl/curl_shared.cpp | 82 + .../src/comm/curl/multi_request.cpp | 15 +- .../src/comm/packet/packet_client.cpp | 2 +- .../src/drives/directory_iterator.cpp | 31 +- .../src/drives/fuse/fuse_base.cpp | 83 +- .../src/drives/fuse/fuse_drive.cpp | 82 +- .../src/drives/fuse/fuse_drive_base.cpp | 39 +- .../drives/fuse/remotefuse/remote_client.cpp | 8 + .../fuse/remotefuse/remote_fuse_drive.cpp | 56 +- .../drives/fuse/remotefuse/remote_server.cpp | 468 +- .../winfsp/remotewinfsp/remote_client.cpp | 30 +- .../winfsp/remotewinfsp/remote_server.cpp | 16 +- .../remotewinfsp/remote_winfsp_drive.cpp | 78 +- .../src/drives/winfsp/winfsp_drive.cpp | 11 +- .../src/file_manager/cache_size_mgr.cpp | 9 +- .../src/file_manager/file_manager.cpp | 25 +- .../src/file_manager/open_file.cpp | 5 +- .../src/file_manager/open_file_base.cpp | 4 +- .../src/file_manager/ring_buffer_base.cpp | 1 + repertory/librepertory/src/initialize.cpp | 59 +- .../src/platform/unix_platform.cpp | 2 +- .../src/platform/win32_platform.cpp | 2 +- .../src/providers/base_provider.cpp | 34 +- .../providers/encrypt/encrypt_provider.cpp | 75 +- .../src/providers/s3/s3_provider.cpp | 96 +- .../src/providers/sia/sia_provider.cpp | 296 +- .../librepertory/src/rpc/server/server.cpp | 378 +- .../librepertory/src/types/repertory.cpp | 2 +- .../librepertory/src/utils/error_utils.cpp | 36 +- .../src/utils/unix/unix_utils.cpp | 2 +- .../src/utils/windows/windows_utils.cpp | 2 +- repertory/repertory/include/cli/actions.hpp | 6 +- .../repertory/include/cli/check_version.hpp | 9 +- repertory/repertory/include/cli/common.hpp | 60 + .../repertory/include/cli/display_config.hpp | 7 +- .../include/cli/drive_information.hpp | 7 +- repertory/repertory/include/cli/get.hpp | 7 +- .../include/cli/get_directory_items.hpp | 6 +- .../include/cli/get_pinned_files.hpp | 6 +- .../repertory/include/cli/get_version.hpp | 2 +- repertory/repertory/include/cli/help.hpp | 2 + repertory/repertory/include/cli/mount.hpp | 29 +- .../repertory/include/cli/open_files.hpp | 18 +- repertory/repertory/include/cli/pin_file.hpp | 6 +- .../repertory/include/cli/pinned_status.hpp | 6 +- repertory/repertory/include/cli/set.hpp | 7 +- repertory/repertory/include/cli/status.hpp | 3 +- repertory/repertory/include/cli/test.hpp | 46 + repertory/repertory/include/cli/ui.hpp | 5 +- repertory/repertory/include/cli/unmount.hpp | 6 +- .../repertory/include/cli/unpin_file.hpp | 6 +- repertory/repertory/include/ui/handlers.hpp | 17 +- repertory/repertory/main.cpp | 3 +- repertory/repertory/src/ui/handlers.cpp | 181 +- .../include/fixtures/fuse_fixture.hpp | 53 +- .../include/fixtures/winfsp_fixture.hpp | 57 +- .../include/mocks/mock_fuse_drive.hpp | 20 +- repertory/repertory_test/main.cpp | 15 +- .../repertory_test/src/curl_comm_test.cpp | 12 +- .../src/direct_open_file_test.cpp | 10 +- .../repertory_test/src/open_file_test.cpp | 4 +- .../src/ring_buffer_open_file_test.cpp | 10 +- repertory/repertory_test/src/upload_test.cpp | 2 +- .../src/winfsp_drive_info_test.cpp | 6 +- .../src/winfsp_drive_rdrw_test.cpp | 3 + .../src/winfsp_drive_rename_test.cpp | 57 +- .../src/winfsp_drive_volume_test.cpp | 15 +- repertory/version.cpp.in | 6 +- scripts/copy_mingw64_deps.sh | 2 +- scripts/libraries.sh | 2 +- scripts/versions.sh | 33 +- support/3rd_party/boost_1_87_0.tar.gz | 3 - support/3rd_party/boost_1_87_0.tar.gz.sha256 | 1 - support/3rd_party/boost_1_88_0.tar.gz | 3 + support/3rd_party/boost_1_88_0.tar.gz.sha256 | 1 + support/3rd_party/cpp-httplib-0.19.0.tar.gz | 3 - .../cpp-httplib-0.19.0.tar.gz.sha256 | 1 - support/3rd_party/cpp-httplib-0.23.1.tar.gz | 3 + .../cpp-httplib-0.23.1.tar.gz.sha256 | 1 + support/3rd_party/curl-8.12.1.tar.gz | 3 - support/3rd_party/curl-8.12.1.tar.gz.sha256 | 1 - support/3rd_party/curl-8.15.0.tar.gz | 3 + support/3rd_party/curl-8.15.0.tar.gz.sha256 | 1 + support/3rd_party/googletest-1.15.2.tar.gz | 3 - .../3rd_party/googletest-1.15.2.tar.gz.sha256 | 1 - support/3rd_party/googletest-1.16.0.tar.gz | 3 - .../3rd_party/googletest-1.16.0.tar.gz.sha256 | 1 - support/3rd_party/googletest-1.17.0.tar.gz | 3 + .../3rd_party/googletest-1.17.0.tar.gz.sha256 | 1 + support/3rd_party/json-3.11.3.tar.gz | 3 - support/3rd_party/json-3.11.3.tar.gz.sha256 | 1 - support/3rd_party/json-3.12.0.tar.gz | 3 + support/3rd_party/json-3.12.0.tar.gz.sha256 | 1 + .../3rd_party/mingw64/binutils-2.43.tar.xz | 3 - .../mingw64/binutils-2.43.tar.xz.sha256 | 1 - .../3rd_party/mingw64/binutils-2.44.tar.xz | 3 + .../mingw64/binutils-2.44.tar.xz.sha256 | 1 + support/3rd_party/mingw64/expat-2.6.4.tar.gz | 3 - .../mingw64/expat-2.6.4.tar.gz.sha256 | 1 - support/3rd_party/mingw64/expat-2.7.1.tar.gz | 3 + .../mingw64/expat-2.7.1.tar.gz.sha256 | 1 + support/3rd_party/mingw64/gcc-14.2.0.tar.gz | 3 - .../mingw64/gcc-14.2.0.tar.gz.sha256 | 1 - support/3rd_party/mingw64/gcc-15.1.0.tar.gz | 3 + .../mingw64/gcc-15.1.0.tar.gz.sha256 | 1 + .../mingw64/mingw-w64-v12.0.0.tar.bz2.sha256 | 1 - ....0.0.tar.bz2 => mingw-w64-v13.0.0.tar.bz2} | Bin 10474283 -> 10868704 bytes .../mingw64/mingw-w64-v13.0.0.tar.bz2.sha256 | 1 + support/3rd_party/openssl-3.4.1.tar.gz | 3 - support/3rd_party/openssl-3.4.1.tar.gz.sha256 | 1 - support/3rd_party/openssl-3.5.1.tar.gz | 3 + support/3rd_party/openssl-3.5.1.tar.gz.sha256 | 1 + support/3rd_party/rocksdb-10.4.2.tar.gz | 3 + .../3rd_party/rocksdb-10.4.2.tar.gz.sha256 | 1 + support/3rd_party/rocksdb-9.10.0.tar.gz | 3 - .../3rd_party/rocksdb-9.10.0.tar.gz.sha256 | 1 - support/3rd_party/spdlog-1.15.1.tar.gz | 3 - support/3rd_party/spdlog-1.15.1.tar.gz.sha256 | 1 - support/3rd_party/spdlog-1.15.3.tar.gz | 3 + support/3rd_party/spdlog-1.15.3.tar.gz.sha256 | 1 + .../3rd_party/sqlite-amalgamation-3490100.zip | 3 - .../sqlite-amalgamation-3490100.zip.sha256 | 1 - .../3rd_party/sqlite-amalgamation-3500300.zip | 3 + .../sqlite-amalgamation-3500300.zip.sha256 | 1 + .../3rd_party/winfsp-2.0/bin/memfs-a64.exe | Bin 152352 -> 0 bytes .../3rd_party/winfsp-2.0/bin/memfs-x64.exe | Bin 171296 -> 0 bytes .../3rd_party/winfsp-2.0/bin/memfs-x86.exe | Bin 134944 -> 0 bytes .../3rd_party/winfsp-2.0/bin/winfsp-a64.dll | Bin 206624 -> 0 bytes .../3rd_party/winfsp-2.0/bin/winfsp-x64.dll | Bin 197920 -> 0 bytes .../3rd_party/winfsp-2.0/bin/winfsp-x64.sys | Bin 168512 -> 0 bytes .../3rd_party/winfsp-2.0/bin/winfsp-x86.dll | Bin 162592 -> 0 bytes .../3rd_party/winfsp-2.0/inc/winfsp/fsctl.h | 839 --- .../3rd_party/winfsp-2.0/lib/winfsp-a64.lib | Bin 54816 -> 0 bytes .../3rd_party/winfsp-2.0/lib/winfsp-x64.lib | Bin 54816 -> 0 bytes .../3rd_party/winfsp-2.0/lib/winfsp-x86.lib | Bin 55986 -> 0 bytes .../{winfsp-2.0 => winfsp-2.1}/License.txt | 1416 +++--- .../{winfsp-2.0 => winfsp-2.1}/bin/diag.bat | 108 +- .../bin/fsptool-a64.exe | Bin 19744 -> 19680 bytes .../bin/fsptool-x64.exe | Bin 20256 -> 20200 bytes .../bin/fsptool-x86.exe | Bin 18720 -> 18656 bytes .../{winfsp-2.0 => winfsp-2.1}/bin/fsreg.bat | 84 +- .../bin/launchctl-a64.exe | Bin 16160 -> 16096 bytes .../bin/launchctl-x64.exe | Bin 15648 -> 15592 bytes .../bin/launchctl-x86.exe | Bin 15648 -> 15584 bytes .../bin/launcher-a64.exe | Bin 34080 -> 34016 bytes .../bin/launcher-x64.exe | Bin 34592 -> 34536 bytes .../bin/launcher-x86.exe | Bin 28960 -> 28896 bytes .../3rd_party/winfsp-2.1/bin/memfs-a64.exe | Bin 0 -> 150752 bytes .../bin/memfs-dotnet-msil.exe | Bin 35616 -> 35552 bytes .../3rd_party/winfsp-2.1/bin/memfs-x64.exe | Bin 0 -> 161000 bytes .../3rd_party/winfsp-2.1/bin/memfs-x86.exe | Bin 0 -> 132328 bytes .../3rd_party/winfsp-2.1/bin/winfsp-a64.dll | Bin 0 -> 207080 bytes .../bin/winfsp-a64.sys | Bin 172056 -> 172184 bytes .../bin/winfsp-msil.dll | Bin 188704 -> 188648 bytes .../bin/winfsp-msil.xml | 2750 +++++----- .../3rd_party/winfsp-2.1/bin/winfsp-x64.dll | Bin 0 -> 198376 bytes .../3rd_party/winfsp-2.1/bin/winfsp-x64.sys | Bin 0 -> 168600 bytes .../3rd_party/winfsp-2.1/bin/winfsp-x86.dll | Bin 0 -> 163552 bytes .../bin/winfsp-x86.sys | Bin 140312 -> 140440 bytes .../inc/fuse/fuse.h | 542 +- .../inc/fuse/fuse_common.h | 404 +- .../inc/fuse/fuse_opt.h | 266 +- .../inc/fuse/winfsp_fuse.h | 869 ++-- .../inc/fuse3/fuse.h | 676 +-- .../inc/fuse3/fuse_common.h | 476 +- .../inc/fuse3/fuse_opt.h | 46 +- .../inc/fuse3/winfsp_fuse.h | 164 +- .../3rd_party/winfsp-2.1/inc/winfsp/fsctl.h | 812 +++ .../inc/winfsp/launch.h | 700 +-- .../inc/winfsp/winfsp.h | 4480 ++++++++--------- .../inc/winfsp/winfsp.hpp | 1804 +++---- .../{winfsp-2.0 => winfsp-2.1}/lib/fuse.pc | 22 +- .../{winfsp-2.0 => winfsp-2.1}/lib/fuse3.pc | 22 +- .../3rd_party/winfsp-2.1/lib/winfsp-a64.lib | Bin 0 -> 55054 bytes .../3rd_party/winfsp-2.1/lib/winfsp-x64.lib | Bin 0 -> 55054 bytes .../3rd_party/winfsp-2.1/lib/winfsp-x86.lib | Bin 0 -> 56230 bytes support/include/utils/collection.hpp | 4 +- support/include/utils/config.hpp | 13 +- support/include/utils/encryption.hpp | 2 +- support/include/utils/file.hpp | 4 + support/include/utils/path.hpp | 44 +- support/include/utils/time.hpp | 6 +- support/src/utils/common.cpp | 1 + support/src/utils/directory.cpp | 52 + support/src/utils/file.cpp | 12 +- support/src/utils/file_directory.cpp | 20 +- support/src/utils/path.cpp | 14 +- support/test/src/utils/common_test.cpp | 8 +- support/test/src/utils/encryption_test.cpp | 4 +- support/test/src/utils/file_test.cpp | 47 +- web/repertory/lib/helpers.dart | 4 +- web/repertory/lib/models/mount.dart | 27 + .../lib/screens/add_mount_screen.dart | 86 +- web/repertory/lib/widgets/mount_settings.dart | 6 + 311 files changed, 13495 insertions(+), 12079 deletions(-) delete mode 100644 .vimspector.json create mode 100644 repertory/librepertory/include/comm/curl/curl_shared.hpp create mode 100644 repertory/librepertory/include/events/types/info_log.hpp create mode 100644 repertory/librepertory/include/events/types/trace_log.hpp create mode 100644 repertory/librepertory/include/events/types/warn_log.hpp create mode 100644 repertory/librepertory/src/comm/curl/curl_shared.cpp create mode 100644 repertory/repertory/include/cli/common.hpp create mode 100644 repertory/repertory/include/cli/test.hpp delete mode 100644 support/3rd_party/boost_1_87_0.tar.gz delete mode 100644 support/3rd_party/boost_1_87_0.tar.gz.sha256 create mode 100644 support/3rd_party/boost_1_88_0.tar.gz create mode 100644 support/3rd_party/boost_1_88_0.tar.gz.sha256 delete mode 100644 support/3rd_party/cpp-httplib-0.19.0.tar.gz delete mode 100644 support/3rd_party/cpp-httplib-0.19.0.tar.gz.sha256 create mode 100644 support/3rd_party/cpp-httplib-0.23.1.tar.gz create mode 100644 support/3rd_party/cpp-httplib-0.23.1.tar.gz.sha256 delete mode 100644 support/3rd_party/curl-8.12.1.tar.gz delete mode 100644 support/3rd_party/curl-8.12.1.tar.gz.sha256 create mode 100644 support/3rd_party/curl-8.15.0.tar.gz create mode 100644 support/3rd_party/curl-8.15.0.tar.gz.sha256 delete mode 100644 support/3rd_party/googletest-1.15.2.tar.gz delete mode 100644 support/3rd_party/googletest-1.15.2.tar.gz.sha256 delete mode 100644 support/3rd_party/googletest-1.16.0.tar.gz delete mode 100644 support/3rd_party/googletest-1.16.0.tar.gz.sha256 create mode 100644 support/3rd_party/googletest-1.17.0.tar.gz create mode 100644 support/3rd_party/googletest-1.17.0.tar.gz.sha256 delete mode 100644 support/3rd_party/json-3.11.3.tar.gz delete mode 100644 support/3rd_party/json-3.11.3.tar.gz.sha256 create mode 100644 support/3rd_party/json-3.12.0.tar.gz create mode 100644 support/3rd_party/json-3.12.0.tar.gz.sha256 delete mode 100644 support/3rd_party/mingw64/binutils-2.43.tar.xz delete mode 100644 support/3rd_party/mingw64/binutils-2.43.tar.xz.sha256 create mode 100644 support/3rd_party/mingw64/binutils-2.44.tar.xz create mode 100644 support/3rd_party/mingw64/binutils-2.44.tar.xz.sha256 delete mode 100644 support/3rd_party/mingw64/expat-2.6.4.tar.gz delete mode 100644 support/3rd_party/mingw64/expat-2.6.4.tar.gz.sha256 create mode 100644 support/3rd_party/mingw64/expat-2.7.1.tar.gz create mode 100644 support/3rd_party/mingw64/expat-2.7.1.tar.gz.sha256 delete mode 100644 support/3rd_party/mingw64/gcc-14.2.0.tar.gz delete mode 100644 support/3rd_party/mingw64/gcc-14.2.0.tar.gz.sha256 create mode 100644 support/3rd_party/mingw64/gcc-15.1.0.tar.gz create mode 100644 support/3rd_party/mingw64/gcc-15.1.0.tar.gz.sha256 delete mode 100644 support/3rd_party/mingw64/mingw-w64-v12.0.0.tar.bz2.sha256 rename support/3rd_party/mingw64/{mingw-w64-v12.0.0.tar.bz2 => mingw-w64-v13.0.0.tar.bz2} (55%) create mode 100644 support/3rd_party/mingw64/mingw-w64-v13.0.0.tar.bz2.sha256 delete mode 100644 support/3rd_party/openssl-3.4.1.tar.gz delete mode 100644 support/3rd_party/openssl-3.4.1.tar.gz.sha256 create mode 100644 support/3rd_party/openssl-3.5.1.tar.gz create mode 100644 support/3rd_party/openssl-3.5.1.tar.gz.sha256 create mode 100644 support/3rd_party/rocksdb-10.4.2.tar.gz create mode 100644 support/3rd_party/rocksdb-10.4.2.tar.gz.sha256 delete mode 100644 support/3rd_party/rocksdb-9.10.0.tar.gz delete mode 100644 support/3rd_party/rocksdb-9.10.0.tar.gz.sha256 delete mode 100644 support/3rd_party/spdlog-1.15.1.tar.gz delete mode 100644 support/3rd_party/spdlog-1.15.1.tar.gz.sha256 create mode 100644 support/3rd_party/spdlog-1.15.3.tar.gz create mode 100644 support/3rd_party/spdlog-1.15.3.tar.gz.sha256 delete mode 100644 support/3rd_party/sqlite-amalgamation-3490100.zip delete mode 100644 support/3rd_party/sqlite-amalgamation-3490100.zip.sha256 create mode 100644 support/3rd_party/sqlite-amalgamation-3500300.zip create mode 100644 support/3rd_party/sqlite-amalgamation-3500300.zip.sha256 delete mode 100644 support/3rd_party/winfsp-2.0/bin/memfs-a64.exe delete mode 100644 support/3rd_party/winfsp-2.0/bin/memfs-x64.exe delete mode 100644 support/3rd_party/winfsp-2.0/bin/memfs-x86.exe delete mode 100644 support/3rd_party/winfsp-2.0/bin/winfsp-a64.dll delete mode 100644 support/3rd_party/winfsp-2.0/bin/winfsp-x64.dll delete mode 100644 support/3rd_party/winfsp-2.0/bin/winfsp-x64.sys delete mode 100644 support/3rd_party/winfsp-2.0/bin/winfsp-x86.dll delete mode 100644 support/3rd_party/winfsp-2.0/inc/winfsp/fsctl.h delete mode 100644 support/3rd_party/winfsp-2.0/lib/winfsp-a64.lib delete mode 100644 support/3rd_party/winfsp-2.0/lib/winfsp-x64.lib delete mode 100644 support/3rd_party/winfsp-2.0/lib/winfsp-x86.lib rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/License.txt (98%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/diag.bat (95%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/fsptool-a64.exe (72%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/fsptool-x64.exe (72%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/fsptool-x86.exe (70%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/fsreg.bat (95%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/launchctl-a64.exe (69%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/launchctl-x64.exe (66%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/launchctl-x86.exe (67%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/launcher-a64.exe (79%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/launcher-x64.exe (81%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/launcher-x86.exe (76%) create mode 100644 support/3rd_party/winfsp-2.1/bin/memfs-a64.exe rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/memfs-dotnet-msil.exe (88%) create mode 100644 support/3rd_party/winfsp-2.1/bin/memfs-x64.exe create mode 100644 support/3rd_party/winfsp-2.1/bin/memfs-x86.exe create mode 100644 support/3rd_party/winfsp-2.1/bin/winfsp-a64.dll rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/winfsp-a64.sys (61%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/winfsp-msil.dll (97%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/winfsp-msil.xml (97%) create mode 100644 support/3rd_party/winfsp-2.1/bin/winfsp-x64.dll create mode 100644 support/3rd_party/winfsp-2.1/bin/winfsp-x64.sys create mode 100644 support/3rd_party/winfsp-2.1/bin/winfsp-x86.dll rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/bin/winfsp-x86.sys (53%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/fuse/fuse.h (96%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/fuse/fuse_common.h (96%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/fuse/fuse_opt.h (95%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/fuse/winfsp_fuse.h (95%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/fuse3/fuse.h (96%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/fuse3/fuse_common.h (95%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/fuse3/fuse_opt.h (91%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/fuse3/winfsp_fuse.h (96%) create mode 100644 support/3rd_party/winfsp-2.1/inc/winfsp/fsctl.h rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/winfsp/launch.h (97%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/winfsp/winfsp.h (97%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/inc/winfsp/winfsp.hpp (97%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/lib/fuse.pc (95%) rename support/3rd_party/{winfsp-2.0 => winfsp-2.1}/lib/fuse3.pc (95%) create mode 100644 support/3rd_party/winfsp-2.1/lib/winfsp-a64.lib create mode 100644 support/3rd_party/winfsp-2.1/lib/winfsp-x64.lib create mode 100644 support/3rd_party/winfsp-2.1/lib/winfsp-x86.lib create mode 100644 support/src/utils/directory.cpp diff --git a/.cspell/words.txt b/.cspell/words.txt index 1da8f974..40be5f7a 100644 --- a/.cspell/words.txt +++ b/.cspell/words.txt @@ -17,6 +17,7 @@ bugprone cflags chrono cmake_current_source_dir +coinit_apartmentthreaded comdlg32 cppcoreguidelines cppdbg @@ -27,6 +28,7 @@ cppvsdbg create_notraverse crypto_aead_xchacha20poly1305_ietf_npubbytes cstdint +curle_couldnt_resolve_host curlopt_aws_sigv4 cxxflags cxxstd @@ -199,6 +201,7 @@ secp256k1 secur32 sfml_project shlwapi +sigchld skynet source_subdir spdlog diff --git a/.vimspector.json b/.vimspector.json deleted file mode 100644 index c0cc9e1c..00000000 --- a/.vimspector.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "configurations": { - "UnixDebug": { - "adapter": "vscode-cpptools", - "configuration": { - "request": "launch", - "program": "${workspaceRoot}/build/debug/repertory", - "args": ["-f", "/home/sgraves/mnt"], - "cwd": "${workspaceRoot}/build/debug", - "environment": [], - "externalConsole": true, - "MIMode": "gdb", - "stopAtEntry": true, - "logging": { - "engineLogging": false - } - } - }, - "UnixDebugTest": { - "adapter": "vscode-cpptools", - "configuration": { - "request": "launch", - "program": "${workspaceRoot}/build/debug/unittests", - "args": ["--gtest_filter=file_manager.can_close_after_download_timeout"], - "cwd": "${workspaceRoot}/build", - "environment": [], - "externalConsole": true, - "MIMode": "gdb", - "stopAtEntry": true, - "logging": { - "engineLogging": false - } - } - } - } -} diff --git a/CHANGELOG.md b/CHANGELOG.md index 19db631f..d3674096 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,30 @@ # Changelog +## v2.0.6-release + +### Issues +* \#42 [bug] Remote mount directory listing on Windows connected to Linux is failing +* \#43 [bug] Directories are not importing properly for Sia +* \#44 [bug] Windows-to-Linux remote mount ignores `CREATE_NEW` +* \#45 [bug] Windows-to-Linux remote mount is not handling attempts to remove a non-empty directory properly +* \#46 [bug] Changes to maximum cache size should be updated live +* \#47 [bug] Windows-to-Linux remote mount is allowing directory rename when directory is not empty +* \#48 [bug] Windows-to-Linux remote mount overlapped I/O is not detecting EOF for read operations +* \#49 [ui] Implement provider test button + +### Changes from v2.0.5-rc + +* Added request retry on `libcurl` error code `CURLE_COULDNT_RESOLVE_HOST` +* Added `libcurl` DNS caching +* Drive letters in UI should always be lowercase +* Fixed WinFSP directory rename for non-empty directories +* Fixed segfault in UI due to incorrect `SIGCHLD` handling +* Migrated to v2 error handling +* Upgraded WinFSP to v2.1 (2025) + ## v2.0.5-rc + ### Issues * \#39 Create management portal in Flutter @@ -69,6 +92,7 @@ ## v2.0.2-rc + ### BREAKING CHANGES * Refactored `config.json` - will need to verify configuration settings prior to mounting diff --git a/README.md b/README.md index fafe53d7..e4ccd0ee 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ on Windows. * [Sia renterd](https://github.com/SiaFoundation/renterd/releases) v2.0.0+ for Sia support * Linux requires `fusermount3`; otherwise, `repertory` must be manually compiled with `libfuse2` support * Windows requires the following dependencies to be installed: - * [WinFSP 2023](https://github.com/winfsp/winfsp/releases/download/v2.0/winfsp-2.0.23075.msi) + * [WinFSP 2025](https://github.com/winfsp/winfsp/releases/download/v2.1/winfsp-2.1.25156.msi) ### Supported Operating Systems diff --git a/cmake/hashes.cmake b/cmake/hashes.cmake index 942952c9..1941d048 100644 --- a/cmake/hashes.cmake +++ b/cmake/hashes.cmake @@ -1,20 +1,20 @@ -set(BINUTILS_HASH b53606f443ac8f01d1d5fc9c39497f2af322d99e14cea5c0b4b124d630379365) +set(BINUTILS_HASH ce2017e059d63e67ddb9240e9d4ec49c2893605035cd60e92ad53177f4377237) set(BOOST2_HASH 7bd7ddceec1a1dfdcbdb3e609b60d01739c38390a5f956385a12f3122049f0ca) -set(BOOST_HASH f55c340aa49763b1925ccf02b2e83f35fdcf634c9d5164a2acb87540173c741d) -set(CPP_HTTPLIB_HASH c9b9e0524666e1cd088f0874c57c1ce7c0eaa8552f9f4e15c755d5201fc8c608) -set(CURL_HASH 6edc063d1ebaf9cf3b3b46e9fef2f3cd8932694989ecd43d005d6e828426d09f) -set(EXPAT_HASH 372b18f6527d162fa9658f1c74d22a37429b82d822f5a1e1fc7e00f6045a06a2) -set(GCC_HASH 7d376d445f93126dc545e2c0086d0f647c3094aae081cdb78f42ce2bc25e7293) -set(GTEST_HASH 78c676fc63881529bf97bf9d45948d905a66833fbfa5318ea2cd7478cb98f399) +set(BOOST_HASH 3621533e820dcab1e8012afd583c0c73cf0f77694952b81352bf38c1488f9cb4) +set(CPP_HTTPLIB_HASH 410a1347ed6bcbcc4a19af8ed8ad3873fe9fa97731d52db845c4c78f3f9c31e6) +set(CURL_HASH 2937cadde007aa3a52a17c21ac9153ea054700f37926d1d96602bf07e888c847) +set(EXPAT_HASH 85372797ff0673a8fc4a6be16466bb5a0ca28c0dcf3c6f7ac1686b4a3ba2aabb) +set(GCC_HASH 51b9919ea69c980d7a381db95d4be27edf73b21254eb13d752a08003b4d013b1) +set(GTEST_HASH 65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c) set(ICU_HASH a2c443404f00098e9e90acf29dc318e049d2dc78d9ae5f46efb261934a730ce2) -set(JSON_HASH 0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406) +set(JSON_HASH 4b92eb0c06d10683f7447ce9406cb97cd4b453be18d7279320f7b2f025c10187) set(LIBSODIUM_HASH 8e5aeca07a723a27bbecc3beef14b0068d37e7fc0e97f51b3f1c82d2a58005c1) -set(MINGW_HASH cc41898aac4b6e8dd5cffd7331b9d9515b912df4420a3a612b5ea2955bbeed2f) -set(OPENSSL_HASH 002a2d6b30b58bf4bea46c43bdd96365aaf8daa6c428782aa4feee06da197df3) +set(MINGW_HASH 5afe822af5c4edbf67daaf45eec61d538f49eef6b19524de64897c6b95828caf) +set(OPENSSL_HASH 529043b15cffa5f36077a4d0af83f3de399807181d607441d734196d889b641f) set(PKG_CONFIG_HASH 6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591) set(PUGIXML_HASH 655ade57fa703fb421c2eb9a0113b5064bddb145d415dd1f88c79353d90d511a) -set(ROCKSDB_HASH fdccab16133c9d927a183c2648bcea8d956fb41eb1df2aacaa73eb0b95e43724) -set(SPDLOG_HASH 25c843860f039a1600f232c6eb9e01e6627f7d030a2ae5e232bdd3c9205d26cc) -set(SQLITE_HASH 6cebd1d8403fc58c30e93939b246f3e6e58d0765a5cd50546f16c00fd805d2c3) +set(ROCKSDB_HASH afccfab496556904900afacf7d99887f1d50cb893e5d2288bd502db233adacac) +set(SPDLOG_HASH 15a04e69c222eb6c01094b5c7ff8a249b36bb22788d72519646fb85feb267e67) +set(SQLITE_HASH 9ad6d16cbc1df7cd55c8b55127c82a9bca5e9f287818de6dc87e04e73599d754) set(STDUUID_HASH b1176597e789531c38481acbbed2a6894ad419aab0979c10410d59eb0ebf40d3) set(ZLIB_HASH 17e88863f3600672ab49182f217281b6fc4d3c762bde361935e436a95214d05c) diff --git a/cmake/libraries/winfsp.cmake b/cmake/libraries/winfsp.cmake index 5b7b4586..9fd0900a 100644 --- a/cmake/libraries/winfsp.cmake +++ b/cmake/libraries/winfsp.cmake @@ -2,9 +2,9 @@ if(PROJECT_ENABLE_WINFSP AND PROJECT_IS_MINGW) if(PROJECT_BUILD) add_definitions(-DPROJECT_ENABLE_WINFSP) - include_directories(BEFORE SYSTEM ${PROJECT_3RD_PARTY_DIR}/winfsp-2.0/inc) + include_directories(BEFORE SYSTEM ${PROJECT_3RD_PARTY_DIR}/winfsp-2.1/inc) - link_directories(BEFORE ${PROJECT_3RD_PARTY_DIR}/winfsp-2.0/lib) + link_directories(BEFORE ${PROJECT_3RD_PARTY_DIR}/winfsp-2.1/lib) if(PROJECT_IS_ARM64) link_libraries(winfsp-a64) diff --git a/cmake/versions.cmake b/cmake/versions.cmake index 147a990d..0bd00b33 100644 --- a/cmake/versions.cmake +++ b/cmake/versions.cmake @@ -1,28 +1,27 @@ -set(BINUTILS_VERSION 2.43) +set(BINUTILS_VERSION 2.44) set(BOOST2_MAJOR_VERSION 1) set(BOOST2_MINOR_VERSION 76) set(BOOST2_PATCH_VERSION 0) set(BOOST_MAJOR_VERSION 1) -set(BOOST_MINOR_VERSION 87) +set(BOOST_MINOR_VERSION 88) set(BOOST_PATCH_VERSION 0) -set(CPP_HTTPLIB_VERSION 0.19.0) -set(CURL2_VERSION 8_12_1) -set(CURL_VERSION 8.12.1) -set(EXPAT2_VERSION 2_6_4) -set(EXPAT_VERSION 2.6.4) -set(GCC_VERSION 14.2.0) -set(GTEST_VERSION 1.16.0) +set(CPP_HTTPLIB_VERSION 0.23.1) +set(CURL2_VERSION 8_15_0) +set(CURL_VERSION 8.15.0) +set(EXPAT2_VERSION 2_7_1) +set(EXPAT_VERSION 2.7.1) +set(GCC_VERSION 15.1.0) +set(GTEST_VERSION 1.17.0) set(ICU_VERSION 76-1) -set(JSON_VERSION 3.11.3) +set(JSON_VERSION 3.12.0) set(LIBSODIUM_VERSION 1.0.20) -set(MESA_VERSION 23.3.3) -set(MINGW_VERSION 12.0.0) -set(OPENSSL_VERSION 3.4.1) +set(MINGW_VERSION 13.0.0) +set(OPENSSL_VERSION 3.5.1) set(PKG_CONFIG_VERSION 0.29.2) set(PUGIXML_VERSION 1.15) -set(ROCKSDB_VERSION 9.10.0) -set(SPDLOG_VERSION 1.15.1) -set(SQLITE2_VERSION 3.49.1) -set(SQLITE_VERSION 3490100) +set(ROCKSDB_VERSION 10.4.2) +set(SPDLOG_VERSION 1.15.3) +set(SQLITE2_VERSION 3.50.3) +set(SQLITE_VERSION 3500300) set(STDUUID_VERSION 1.2.3) set(ZLIB_VERSION 1.3.1) diff --git a/config.sh b/config.sh index 7e647523..da28760a 100755 --- a/config.sh +++ b/config.sh @@ -10,9 +10,9 @@ PROJECT_DESC="Mount utility for Sia and S3" PROJECT_MAJOR_VERSION=2 PROJECT_MINOR_VERSION=0 -PROJECT_REVISION_VERSION=5 -PROJECT_RELEASE_NUM=0 -PROJECT_RELEASE_ITER=rc +PROJECT_REVISION_VERSION=6 +PROJECT_RELEASE_NUM=1 +PROJECT_RELEASE_ITER=release PROJECT_APP_LIST=(${PROJECT_NAME}) @@ -21,6 +21,7 @@ PROJECT_PUBLIC_KEY=${DEVELOPER_PUBLIC_KEY} PROJECT_FLUTTER_BASE_HREF="/ui/" +PROJECT_ENABLE_V2_ERRORS=ON PROJECT_ENABLE_WIN32_LONG_PATH_NAMES=OFF PROJECT_ENABLE_BACKWARD_CPP=OFF diff --git a/docker/aarch64/alpine b/docker/aarch64/alpine index b6f62e92..dfac5959 100644 --- a/docker/aarch64/alpine +++ b/docker/aarch64/alpine @@ -1,5 +1,5 @@ #comment -FROM arm64v8/alpine:3.21.3 +FROM arm64v8/alpine:3.21.4 MAINTAINER Scott E. Graves CMD bash diff --git a/docker/x86_64/alpine b/docker/x86_64/alpine index ad24210e..2d7026cb 100644 --- a/docker/x86_64/alpine +++ b/docker/x86_64/alpine @@ -1,5 +1,5 @@ #comment -FROM alpine:3.21.3 +FROM alpine:3.21.4 MAINTAINER Scott E. Graves CMD bash diff --git a/docker/x86_64/mingw64 b/docker/x86_64/mingw64 index 8bbe85ec..bf93e5ca 100644 --- a/docker/x86_64/mingw64 +++ b/docker/x86_64/mingw64 @@ -1,5 +1,5 @@ #comment -FROM alpine:3.21.3 +FROM alpine:3.21.4 RUN apk update RUN apk upgrade @@ -351,9 +351,9 @@ RUN cd /3rd_party/mingw64 && sha256sum -c ./expat-${MY_EXPAT_VERSION}.tar.gz.sha ARG FONTCONFIG_VERSION ENV MY_FONTCONFIG_VERSION=${FONTCONFIG_VERSION} -RUN if [ -f "/3rd_party/fontconfig-${MY_FONTCONFIG_VERSION}.tar.gz" ]; then \ - cd /3rd_party && sha256sum -c ./fontconfig-${MY_FONTCONFIG_VERSION}.tar.gz.sha256 && cd - \ - && tar xvzf /3rd_party/fontconfig-${MY_FONTCONFIG_VERSION}.tar.gz \ +RUN if [ -f "/3rd_party/fontconfig-${MY_FONTCONFIG_VERSION}.tar.xz" ]; then \ + cd /3rd_party && sha256sum -c ./fontconfig-${MY_FONTCONFIG_VERSION}.tar.xz.sha256 && cd - \ + && tar xvJf /3rd_party/fontconfig-${MY_FONTCONFIG_VERSION}.tar.xz \ && cd fontconfig-${MY_FONTCONFIG_VERSION} \ && meson setup \ --cross-file ${MY_TOOLCHAIN_FILE_MESON} \ diff --git a/repertory/librepertory/include/comm/curl/curl_comm.hpp b/repertory/librepertory/include/comm/curl/curl_comm.hpp index f4e1eb41..064792f5 100644 --- a/repertory/librepertory/include/comm/curl/curl_comm.hpp +++ b/repertory/librepertory/include/comm/curl/curl_comm.hpp @@ -23,6 +23,7 @@ #define REPERTORY_INCLUDE_COMM_CURL_CURL_COMM_HPP_ #include "app_config.hpp" +#include "comm/curl/curl_shared.hpp" #include "comm/curl/multi_request.hpp" #include "comm/i_http_comm.hpp" #include "events/event_system.hpp" @@ -48,14 +49,12 @@ private: static const write_callback write_data; static const write_callback write_headers; + static constexpr std::uint8_t retry_request_count{5U}; private: std::optional host_config_; std::optional s3_config_; -private: - bool use_s3_path_style_{false}; - public: [[nodiscard]] static auto create_curl() -> CURL *; @@ -67,8 +66,7 @@ public: const host_config &cfg) -> std::string; - [[nodiscard]] static auto create_host_config(const s3_config &cfg, - bool use_s3_path_style) + [[nodiscard]] static auto create_host_config(const s3_config &cfg) -> host_config; [[nodiscard]] static auto url_encode(CURL *curl, const std::string &data, @@ -139,107 +137,128 @@ public: long &response_code, stop_type &stop_requested) -> bool { REPERTORY_USES_FUNCTION_NAME(); - if (request.decryption_token.has_value() && - not request.decryption_token.value().empty()) { - return make_encrypted_request(cfg, request, response_code, - stop_requested); - } - - response_code = 0; - - auto *curl = create_curl(); - if (not request.set_method(curl, stop_requested)) { - return false; - } - - if (not cfg.agent_string.empty()) { - curl_easy_setopt(curl, CURLOPT_USERAGENT, cfg.agent_string.c_str()); - } - - if (request.allow_timeout && cfg.timeout_ms) { - curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, cfg.timeout_ms); - } - - std::string range_list{}; - if (request.range.has_value()) { - range_list = std::to_string(request.range.value().begin) + '-' + - std::to_string(request.range.value().end); - curl_easy_setopt(curl, CURLOPT_RANGE, range_list.c_str()); - } - - if (request.response_headers.has_value()) { - curl_easy_setopt(curl, CURLOPT_HEADERDATA, - &request.response_headers.value()); - curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_headers); - } - - read_write_info write_info{ - {}, - [&stop_requested]() -> bool { - return stop_requested || app_config::get_stop_requested(); - }, - }; - if (request.response_handler.has_value()) { - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_info); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); - } - - std::string parameters{}; - for (const auto ¶m : request.query) { - parameters += (parameters.empty() ? '?' : '&') + param.first + '=' + - url_encode(curl, param.second, false); - } - - if (not cfg.api_password.empty()) { - curl_easy_setopt(curl, CURLOPT_USERNAME, cfg.api_user.c_str()); - curl_easy_setopt(curl, CURLOPT_PASSWORD, cfg.api_password.c_str()); - } else if (not cfg.api_user.empty()) { - curl_easy_setopt(curl, CURLOPT_USERNAME, cfg.api_user.c_str()); - } - - if (request.aws_service.has_value()) { - curl_easy_setopt(curl, CURLOPT_AWS_SIGV4, - request.aws_service.value().c_str()); - } - - curl_slist *header_list{nullptr}; - if (not request.headers.empty()) { - for (const auto &header : request.headers) { - header_list = curl_slist_append( - header_list, - fmt::format("{}: {}", header.first, header.second).c_str()); - } - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list); - } - - auto url = construct_url(curl, request.get_path(), cfg) + parameters; - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - - multi_request curl_request(curl, stop_requested); - CURLcode curl_code{}; - curl_request.get_result(curl_code, response_code); + const auto do_request = [&]() -> bool { + if (request.decryption_token.has_value() && + not request.decryption_token.value().empty()) { + return make_encrypted_request(cfg, request, response_code, + stop_requested); + } - if (header_list != nullptr) { - curl_slist_free_all(header_list); + response_code = 0; + + auto *curl = create_curl(); + if (not request.set_method(curl, stop_requested)) { + return false; + } + + if (not cfg.agent_string.empty()) { + curl_easy_setopt(curl, CURLOPT_USERAGENT, cfg.agent_string.c_str()); + } + + if (request.allow_timeout && cfg.timeout_ms) { + curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, cfg.timeout_ms); + } + + std::string range_list{}; + if (request.range.has_value()) { + range_list = std::to_string(request.range.value().begin) + '-' + + std::to_string(request.range.value().end); + curl_easy_setopt(curl, CURLOPT_RANGE, range_list.c_str()); + } + + if (request.response_headers.has_value()) { + curl_easy_setopt(curl, CURLOPT_HEADERDATA, + &request.response_headers.value()); + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_headers); + } + + read_write_info write_info{ + {}, + [&stop_requested]() -> bool { + return stop_requested || app_config::get_stop_requested(); + }, + }; + if (request.response_handler.has_value()) { + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_info); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); + } + + std::string parameters{}; + for (const auto ¶m : request.query) { + parameters += (parameters.empty() ? '?' : '&') + param.first + '=' + + url_encode(curl, param.second, false); + } + + if (not cfg.api_password.empty()) { + curl_easy_setopt(curl, CURLOPT_USERNAME, cfg.api_user.c_str()); + curl_easy_setopt(curl, CURLOPT_PASSWORD, cfg.api_password.c_str()); + } else if (not cfg.api_user.empty()) { + curl_easy_setopt(curl, CURLOPT_USERNAME, cfg.api_user.c_str()); + } + + if (request.aws_service.has_value()) { + curl_easy_setopt(curl, CURLOPT_AWS_SIGV4, + request.aws_service.value().c_str()); + } + + curl_slist *header_list{nullptr}; + if (not request.headers.empty()) { + for (const auto &header : request.headers) { + header_list = curl_slist_append( + header_list, + fmt::format("{}: {}", header.first, header.second).c_str()); + } + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list); + } + + curl_shared::set_share(curl); + + auto url = construct_url(curl, request.get_path(), cfg) + parameters; + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + + multi_request curl_request(curl, stop_requested); + + curl_code = CURLE_OK; + curl_request.get_result(curl_code, response_code); + + if (header_list != nullptr) { + curl_slist_free_all(header_list); + } + + if (curl_code != CURLE_OK) { + event_system::instance().raise(curl_code, function_name, + request.get_type(), url); + return false; + } + + if (request.response_handler.has_value()) { + request.response_handler.value()(write_info.data, response_code); + } + + return true; + }; + + bool ret{false}; + for (std::uint8_t retry = 0U; !ret && retry < retry_request_count; + ++retry) { + ret = do_request(); + if (ret) { + break; + } + + if (curl_code == CURLE_COULDNT_RESOLVE_HOST) { + std::this_thread::sleep_for(1s); + continue; + } + + break; } - if (curl_code != CURLE_OK) { - event_system::instance().raise(curl_code, function_name, - url); - return false; - } - - if (request.response_handler.has_value()) { - request.response_handler.value()(write_info.data, response_code); - } - - return true; + return ret; } public: - void enable_s3_path_style(bool enable) override; - [[nodiscard]] auto make_request(const curl::requests::http_delete &del, long &response_code, stop_type &stop_requested) const diff --git a/repertory/librepertory/include/comm/curl/curl_shared.hpp b/repertory/librepertory/include/comm/curl/curl_shared.hpp new file mode 100644 index 00000000..d214d63c --- /dev/null +++ b/repertory/librepertory/include/comm/curl/curl_shared.hpp @@ -0,0 +1,67 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_COMM_CURL_CURL_SHARED_HPP_ +#define REPERTORY_INCLUDE_COMM_CURL_CURL_SHARED_HPP_ + +namespace repertory { +class curl_shared final { +private: + struct curl_sh_deleter final { + void operator()(CURLSH *ptr) { + if (ptr != nullptr) { + curl_share_cleanup(ptr); + } + } + }; + + using curl_sh_t = std::unique_ptr; + +public: + curl_shared() = delete; + curl_shared(const curl_shared &) = delete; + curl_shared(curl_shared &&) = delete; + ~curl_shared() = delete; + + auto operator=(const curl_shared &) -> curl_shared & = delete; + auto operator=(curl_shared &&) -> curl_shared & = delete; + +private: + static curl_sh_t cache_; + static std::recursive_mutex mtx_; + +private: + static void lock_callback(CURL * /* curl */, curl_lock_data /* data */, + curl_lock_access /* access */, void * /* ptr */); + + static void unlock_callback(CURL * /* curl */, curl_lock_data /* data */, + curl_lock_access /* access */, void * /* ptr */); + +public: + static void cleanup(); + + [[nodiscard]] static auto init() -> bool; + + static void set_share(CURL *curl); +}; +} // namespace repertory + +#endif // REPERTORY_INCLUDE_COMM_CURL_DNS_CACHE_HPP_ diff --git a/repertory/librepertory/include/comm/curl/requests/http_delete.hpp b/repertory/librepertory/include/comm/curl/requests/http_delete.hpp index 41d6a94c..e8be7ce3 100644 --- a/repertory/librepertory/include/comm/curl/requests/http_delete.hpp +++ b/repertory/librepertory/include/comm/curl/requests/http_delete.hpp @@ -26,11 +26,13 @@ namespace repertory::curl::requests { struct http_delete final : http_request_base { - ~http_delete() override = default; + [[nodiscard]] auto get_type() const -> std::string override { + return "delete"; + } - [[nodiscard]] auto - set_method(CURL *curl, - stop_type & /* stop_requested */) const -> bool override { + [[nodiscard]] auto set_method(CURL *curl, + stop_type & /* stop_requested */) const + -> bool override { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE"); return true; } diff --git a/repertory/librepertory/include/comm/curl/requests/http_get.hpp b/repertory/librepertory/include/comm/curl/requests/http_get.hpp index e1f02326..92c3b55b 100644 --- a/repertory/librepertory/include/comm/curl/requests/http_get.hpp +++ b/repertory/librepertory/include/comm/curl/requests/http_get.hpp @@ -33,9 +33,11 @@ struct http_get final : http_request_base { auto operator=(http_get &&) -> http_get & = default; ~http_get() override = default; - [[nodiscard]] auto - set_method(CURL *curl, - stop_type & /*stop_requested*/) const -> bool override { + [[nodiscard]] auto get_type() const -> std::string override { return "get"; } + + [[nodiscard]] auto set_method(CURL *curl, + stop_type & /*stop_requested*/) const + -> bool override { curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); return true; } diff --git a/repertory/librepertory/include/comm/curl/requests/http_head.hpp b/repertory/librepertory/include/comm/curl/requests/http_head.hpp index 341bed8f..26b37347 100644 --- a/repertory/librepertory/include/comm/curl/requests/http_head.hpp +++ b/repertory/librepertory/include/comm/curl/requests/http_head.hpp @@ -26,11 +26,11 @@ namespace repertory::curl::requests { struct http_head final : http_request_base { - ~http_head() override = default; + [[nodiscard]] auto get_type() const -> std::string override { return "head"; } - [[nodiscard]] auto - set_method(CURL *curl, - stop_type & /* stop_requested */) const -> bool override { + [[nodiscard]] auto set_method(CURL *curl, + stop_type & /* stop_requested */) const + -> bool override { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "HEAD"); curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); return true; diff --git a/repertory/librepertory/include/comm/curl/requests/http_post.hpp b/repertory/librepertory/include/comm/curl/requests/http_post.hpp index c5425e12..d465d0ef 100644 --- a/repertory/librepertory/include/comm/curl/requests/http_post.hpp +++ b/repertory/librepertory/include/comm/curl/requests/http_post.hpp @@ -26,16 +26,10 @@ namespace repertory::curl::requests { struct http_post final : http_request_base { - http_post() = default; - http_post(const http_post &) = default; - http_post(http_post &&) = default; - auto operator=(const http_post &) -> http_post & = default; - auto operator=(http_post &&) -> http_post & = default; - - ~http_post() override = default; - std::optional json; + [[nodiscard]] auto get_type() const -> std::string override { return "post"; } + [[nodiscard]] auto set_method(CURL *curl, stop_type & /*stop_requested*/) const -> bool override; diff --git a/repertory/librepertory/include/comm/curl/requests/http_put_file.hpp b/repertory/librepertory/include/comm/curl/requests/http_put_file.hpp index 8841adc4..3310210b 100644 --- a/repertory/librepertory/include/comm/curl/requests/http_put_file.hpp +++ b/repertory/librepertory/include/comm/curl/requests/http_put_file.hpp @@ -27,18 +27,11 @@ namespace repertory::curl::requests { struct http_put_file final : http_request_base { - http_put_file() = default; - http_put_file(const http_put_file &) = default; - http_put_file(http_put_file &&) = default; - - auto operator=(const http_put_file &) -> http_put_file & = default; - auto operator=(http_put_file &&) -> http_put_file & = default; - - ~http_put_file() override = default; - std::shared_ptr reader; std::string source_path; + [[nodiscard]] auto get_type() const -> std::string override { return "put"; } + [[nodiscard]] auto set_method(CURL *curl, stop_type &stop_requested) const -> bool override; diff --git a/repertory/librepertory/include/comm/curl/requests/http_request_base.hpp b/repertory/librepertory/include/comm/curl/requests/http_request_base.hpp index a99d88da..0246dbc4 100644 --- a/repertory/librepertory/include/comm/curl/requests/http_request_base.hpp +++ b/repertory/librepertory/include/comm/curl/requests/http_request_base.hpp @@ -61,6 +61,8 @@ struct http_request_base { [[nodiscard]] virtual auto get_path() const -> std::string { return path; } + [[nodiscard]] virtual auto get_type() const -> std::string = 0; + [[nodiscard]] virtual auto set_method(CURL *curl, stop_type &stop_requested) const -> bool = 0; diff --git a/repertory/librepertory/include/comm/i_http_comm.hpp b/repertory/librepertory/include/comm/i_http_comm.hpp index e4373b76..79e774c0 100644 --- a/repertory/librepertory/include/comm/i_http_comm.hpp +++ b/repertory/librepertory/include/comm/i_http_comm.hpp @@ -34,28 +34,29 @@ struct i_http_comm { INTERFACE_SETUP(i_http_comm); public: - virtual void enable_s3_path_style(bool enable) = 0; - [[nodiscard]] virtual auto make_request(const curl::requests::http_delete &del, long &response_code, stop_type &stop_requested) const -> bool = 0; - [[nodiscard]] virtual auto - make_request(const curl::requests::http_get &get, long &response_code, - stop_type &stop_requested) const -> bool = 0; + [[nodiscard]] virtual auto make_request(const curl::requests::http_get &get, + long &response_code, + stop_type &stop_requested) const + -> bool = 0; - [[nodiscard]] virtual auto - make_request(const curl::requests::http_head &head, long &response_code, - stop_type &stop_requested) const -> bool = 0; + [[nodiscard]] virtual auto make_request(const curl::requests::http_head &head, + long &response_code, + stop_type &stop_requested) const + -> bool = 0; - [[nodiscard]] virtual auto - make_request(const curl::requests::http_post &post, long &response_code, - stop_type &stop_requested) const -> bool = 0; + [[nodiscard]] virtual auto make_request(const curl::requests::http_post &post, + long &response_code, + stop_type &stop_requested) const + -> bool = 0; [[nodiscard]] virtual auto make_request(const curl::requests::http_put_file &put_file, - long &response_code, - stop_type &stop_requested) const -> bool = 0; + long &response_code, stop_type &stop_requested) const + -> bool = 0; }; } // namespace repertory diff --git a/repertory/librepertory/include/comm/packet/client_pool.hpp b/repertory/librepertory/include/comm/packet/client_pool.hpp index d4c9795d..9df0ab04 100644 --- a/repertory/librepertory/include/comm/packet/client_pool.hpp +++ b/repertory/librepertory/include/comm/packet/client_pool.hpp @@ -94,7 +94,7 @@ private: bool shutdown_ = false; private: - static constexpr const auto min_pool_size = 10U; + static constexpr auto min_pool_size = 10U; public: void execute(const std::string &client_id, std::uint64_t thread_id, diff --git a/repertory/librepertory/include/common.hpp b/repertory/librepertory/include/common.hpp index 7c92b326..8c7cb131 100644 --- a/repertory/librepertory/include/common.hpp +++ b/repertory/librepertory/include/common.hpp @@ -54,12 +54,13 @@ REPERTORY_IGNORE_WARNINGS_DISABLE() using namespace std::chrono_literals; using json = nlohmann::json; -inline constexpr const std::string_view REPERTORY = "repertory"; -inline constexpr const std::wstring_view REPERTORY_W = L"repertory"; +inline constexpr std::string_view REPERTORY{"repertory"}; +inline constexpr std::string_view REPERTORY_DATA_NAME{"repertory2"}; +inline constexpr std::wstring_view REPERTORY_W{L"repertory"}; -inline constexpr const std::uint64_t REPERTORY_CONFIG_VERSION = 2ULL; -inline constexpr const std::string_view REPERTORY_DATA_NAME = "repertory2"; -inline constexpr const std::string_view REPERTORY_MIN_REMOTE_VERSION = "2.0.0"; +inline constexpr std::uint64_t REPERTORY_CONFIG_VERSION{2ULL}; +inline constexpr std::string_view REPERTORY_MIN_REMOTE_VERSION{"2.0.0"}; +inline constexpr std::string_view RENTERD_MIN_VERSION{"2.0.0"}; #define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE @@ -221,11 +222,11 @@ using WCHAR = wchar_t; #define MAX_PATH 260 -#define STATUS_SUCCESS std::uint32_t{0U} #define STATUS_ACCESS_DENIED std::uint32_t{0xC0000022L} #define STATUS_DEVICE_BUSY std::uint32_t{0x80000011L} #define STATUS_DEVICE_INSUFFICIENT_RESOURCES std::uint32_t{0xC0000468L} #define STATUS_DIRECTORY_NOT_EMPTY std::uint32_t{0xC0000101L} +#define STATUS_END_OF_FILE std::uint32_t{0xC0000011L} #define STATUS_FILE_IS_A_DIRECTORY std::uint32_t{0xC00000BAL} #define STATUS_FILE_TOO_LARGE std::uint32_t{0xC0000904L} #define STATUS_INSUFFICIENT_RESOURCES std::uint32_t{0xC000009AL} @@ -234,11 +235,13 @@ using WCHAR = wchar_t; #define STATUS_INVALID_HANDLE std::uint32_t{0xC0000006L} #define STATUS_INVALID_IMAGE_FORMAT std::uint32_t{0xC000007BL} #define STATUS_INVALID_PARAMETER std::uint32_t{0xC000000DL} -#define STATUS_NO_MEMORY std::uint32_t{0xC0000017L} #define STATUS_NOT_IMPLEMENTED std::uint32_t{0xC0000002L} +#define STATUS_NO_MEMORY std::uint32_t{0xC0000017L} +#define STATUS_OBJECT_NAME_COLLISION std::uint32_t{0xC0000035L} #define STATUS_OBJECT_NAME_EXISTS std::uint32_t{0x40000000L} #define STATUS_OBJECT_NAME_NOT_FOUND std::uint32_t{0xC0000034L} #define STATUS_OBJECT_PATH_INVALID std::uint32_t{0xC0000039L} +#define STATUS_SUCCESS std::uint32_t{0U} #define STATUS_UNEXPECTED_IO_ERROR std::uint32_t{0xC00000E9L} #define CONVERT_STATUS_NOT_IMPLEMENTED(e) \ diff --git a/repertory/librepertory/include/drives/directory_iterator.hpp b/repertory/librepertory/include/drives/directory_iterator.hpp index d535a10e..372ef86c 100644 --- a/repertory/librepertory/include/drives/directory_iterator.hpp +++ b/repertory/librepertory/include/drives/directory_iterator.hpp @@ -50,14 +50,14 @@ public: [[nodiscard]] auto fill_buffer(const remote::file_offset &offset, fuse_fill_dir_t filler_function, void *buffer, populate_stat_callback populate_stat) -> int; -#endif +#endif // !defined(_WIN32) [[nodiscard]] auto get(std::size_t offset, std::string &item) -> int; [[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 284e0b67..bc0147f3 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_base.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_base.hpp @@ -61,7 +61,7 @@ private: static auto instance() -> fuse_base &; private: - struct fuse_operations fuse_ops_ {}; + struct fuse_operations fuse_ops_{}; private: [[nodiscard]] auto @@ -78,9 +78,9 @@ private: static void execute_void_callback(std::string_view function_name, const std::function &cb); - static auto - execute_void_pointer_callback(std::string_view function_name, - const std::function &cb) -> void *; + static auto execute_void_pointer_callback(std::string_view function_name, + const std::function &cb) + -> void *; void raise_fuse_event(std::string_view function_name, std::string_view api_path, int ret, @@ -91,22 +91,22 @@ private: #if defined(__APPLE__) [[nodiscard]] static auto chflags_(const char *path, uint32_t flags) -> int; -#endif // __APPLE__ +#endif // defined(__APPLE__) #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto chmod_(const char *path, mode_t mode, struct fuse_file_info *fi) -> int; -#else +#else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto chmod_(const char *path, mode_t mode) -> int; -#endif +#endif // FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30 [[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; -#endif +#else // FUSE_USE_VERSION < 30 + [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid) + -> int; +#endif // FUSE_USE_VERSION >= 30 [[nodiscard]] static auto create_(const char *path, mode_t mode, struct fuse_file_info *fi) -> int; @@ -114,19 +114,19 @@ 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 +#endif // FUSE_USE_VERSION < 30 #if defined(__APPLE__) [[nodiscard]] static auto fsetattr_x_(const char *path, struct setattr_x *attr, struct fuse_file_info *fi) -> int; -#endif // __APPLE__ +#endif // defined(__APPLE__) [[nodiscard]] static auto fsync_(const char *path, int datasync, struct fuse_file_info *fi) -> int; @@ -137,27 +137,27 @@ private: #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto getattr_(const char *path, struct stat *st, struct fuse_file_info *fi) -> int; -#else +#else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto getattr_(const char *path, struct stat *st) -> int; -#endif +#endif // FUSE_USE_VERSION >= 30 #if defined(__APPLE__) [[nodiscard]] static auto getxtimes_(const char *path, struct timespec *bkuptime, struct timespec *crtime) -> int; -#endif // __APPLE__ +#endif // defined(__APPLE__) #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto init_(struct fuse_conn_info *conn, struct fuse_config *cfg) -> void *; -#else +#else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto init_(struct fuse_conn_info *conn) -> void *; -#endif +#endif // FUSE_USE_VERSION >= 30 [[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; @@ -171,12 +171,12 @@ private: fuse_fill_dir_t fuse_fill_dir, off_t offset, struct fuse_file_info *fi, fuse_readdir_flags flags) -> int; -#else +#else // FUSE_USE_VERSION < 30 [[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; -#endif + off_t offset, struct fuse_file_info *fi) + -> int; +#endif // FUSE_USE_VERSION >= 30 [[nodiscard]] static auto release_(const char *path, struct fuse_file_info *fi) -> int; @@ -187,9 +187,9 @@ private: #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto rename_(const char *from, const char *to, unsigned int flags) -> int; -#else +#else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto rename_(const char *from, const char *to) -> int; -#endif +#endif // FUSE_USE_VERSION >= 30 [[nodiscard]] static auto rmdir_(const char *path) -> int; @@ -199,35 +199,36 @@ private: char *value, size_t size, uint32_t position) -> int; -#else // __APPLE__ +#else // !defined(__APPLE__) [[nodiscard]] static auto getxattr_(const char *path, const char *name, char *value, size_t size) -> int; -#endif // __APPLE__ +#endif // defined(__APPLE__) [[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; #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__ +#else // !defined(__APPLE__) [[nodiscard]] static auto setxattr_(const char *path, const char *name, - const char *value, size_t size, - int flags) -> int; -#endif // __APPLE__ -#endif // HAS_SETXATTR + const char *value, size_t size, int flags) + -> int; +#endif // defined(__APPLE__) +#endif // defined(HAS_SETXATTR) #if defined(__APPLE__) - [[nodiscard]] static auto setattr_x_(const char *path, - struct setattr_x *attr) -> int; + [[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,20 +238,20 @@ 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; -#endif // __APPLE__ +#else // !defined(__APPLE__) + [[nodiscard]] static auto statfs_(const char *path, struct statvfs *stbuf) + -> int; +#endif // defined(__APPLE__) #if FUSE_USE_VERSION >= 30 [[nodiscard]] static auto truncate_(const char *path, off_t size, struct fuse_file_info *fi) -> int; -#else +#else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto truncate_(const char *path, off_t size) -> int; -#endif +#endif // FUSE_USE_VERSION >= 30 [[nodiscard]] static auto unlink_(const char *path) -> int; @@ -258,18 +259,18 @@ private: [[nodiscard]] static auto utimens_(const char *path, const struct timespec tv[2], struct fuse_file_info *fi) -> int; -#else +#else // FUSE_USE_VERSION < 30 [[nodiscard]] static auto utimens_(const char *path, const struct timespec tv[2]) -> int; -#endif +#endif // FUSE_USE_VERSION >= 30 [[nodiscard]] static auto write_(const char *path, const char *buffer, size_t write_size, off_t write_offset, 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; } @@ -278,37 +279,40 @@ protected: uint32_t /*flags*/) -> api_error { return api_error::not_implemented; } -#endif // __APPLE__ +#endif // defined(__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 +#else //FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/, mode_t /*mode*/) -> api_error { return api_error::not_implemented; } -#endif +#endif // FUSE_USE_VERSION >= 30 #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 +#else // FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/, gid_t /*gid*/) -> api_error { return api_error::not_implemented; } -#endif +#endif // FUSE_USE_VERSION >= 30 - [[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; } @@ -316,81 +320,87 @@ 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; } #if defined(__APPLE__) - [[nodiscard]] virtual auto - fsetattr_x_impl(std::string /*api_path*/, struct setattr_x * /*attr*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[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__ +#endif // defined(__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 +#endif // FUSE_USE_VERSION < 30 #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 +#else // FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/, struct stat * /*st*/) -> api_error { return api_error::not_implemented; } -#endif +#endif // FUSE_USE_VERSION >= 30 #if defined(__APPLE__) - [[nodiscard]] virtual auto - getxtimes_impl(std::string /*api_path*/, struct timespec * /*bkuptime*/, - struct timespec * /*crtime*/) -> api_error { + [[nodiscard]] virtual auto getxtimes_impl(std::string /*api_path*/, + struct timespec * /*bkuptime*/, + struct timespec * /*crtime*/) + -> api_error { return api_error::not_implemented; } -#endif // __APPLE__ +#endif // defined(__APPLE__) #if FUSE_USE_VERSION >= 30 - virtual auto init_impl(struct fuse_conn_info *conn, - struct fuse_config *cfg) -> void *; -#else + virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) + -> void *; +#else // FUSE_USE_VERSION < 30 virtual auto init_impl(struct fuse_conn_info *conn) -> void *; -#endif +#endif // FUSE_USE_VERSION >= 30 [[nodiscard]] virtual auto mkdir_impl(std::string /*api_path*/, mode_t /*mode*/) -> api_error { 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; } @@ -405,28 +415,28 @@ 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 +#else // FUSE_USE_VERSION < 30 [[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*/) -> api_error { return api_error::not_implemented; } -#endif +#endif // FUSE_USE_VERSION >= 30 - [[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; } @@ -436,13 +446,13 @@ protected: unsigned int /*flags*/) -> api_error { return api_error::not_implemented; } -#else - [[nodiscard]] virtual auto - rename_impl(std::string /*from_api_path*/, - std::string /*to_api_path*/) -> api_error { +#else // FUSE_USE_VERSION < 30 + [[nodiscard]] virtual auto rename_impl(std::string /*from_api_path*/, + std::string /*to_api_path*/) + -> api_error { return api_error::not_implemented; } -#endif +#endif // FUSE_USE_VERSION >= 30 [[nodiscard]] virtual auto rmdir_impl(std::string /*api_path*/) -> api_error { return api_error::not_implemented; @@ -456,14 +466,14 @@ protected: int & /*attribute_size*/) -> api_error { return api_error::not_implemented; } -#else // __APPLE__ +#else // !defined(__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__ +#endif // defined(__APPLE__) [[nodiscard]] virtual auto listxattr_impl(std::string /*api_path*/, char * /*buffer*/, size_t /*size*/, @@ -471,9 +481,9 @@ 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; } @@ -485,21 +495,20 @@ protected: uint32_t /*position*/) -> api_error { 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 { +#else // !defined (__APPLE__) + [[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 +#endif // defined (__APPLE__) +#endif // defined(HAS_SETXATTR) #if defined(__APPLE__) - [[nodiscard]] virtual auto - setattr_x_impl(std::string /*api_path*/, - struct setattr_x * /*attr*/) -> api_error { + [[nodiscard]] virtual auto setattr_x_impl(std::string /*api_path*/, + struct setattr_x * /*attr*/) + -> api_error { return api_error::not_implemented; } @@ -510,72 +519,74 @@ 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 { +#else // !defined(__APPLE__) + [[nodiscard]] virtual auto statfs_impl(std::string /*api_path*/, + struct statvfs * /*stbuf*/) + -> api_error { return api_error::not_implemented; } -#endif // __APPLE__ +#endif // defined(__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 +#else // FUSE_USE_VERSION < 30 [[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/, off_t /*size*/) -> api_error { return api_error::not_implemented; } -#endif +#endif // FUSE_USE_VERSION >= 30 - [[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 { +#else // FUSE_USE_VERSION < 30 + [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, + const struct timespec /*tv*/[2]) + -> api_error { return api_error::not_implemented; } -#endif +#endif // FUSE_USE_VERSION >= 30 [[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; } @@ -603,5 +614,5 @@ public: }; } // namespace repertory -#endif // _WIN32 +#endif // !defined(_WIN32) #endif // REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_ diff --git a/repertory/librepertory/include/drives/fuse/fuse_drive.hpp b/repertory/librepertory/include/drives/fuse/fuse_drive.hpp index fa7b4b50..deb30c47 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_drive.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_drive.hpp @@ -73,92 +73,95 @@ private: protected: #if defined(__APPLE__) - [[nodiscard]] auto chflags_impl(std::string api_path, - uint32_t flags) -> api_error override; -#endif // __APPLE__ + [[nodiscard]] auto chflags_impl(std::string api_path, uint32_t flags) + -> api_error override; +#endif // defined(__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; -#else - [[nodiscard]] auto chmod_impl(std::string api_path, - mode_t mode) -> api_error override; -#endif + [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode, + struct fuse_file_info *file_info) + -> api_error override; +#else // FUSE_USE_VERSION < 30 + [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode) + -> api_error override; +#endif // FUSE_USE_VERSION >= 30 #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; -#else - [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, - gid_t gid) -> api_error override; -#endif + [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid, + struct fuse_file_info *file_info) + -> api_error override; +#else // FUSE_USE_VERSION < 30 + [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid) + -> api_error override; +#endif // FUSE_USE_VERSION >= 30 - [[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 *unix_st, - struct fuse_file_info *file_info) -> api_error override; + [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *unix_st, + 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 fsetattr_x_impl(std::string api_path, + struct setattr_x *attr, + struct fuse_file_info *file_info) + -> api_error override; +#endif // defined(__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; -#endif + [[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size, + struct fuse_file_info *file_info) + -> api_error override; +#endif // FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION >= 30 - [[nodiscard]] auto - getattr_impl(std::string api_path, struct stat *unix_st, - struct fuse_file_info *file_info) -> api_error override; -#else - [[nodiscard]] auto getattr_impl(std::string api_path, - struct stat *unix_st) -> api_error override; -#endif + [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *unix_st, + struct fuse_file_info *file_info) + -> api_error override; +#else // FUSE_USE_VERSION < 30 + [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *unix_st) + -> api_error override; +#endif // FUSE_USE_VERSION >= 30 #if defined(__APPLE__) - [[nodiscard]] auto - getxtimes_impl(std::string api_path, struct timespec *bkuptime, - struct timespec *crtime) -> api_error override; -#endif // __APPLE__ + [[nodiscard]] auto getxtimes_impl(std::string api_path, + struct timespec *bkuptime, + struct timespec *crtime) + -> api_error override; +#endif // defined(__APPLE__) #if FUSE_USE_VERSION >= 30 - auto init_impl(struct fuse_conn_info *conn, - struct fuse_config *cfg) -> void * override; -#else + auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) + -> void * override; +#else // FUSE_USE_VERSION < 30 auto init_impl(struct fuse_conn_info *conn) -> void * override; -#endif +#endif // FUSE_USE_VERSION >= 30 - [[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,121 +169,124 @@ 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; -#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; -#endif + [[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 // 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) + -> api_error override; +#endif // FUSE_USE_VERSION >= 30 - [[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; -#else + std::string to_api_path, unsigned int flags) + -> api_error override; +#else // FUSE_USE_VERSION < 30 [[nodiscard]] auto rename_impl(std::string from_api_path, std::string to_api_path) -> api_error override; -#endif +#endif // FUSE_USE_VERSION >= 30 [[nodiscard]] auto rmdir_impl(std::string api_path) -> api_error override; #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; #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; -#else // __APPLE__ +#else // !defined(__APPLE__) [[nodiscard]] auto getxattr_impl(std::string api_path, const char *name, char *value, size_t size, int &attribute_size) -> api_error override; -#endif // __APPLE__ +#endif // defined(__APPLE__) [[nodiscard]] auto listxattr_impl(std::string api_path, char *buffer, 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; #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__ +#else // !defined(__APPLE__) [[nodiscard]] auto setxattr_impl(std::string api_path, const char *name, - const char *value, size_t size, - int flags) -> api_error override; -#endif // __APPLE__ -#endif // HAS_SETXATTR + const char *value, size_t size, int flags) + -> api_error override; +#endif // defined(__APPLE__) +#endif // defined(HAS_SETXATTR{} #if defined(__APPLE__) - [[nodiscard]] auto - setattr_x_impl(std::string api_path, - struct setattr_x *attr) -> api_error override; + [[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; -#else // __APPLE__ - [[nodiscard]] auto statfs_impl(std::string api_path, - struct statvfs *stbuf) -> api_error override; -#endif // __APPLE__ + [[nodiscard]] auto statfs_x_impl(std::string api_path, struct statfs *stbuf) + -> api_error override; +#else // !defined(__APPLE__) + [[nodiscard]] auto statfs_impl(std::string api_path, struct statvfs *stbuf) + -> api_error override; +#endif // defined(__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; -#else - [[nodiscard]] auto truncate_impl(std::string api_path, - off_t size) -> api_error override; -#endif + [[nodiscard]] auto truncate_impl(std::string api_path, off_t size, + struct fuse_file_info *file_info) + -> api_error override; +#else // FUSE_USE_VERSION < 30 + [[nodiscard]] auto truncate_impl(std::string api_path, off_t size) + -> api_error override; +#endif // FUSE_USE_VERSION >= 30 [[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; -#else - [[nodiscard]] auto - utimens_impl(std::string api_path, - const struct timespec tv[2]) -> api_error override; -#endif + [[nodiscard]] auto utimens_impl(std::string api_path, + const struct timespec tv[2], + struct fuse_file_info *file_info) + -> api_error override; +#else // FUSE_USE_VERSION < 30 + [[nodiscard]] auto utimens_impl(std::string api_path, + const struct timespec tv[2]) + -> api_error override; +#endif // FUSE_USE_VERSION >= 30 - [[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 @@ -289,16 +295,17 @@ 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; @@ -309,21 +316,24 @@ 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; + + void set_item_meta(const std::string &api_path, + const api_meta_map &meta) override; }; } // namespace repertory -#endif // _WIN32 +#endif // !defined(_WIN32) #endif // REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_HPP_ diff --git a/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp b/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp index 9f51fbbc..2cc51149 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp @@ -43,16 +43,17 @@ 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; @@ -62,58 +63,60 @@ 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, + 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, 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, api_error fail_error) + -> api_error; #if defined(__APPLE__) - [[nodiscard]] static auto - get_flags_from_meta(const api_meta_map &meta) -> __uint32_t; -#endif // __APPLE__ + [[nodiscard]] static auto get_flags_from_meta(const api_meta_map &meta) + -> __uint32_t; +#endif // defined(__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; #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; -#endif + [[nodiscard]] auto parse_xattr_parameters(const char *name, + const uint32_t &position, + std::string &attribute_name, + const std::string &api_path) + -> api_error; +#else // !defined(__APPLE__) + [[nodiscard]] auto parse_xattr_parameters(const char *name, + std::string &attribute_name, + const std::string &api_path) + -> api_error; +#endif // defined(__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; -#endif +#else // !defined(__APPLE__) + [[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 // defined(__APPLE__) static void populate_stat(const std::string &api_path, std::uint64_t size_or_count, @@ -125,13 +128,13 @@ 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; }; } // namespace repertory -#endif // _WIN32 +#endif // !defined(_WIN32) #endif // REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_DRIVE_BASE_HPP_ diff --git a/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp b/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp index ef029052..e70624f7 100644 --- a/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp +++ b/repertory/librepertory/include/drives/fuse/i_fuse_drive.hpp @@ -30,29 +30,32 @@ 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_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_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; + get_directory_item_count(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; + get_directory_items(const std::string &api_path) const + -> directory_item_list = 0; - [[nodiscard]] virtual auto - get_item_meta(const std::string &api_path, - api_meta_map &meta) const -> api_error = 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, + 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_total_drive_space() const -> std::uint64_t = 0; @@ -63,12 +66,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, @@ -77,8 +80,11 @@ public: virtual void set_item_meta(const std::string &api_path, const std::string &key, const std::string &value) = 0; + + virtual void set_item_meta(const std::string &api_path, + const api_meta_map &meta) = 0; }; } // namespace repertory -#endif +#endif // !defined(_WIN32) #endif // REPERTORY_INCLUDE_DRIVES_FUSE_I_FUSE_DRIVE_HPP_ diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp index 494ee16c..63495069 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp @@ -38,10 +38,12 @@ public: private: const app_config &config_; packet_client packet_client_; - remote::user_id uid_ = 0; - remote::group_id gid_ = 0; + remote::user_id uid_{0}; + remote::group_id gid_{0}; public: + [[nodiscard]] auto check() -> packet::error_type; + [[nodiscard]] auto fuse_access(const char *path, const std::int32_t &mask) -> packet::error_type override; @@ -51,9 +53,9 @@ 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_destroy() -> packet::error_type override; @@ -67,21 +69,23 @@ public: 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 &st, - bool &directory) -> packet::error_type override; + [[nodiscard]] auto fuse_getattr(const char *path, remote::stat &st, + 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 ; @@ -90,9 +94,10 @@ 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; @@ -107,25 +112,27 @@ public: [[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_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_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) @@ -139,8 +146,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; @@ -157,8 +164,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 @@ -169,45 +176,48 @@ public: std::int32_t &flags, std::uint32_t position) override ;*/ [[nodiscard]] auto - fuse_statfs(const char *path, std::uint64_t frsize, - remote::statfs &st) -> packet::error_type override; + fuse_statfs(const char *path, std::uint64_t frsize, remote::statfs &st) + -> packet::error_type override; - [[nodiscard]] auto - fuse_statfs_x(const char *path, std::uint64_t bsize, - remote::statfs_x &st) -> packet::error_type override; + [[nodiscard]] auto fuse_statfs_x(const char *path, std::uint64_t bsize, + remote::statfs_x &st) + -> 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; - [[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; void set_fuse_uid_gid(const remote::user_id &uid, const remote::group_id &gid) override; diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp index 7290d4bd..e7b0e675 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp @@ -59,7 +59,8 @@ private: static void populate_stat(const struct stat64 &unix_st, remote::stat &r_stat); - [[nodiscard]] auto update_to_windows_format(json &item) -> json &; + [[nodiscard]] auto update_to_windows_format(const std::string &root_api_path, + json &item) -> json &; public: // FUSE Layer diff --git a/repertory/librepertory/include/drives/remote/remote_server_base.hpp b/repertory/librepertory/include/drives/remote/remote_server_base.hpp index 32c09d78..4263ba4a 100644 --- a/repertory/librepertory/include/drives/remote/remote_server_base.hpp +++ b/repertory/librepertory/include/drives/remote/remote_server_base.hpp @@ -39,13 +39,16 @@ #include "utils/base64.hpp" #include "utils/path.hpp" -#define REPERTORY_DIRECTORY_PAGE_SIZE std::size_t(100U) - namespace repertory { template class remote_server_base : public remote_open_file_table, public virtual remote_winfsp::i_remote_instance, public virtual remote_fuse::i_remote_instance { +public: + using handler_callback = std::function; + public: remote_server_base(const remote_server_base &) = delete; remote_server_base(remote_server_base &&) = delete; @@ -62,1318 +65,14 @@ public: event_system::instance().raise(function_name, "remote_server_base"); - handler_lookup_.insert( - {"::winfsp_can_delete", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - std::wstring file_name; - DECODE_OR_RETURN(request, file_name); - - return this->winfsp_can_delete(file_desc, file_name.data()); - }}); - handler_lookup_.insert( - {"::winfsp_cleanup", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - std::wstring file_name; - DECODE_OR_RETURN(request, file_name); - - UINT32 flags{}; - DECODE_OR_RETURN(request, flags); - - BOOLEAN was_deleted{}; - ret = this->winfsp_cleanup(file_desc, file_name.data(), flags, - was_deleted); - response.encode(was_deleted); - - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_close", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - return this->winfsp_close(file_desc); - }}); - handler_lookup_.insert( - {"::winfsp_create", - [this](std::uint32_t, const std::string &client_id, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - std::wstring file_name; - DECODE_OR_RETURN(request, file_name); - - UINT32 create_options{}; - DECODE_OR_RETURN(request, create_options); - - UINT32 granted_access{}; - DECODE_OR_RETURN(request, granted_access); - - UINT32 attributes{}; - DECODE_OR_RETURN(request, attributes); - - UINT64 allocation_size{}; - DECODE_OR_RETURN(request, allocation_size); - - BOOLEAN exists{0}; - remote::file_info file_info{}; - std::string normalized_name; - PVOID file_desc{}; - ret = this->winfsp_create(file_name.data(), create_options, - granted_access, attributes, - allocation_size, &file_desc, &file_info, - normalized_name, exists); - if (ret == STATUS_SUCCESS) { -#if defined(_WIN32) - this->set_client_id(file_desc, client_id); -#else // !defined(_WIN32) - this->set_client_id( - static_cast( - reinterpret_cast(file_desc)), - client_id); -#endif // defined(_WIN32) - response.encode(file_desc); - response.encode(file_info); - response.encode(normalized_name); - response.encode(exists); - } - - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_flush", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - remote::file_info file_info{}; - ret = this->winfsp_flush(file_desc, &file_info); - if (ret == STATUS_SUCCESS) { - response.encode(file_info); - } - - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_get_file_info", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - remote::file_info file_info{}; - ret = this->winfsp_get_file_info(file_desc, &file_info); - if (ret == STATUS_SUCCESS) { - response.encode(file_info); - } - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_get_security_by_name", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - std::wstring file_name; - DECODE_OR_RETURN(request, file_name); - - std::uint64_t descriptor_size{}; - DECODE_OR_RETURN(request, descriptor_size); - - std::uint8_t get_attributes{}; - DECODE_OR_RETURN(request, get_attributes); - - UINT32 attributes{}; - auto *attr_ptr = get_attributes == 0U ? nullptr : &attributes; - std::wstring string_descriptor; - ret = this->winfsp_get_security_by_name( - file_name.data(), attr_ptr, - descriptor_size == 0U ? nullptr : &descriptor_size, - string_descriptor); - if (ret == STATUS_SUCCESS) { - response.encode(string_descriptor); - if (get_attributes != 0U) { - response.encode(attributes); - } - } - - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_get_volume_info", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - UINT64 total_size{}; - UINT64 free_size{}; - std::string volume_label; - if ((ret = this->winfsp_get_volume_info( - total_size, free_size, volume_label)) == STATUS_SUCCESS) { - response.encode(total_size); - response.encode(free_size); - response.encode(volume_label); - } - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_mounted", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - std::string version; - DECODE_OR_RETURN(request, version); - - std::wstring location; - DECODE_OR_RETURN(request, location); - - ret = this->winfsp_mounted(location); - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_open", - [this](std::uint32_t, const std::string &client_id, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - std::wstring file_name; - DECODE_OR_RETURN(request, file_name); - - UINT32 create_options{}; - DECODE_OR_RETURN(request, create_options); - - UINT32 granted_access{}; - DECODE_OR_RETURN(request, granted_access); - - remote::file_info file_info{}; - std::string normalized_name; - PVOID file_desc{}; - ret = this->winfsp_open(file_name.data(), create_options, - granted_access, &file_desc, &file_info, - normalized_name); - if (ret == STATUS_SUCCESS) { -#if defined(_WIN32) - this->set_client_id(file_desc, client_id); -#else // !defined(_WIN32) - this->set_client_id( - static_cast( - reinterpret_cast(file_desc)), - client_id); -#endif // defined(_WIN32) - response.encode(file_desc); - response.encode(file_info); - response.encode(normalized_name); - } - - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_overwrite", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - UINT32 attributes{}; - DECODE_OR_RETURN(request, attributes); - - BOOLEAN replace_attributes{}; - DECODE_OR_RETURN(request, replace_attributes); - - UINT64 allocation_size{}; - DECODE_OR_RETURN(request, allocation_size); - - remote::file_info file_info{}; - ret = - this->winfsp_overwrite(file_desc, attributes, replace_attributes, - allocation_size, &file_info); - if (ret == STATUS_SUCCESS) { - response.encode(file_info); - } - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_read", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - UINT64 offset{}; - DECODE_OR_RETURN(request, offset); - - UINT32 length{}; - DECODE_OR_RETURN(request, length); - - data_buffer buffer(length); - UINT32 bytes_transferred{0}; - ret = this->winfsp_read(file_desc, buffer.data(), offset, length, - &bytes_transferred); - if (ret == STATUS_SUCCESS) { - response.encode(bytes_transferred); - if (bytes_transferred != 0U) { - response.encode(buffer.data(), bytes_transferred); - } - } - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_read_directory", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - std::wstring pattern; - DECODE_OR_IGNORE(request, pattern); - - std::wstring marker; - DECODE_OR_IGNORE(request, marker); - - json item_list; - ret = this->winfsp_read_directory( - file_desc, pattern.data(), - wcsnlen(marker.data(), marker.size()) == 0U ? nullptr - : marker.data(), - item_list); - if (ret == STATUS_SUCCESS) { - response.encode(item_list.dump(0)); - } - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_rename", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - std::wstring file_name; - DECODE_OR_RETURN(request, file_name); - - std::wstring new_file_name; - DECODE_OR_RETURN(request, new_file_name); - - BOOLEAN replace_if_exists{}; - DECODE_OR_RETURN(request, replace_if_exists); - - ret = this->winfsp_rename(file_desc, file_name.data(), - new_file_name.data(), replace_if_exists); - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_set_basic_info", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - UINT32 attributes{}; - DECODE_OR_RETURN(request, attributes); - - UINT64 creation_time{}; - DECODE_OR_RETURN(request, creation_time); - - UINT64 last_access_time{}; - DECODE_OR_RETURN(request, last_access_time); - - UINT64 last_write_time{}; - DECODE_OR_RETURN(request, last_write_time); - - UINT64 change_time{}; - DECODE_OR_RETURN(request, change_time); - - remote::file_info file_info{}; - ret = this->winfsp_set_basic_info( - file_desc, attributes, creation_time, last_access_time, - last_write_time, change_time, &file_info); - if (ret == STATUS_SUCCESS) { - response.encode(file_info); - } - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_set_file_size", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - UINT64 new_size{}; - DECODE_OR_RETURN(request, new_size); - - BOOLEAN set_allocation_size{}; - DECODE_OR_RETURN(request, set_allocation_size); - - remote::file_info file_info{}; - ret = this->winfsp_set_file_size(file_desc, new_size, - set_allocation_size, &file_info); - if (ret == STATUS_SUCCESS) { - response.encode(file_info); - } - return ret; - }}); - handler_lookup_.insert( - {"::winfsp_unmounted", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - std::wstring location; - DECODE_OR_RETURN(request, location); - - return this->winfsp_unmounted(location); - }}); - handler_lookup_.insert( - {"::winfsp_write", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret = static_cast(STATUS_SUCCESS); - - HANDLE file_desc{}; - DECODE_OR_RETURN(request, file_desc); - - UINT32 length{}; - DECODE_OR_RETURN(request, length); - - UINT64 offset{}; - DECODE_OR_RETURN(request, offset); - - BOOLEAN write_to_end{}; - DECODE_OR_RETURN(request, write_to_end); - - BOOLEAN constrained_io{}; - DECODE_OR_RETURN(request, constrained_io); - - auto *buffer = request->current_pointer(); - - UINT32 bytes_transferred{0}; - remote::file_info file_info{}; - ret = this->winfsp_write(file_desc, buffer, offset, length, - write_to_end, constrained_io, - &bytes_transferred, &file_info); - if (ret == STATUS_SUCCESS) { - response.encode(bytes_transferred); - response.encode(file_info); - } - return ret; - }}); - handler_lookup_.insert( - {"::fuse_access", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::int32_t mask{}; - DECODE_OR_RETURN(request, mask); - - return this->fuse_access(path.data(), mask); - }}); - handler_lookup_.insert( - {"::fuse_chflags", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::uint32_t flags{}; - DECODE_OR_RETURN(request, flags); - - return this->fuse_chflags(path.data(), flags); - }}); - handler_lookup_.insert( - {"::fuse_chmod", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_mode mode; - DECODE_OR_RETURN(request, mode); - - return this->fuse_chmod(path.c_str(), mode); - }}); - handler_lookup_.insert( - {"::fuse_chown", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::user_id uid{}; - DECODE_OR_RETURN(request, uid); - - remote::group_id gid{}; - DECODE_OR_RETURN(request, gid); - - return this->fuse_chown(path.c_str(), uid, gid); - }}); - handler_lookup_.insert( - {"::fuse_create", - [this](std::uint32_t, const std::string &client_id, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_mode mode{}; - DECODE_OR_RETURN(request, mode); - - remote::open_flags flags{}; - DECODE_OR_RETURN(request, flags); - - remote::file_handle handle{}; - if ((ret = this->fuse_create(path.data(), mode, flags, handle)) >= - 0) { -#if defined(_WIN32) - this->set_compat_client_id(handle, client_id); -#else // !defined(_WIN32) - this->set_client_id(static_cast(handle), client_id); -#endif // defined(_WIN32) - response.encode(handle); - } - return ret; - }}); - handler_lookup_.insert( - {"::fuse_destroy", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *, packet &) -> packet::error_type { - return this->fuse_destroy(); - }}); - /*handlerLookup_.insert({"::fuse_fallocate", - [this](std::uint32_t serviceFlags, const std::string - &client_id, std::uint64_t threadId, const std::string &method, packet - *request, packet &response) -> packet::error_type { auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::int32_t mode; - DECODE_OR_RETURN(request, mode); - - remote::file_offset offset; - DECODE_OR_RETURN(request, offset); - - remote::file_offset length; - DECODE_OR_RETURN(request, length); - - remote::file_handle handle; - DECODE_OR_RETURN(request, handle); - - return this->fuse_fallocate(path.c_str(), mode, - offset, length, handle); - }});*/ - handler_lookup_.insert( - {"::fuse_fgetattr", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_handle handle{}; - DECODE_OR_RETURN(request, handle); - - remote::user_id uid{}; - DECODE_OR_RETURN(request, uid); - - remote::group_id gid{}; - DECODE_OR_RETURN(request, gid); - - remote::stat st{}; - bool directory = false; - ret = this->fuse_fgetattr(path.data(), st, directory, handle); - if (ret == 0) { - st.st_uid = uid; - st.st_gid = gid; - response.encode(st); - response.encode(static_cast(directory)); - } - - return ret; - }}); - handler_lookup_.insert( - {"::fuse_fsetattr_x", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::setattr_x attr{}; - DECODE_OR_RETURN(request, attr); - - remote::file_handle handle{}; - DECODE_OR_RETURN(request, handle); - - return this->fuse_fsetattr_x(path.data(), attr, handle); - }}); - handler_lookup_.insert( - {"::fuse_fsync", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::int32_t dataSync; - DECODE_OR_RETURN(request, dataSync); - - remote::file_handle handle; - DECODE_OR_RETURN(request, handle); - - return this->fuse_fsync(path.c_str(), dataSync, handle); - }}); - handler_lookup_.insert( - {"::fuse_ftruncate", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_offset size; - DECODE_OR_RETURN(request, size); - - remote::file_handle handle; - DECODE_OR_RETURN(request, handle); - - return this->fuse_ftruncate(path.c_str(), size, handle); - }}); - handler_lookup_.insert( - {"::fuse_getattr", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::user_id uid; - DECODE_OR_RETURN(request, uid); - - remote::group_id gid; - DECODE_OR_RETURN(request, gid); - - remote::stat st{}; - bool directory = false; - ret = this->fuse_getattr(path.c_str(), st, directory); - if (ret == 0) { - st.st_uid = uid; - st.st_gid = gid; - response.encode(st); - response.encode(static_cast(directory)); - } - return ret; - }}); - /*handlerLookup_.insert({"::fuse_getxattr", - [this](std::uint32_t serviceFlags, const std::string - &client_id, std::uint64_t threadId, const std::string &method, packet - *request, packet &response) -> packet::error_type { auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::string name; - DECODE_OR_RETURN(request, name); - - remote::file_size size; - DECODE_OR_RETURN(request, size); - - return this->fuse_getxattr(path.c_str(), &name[0], - nullptr, size); - }}); - handlerLookup_.insert({"::fuse_getxattr_osx", - [this](std::uint32_t serviceFlags, const std::string - &client_id, std::uint64_t threadId, const std::string &method, packet - *request, packet &response) -> packet::error_type { auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::string name; - DECODE_OR_RETURN(request, name); - - remote::file_size size; - DECODE_OR_RETURN(request, size); - - std::uint32_t position; - DECODE_OR_RETURN(request, position); - - return this->fuse_getxattr_osx(path.c_str(), - &name[0], nullptr, size, position); - }});*/ - handler_lookup_.insert( - {"::fuse_getxtimes", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_time bkuptime{}; - remote::file_time crtime{}; - if ((ret = this->fuse_getxtimes(path.c_str(), bkuptime, crtime)) == - 0) { - response.encode(bkuptime); - response.encode(crtime); - } - - return ret; - }}); - handler_lookup_.insert( - {"::fuse_init", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *, - packet &) -> packet::error_type { return this->fuse_init(); }}); - /*handlerLookup_.insert({"::remote_fuseListxattr", - [this](std::uint32_t serviceFlags, const std::string - &client_id, std::uint64_t threadId, const std::string &method, packet - *request, packet &response) -> packet::error_type { auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_size size; - DECODE_OR_RETURN(request, size); - - return this->fuse_listxattr(path.c_str(), nullptr, - size); - }});*/ - handler_lookup_.insert( - {"::fuse_mkdir", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_mode mode; - DECODE_OR_RETURN(request, mode); - - return this->fuse_mkdir(path.c_str(), mode); - }}); - handler_lookup_.insert( - {"::fuse_open", - [this](std::uint32_t, const std::string &client_id, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::open_flags flags; - DECODE_OR_RETURN(request, flags); - - remote::file_handle handle; - if ((ret = this->fuse_open(path.c_str(), flags, handle)) >= 0) { -#if defined(_WIN32) - this->set_compat_client_id(handle, client_id); -#else // !defined(_WIN32) - this->set_client_id(static_cast(handle), client_id); -#endif // defined(_WIN32) - response.encode(handle); - } - return ret; - }}); - handler_lookup_.insert( - {"::fuse_opendir", - [this](std::uint32_t, const std::string &client_id, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_handle handle{0}; - if ((ret = this->fuse_opendir(path.c_str(), handle)) >= 0) { - this->add_directory(client_id, handle); - response.encode(handle); - } - return ret; - }}); - handler_lookup_.insert( - {"::fuse_read", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_size read_size; - DECODE_OR_RETURN(request, read_size); - - remote::file_offset read_offset; - DECODE_OR_RETURN(request, read_offset); - - remote::file_handle handle; - DECODE_OR_RETURN(request, handle); - - data_buffer buffer; - if ((ret = this->fuse_read(path.c_str(), - reinterpret_cast(&buffer), - read_size, read_offset, handle)) > 0) { - response.encode(buffer.data(), buffer.size()); - } - return ret; - }}); - handler_lookup_.insert( - {"::fuse_readdir", - [this](std::uint32_t, const std::string &client_id, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_offset offset; - DECODE_OR_RETURN(request, offset); - - remote::file_handle handle; - DECODE_OR_RETURN(request, handle); - - if (this->has_open_directory(client_id, handle)) { - std::string file_path; - ret = this->fuse_readdir(path.c_str(), offset, handle, file_path); - if (ret == 0) { - response.encode(file_path); - } - } else { - ret = -EBADF; - } - - return ret; - }}); - handler_lookup_.insert( - {"::fuse_release", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_handle handle; - DECODE_OR_RETURN(request, handle); - - return this->fuse_release(path.c_str(), handle); - }}); - handler_lookup_.insert( - {"::fuse_releasedir", - [this](std::uint32_t, const std::string &client_id, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_handle handle; - DECODE_OR_RETURN(request, handle); - - ret = this->fuse_releasedir(path.c_str(), handle); - if (this->remove_directory(client_id, handle)) { - return ret; - } - return -EBADF; - }}); - /*handlerLookup_.insert({"::fuse_removexattr", - [this](std::uint32_t serviceFlags, const std::string - &client_id, std::uint64_t threadId, const std::string &method, packet - *request, packet &response) -> packet::error_type { auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::string name; - DECODE_OR_RETURN(request, name); - - return this->fuse_removexattr(path.c_str(), - &name[0]); - }});*/ - handler_lookup_.insert( - {"::fuse_rename", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{0}; - - std::string from; - DECODE_OR_RETURN(request, from); - - std::string to; - DECODE_OR_RETURN(request, to); - - return this->fuse_rename(from.data(), to.data()); - }}); - handler_lookup_.insert( - {"::fuse_rmdir", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - return this->fuse_rmdir(path.data()); - }}); - handler_lookup_.insert( - {"::fuse_setattr_x", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::setattr_x attr{}; - DECODE_OR_RETURN(request, attr); - - return this->fuse_setattr_x(path.data(), attr); - }}); - handler_lookup_.insert( - {"::fuse_setbkuptime", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_time bkuptime{}; - DECODE_OR_RETURN(request, bkuptime); - - return this->fuse_setbkuptime(path.data(), bkuptime); - }}); - handler_lookup_.insert( - {"::fuse_setchgtime", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_time chgtime{}; - DECODE_OR_RETURN(request, chgtime); - - return this->fuse_setchgtime(path.data(), chgtime); - }}); - handler_lookup_.insert( - {"::fuse_setcrtime", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_time crtime{}; - DECODE_OR_RETURN(request, crtime); - - return this->fuse_setcrtime(path.data(), crtime); - }}); - handler_lookup_.insert( - {"::fuse_setvolname", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{0}; - - std::string name; - DECODE_OR_RETURN(request, name); - - return this->fuse_setvolname(name.data()); - }}); - /*handlerLookup_.insert({"::fuse_setxattr", - [this](std::uint32_t serviceFlags, const std::string - &client_id, std::uint64_t threadId, const std::string &method, packet - *request, packet &response) -> packet::error_type { auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::string name; - DECODE_OR_RETURN(request, name); - - remote::file_size size; - DECODE_OR_RETURN(request, size); - - if (size > std::numeric_limits::max()) - { return -ERANGE; - } - - data_buffer value(static_cast(size)); - ret = request->Decode(&value[0], value.size()); - if (ret == 0) { - std::int32_t flags; - DECODE_OR_RETURN(request, flags); - - ret = this->fuse_setxattr(path.c_str(), &name[0], - &value[0], size, flags); - } - return ret; - }}); - handlerLookup_.insert({"::fuse_setxattr_osx", - [this](std::uint32_t serviceFlags, const std::string - &client_id, std::uint64_t threadId, const std::string &method, packet - *request, packet &response) -> packet::error_type { auto ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::string name; - DECODE_OR_RETURN(request, name); - - remote::file_size size; - DECODE_OR_RETURN(request, size); - - if (size > std::numeric_limits::max()) - { return -ERANGE; - } - - data_buffer value(static_cast(size)); - ret = request->Decode(&value[0], value.size()); - if (ret == 0) { - std::int32_t flags; - DECODE_OR_RETURN(request, flags); - - std::uint32_t position; - DECODE_OR_RETURN(request, position); - - ret = this->fuse_setxattr_osx(path.c_str(), - &name[0], &value[0], size, flags, position); - } - return ret; - }});*/ - handler_lookup_.insert( - {"::fuse_statfs", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - std::int32_t ret{-1}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::uint64_t frsize{}; - DECODE_OR_RETURN(request, frsize); - - remote::statfs st{}; - ret = this->fuse_statfs(path.data(), frsize, st); - if (ret == 0) { - response.encode(st); - } - return ret; - }}); - handler_lookup_.insert( - {"::fuse_statfs_x", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - std::int32_t ret{-1}; - - std::string path; - DECODE_OR_RETURN(request, path); - - std::uint64_t bsize{}; - DECODE_OR_RETURN(request, bsize); - - remote::statfs_x st{}; - ret = this->fuse_statfs_x(path.data(), bsize, st); - if (ret == 0) { - response.encode(st); - } - return ret; - }}); - handler_lookup_.insert( - {"::fuse_truncate", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_offset size{}; - DECODE_OR_IGNORE(request, size); - - return this->fuse_truncate(path.data(), size); - }}); - handler_lookup_.insert( - {"::fuse_unlink", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{}; - - std::string path; - DECODE_OR_RETURN(request, path); - - return this->fuse_unlink(path.data()); - }}); - handler_lookup_.insert( - {"::fuse_utimens", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_time tv[2] = {0}; - if ((ret = request->decode(&tv[0], sizeof(remote::file_time) * 2)) == - 0) { - std::uint64_t op0{}; - DECODE_OR_RETURN(request, op0); - - std::uint64_t op1{}; - DECODE_OR_RETURN(request, op1); - - ret = this->fuse_utimens(path.data(), tv, op0, op1); - } - return ret; - }}); - handler_lookup_.insert( - {"::fuse_write", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_size write_size{}; - DECODE_OR_RETURN(request, write_size); - - if (write_size > std::numeric_limits::max()) { - return -ERANGE; - } - - data_buffer buffer(write_size); - if ((ret = request->decode(buffer.data(), buffer.size())) == 0) { - remote::file_offset write_offset{}; - DECODE_OR_RETURN(request, write_offset); - - remote::file_handle handle{}; - DECODE_OR_RETURN(request, handle); - - ret = this->fuse_write( - path.data(), reinterpret_cast(buffer.data()), - write_size, write_offset, handle); - } - return ret; - }}); - handler_lookup_.insert( - {"::fuse_write_base64", - [this](std::uint32_t, const std::string &, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_size write_size{}; - DECODE_OR_RETURN(request, write_size); - - if (write_size > std::numeric_limits::max()) { - return -ERANGE; - } - - data_buffer buffer(write_size); - if ((ret = request->decode(buffer.data(), buffer.size())) == 0) { - buffer = macaron::Base64::Decode( - std::string(buffer.begin(), buffer.end())); - write_size = buffer.size(); - - remote::file_offset write_offset{}; - DECODE_OR_RETURN(request, write_offset); - - remote::file_handle handle{}; - DECODE_OR_RETURN(request, handle); - - ret = this->fuse_write(path.data(), - reinterpret_cast(buffer.data()), - write_size, write_offset, handle); - } - return ret; - }}); - handler_lookup_.insert( - {"::json_create_directory_snapshot", - [this](std::uint32_t, const std::string &client_id, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - std::int32_t ret{}; - - std::string path; - DECODE_OR_RETURN(request, path); - - json json_data; - json_data["handle"] = -1; - json_data["page_count"] = 0; - json_data["path"] = path; - if ((ret = this->json_create_directory_snapshot(path.data(), - json_data)) == 0) { - this->add_directory(client_id, - json_data["handle"].get()); - response.encode(json_data.dump(0)); - } - return ret; - }}); - handler_lookup_.insert( - {"::json_read_directory_snapshot", - [this](std::uint32_t, const std::string &client_id, std::uint64_t, - const std::string &, packet *request, - packet &response) -> packet::error_type { - std::int32_t ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_handle handle{}; - DECODE_OR_RETURN(request, handle); - - std::uint32_t page{}; - DECODE_OR_RETURN(request, page); - - ret = -EBADF; - if (this->has_open_directory(client_id, handle)) { - json json_data; - json_data["directory_list"] = std::vector(); - json_data["page"] = page; - ret = this->json_read_directory_snapshot(path, handle, page, - json_data); - if ((ret == 0) || (ret == -120)) { - response.encode(json_data.dump(0)); - } - } - - return ret; - }}); - handler_lookup_.insert( - {"::json_release_directory_snapshot", - [this](std::uint32_t, const std::string &client_id, std::uint64_t, - const std::string &, packet *request, - packet &) -> packet::error_type { - std::int32_t ret{0}; - - std::string path; - DECODE_OR_RETURN(request, path); - - remote::file_handle handle{}; - DECODE_OR_RETURN(request, handle); - - ret = this->json_release_directory_snapshot(path.data(), handle); - if (this->remove_directory(client_id, handle)) { - return ret; - } - return -EBADF; - }}); - packet_server_ = std::make_unique( config_.get_remote_mount().api_port, - config_.get_remote_mount().encryption_token, 10, - [this](const std::string &client_id) { - return this->closed_handler(client_id); - }, - [this](std::uint32_t service_flags, const std::string &client_id, - std::uint64_t thread_id, const std::string &method, - packet *request, packet &response, - packet_server::message_complete_callback message_complete) { + config_.get_remote_mount().encryption_token, + config_.get_remote_mount().client_pool_size, + [this](auto &&client_id) { return this->closed_handler(client_id); }, + [this](auto &&service_flags, auto &&client_id, auto &&thread_id, + auto &&method, auto &&request, auto &&response, + auto &&message_complete) { return this->message_handler(service_flags, client_id, thread_id, method, request, response, message_complete); @@ -1393,11 +92,6 @@ public: "remote_server_base"); } -public: - using handler_callback = std::function; - protected: app_config &config_; drive &drive_; @@ -1406,7 +100,460 @@ protected: private: client_pool client_pool_; std::unique_ptr packet_server_; - std::unordered_map handler_lookup_; + +private: + const std::unordered_map handler_lookup_ = { + { + "::check", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, + auto && /* request */, + auto && /* response */) -> auto { return 0; }, + }, + { + "::fuse_access", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_access(request); + }, + }, + { + "::fuse_chflags", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_chflags(request); + }, + }, + { + "::fuse_chmod", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_chmod(request); + }, + }, + { + "::fuse_chown", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_chown(request); + }, + }, + { + "::fuse_create", + [this](auto && /* service_flags */, auto &&client_id, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_fuse_create(client_id, request, response); + }, + }, + { + "::fuse_destroy", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, + auto && /* request */, auto && /* response */) -> auto { + return this->handle_fuse_destroy(); + }, + }, + { + "::fuse_fgetattr", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_fuse_fgetattr(request, response); + }, + }, + { + "::fuse_fsetattr_x", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_fsetattr_x(request); + }, + }, + { + "::fuse_fsync", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_fsync(request); + }, + }, + { + "::fuse_ftruncate", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_ftruncate(request); + }, + }, + { + "::fuse_getattr", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_fuse_getattr(request, response); + }, + }, + { + "::fuse_getxtimes", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_fuse_getxtimes(request, response); + }, + }, + { + "::fuse_init", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, + auto && /* request */, auto && /* response */) -> auto { + return this->handle_fuse_init(); + }, + }, + { + "::fuse_mkdir", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_mkdir(request); + }, + }, + { + "::fuse_open", + [this](auto && /* service_flags */, auto &&client_id, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_fuse_open(client_id, request, response); + }, + }, + { + "::fuse_opendir", + [this](auto && /* service_flags */, auto &&client_id, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_fuse_opendir(client_id, request, response); + }, + }, + { + "::fuse_read", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_fuse_read(request, response); + }, + }, + { + "::fuse_readdir", + [this](auto && /* service_flags */, auto &&client_id, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_fuse_readdir(client_id, request, response); + }, + }, + { + "::fuse_release", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_release(request); + }, + }, + { + "::fuse_releasedir", + [this](auto && /* service_flags */, auto &&client_id, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_releasedir(client_id, request); + }, + }, + { + "::fuse_rename", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_rename(request); + }, + }, + { + "::fuse_rmdir", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_rmdir(request); + }, + }, + { + "::fuse_setattr_x", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_setattr_x(request); + }, + }, + { + "::fuse_setbkuptime", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_setbkuptime(request); + }, + }, + { + "::fuse_setchgtime", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_setchgtime(request); + }, + }, + { + "::fuse_setcrtime", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_setcrtime(request); + }, + }, + { + "::fuse_setvolname", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_setvolname(request); + }, + }, + { + "::fuse_statfs", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_fuse_statfs(request, response); + }, + }, + { + "::fuse_statfs_x", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_fuse_statfs_x(request, response); + }, + }, + { + "::fuse_truncate", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_truncate(request); + }, + }, + { + "::fuse_unlink", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_unlink(request); + }, + }, + { + "::fuse_utimens", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_utimens(request); + }, + }, + { + "::fuse_write", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_write(request); + }, + }, + { + "::fuse_write_base64", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_fuse_write_base64(request); + }, + }, + { + "::json_create_directory_snapshot", + [this](auto && /* service_flags */, auto &&client_id, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_json_create_directory_snapshot( + client_id, request, response); + }, + }, + { + "::json_read_directory_snapshot", + [this](auto && /* service_flags */, auto &&client_id, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_json_read_directory_snapshot(client_id, request, + response); + }, + }, + { + "::json_release_directory_snapshot", + [this](auto && /* service_flags */, auto &&client_id, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_json_release_directory_snapshot(client_id, + request); + }, + }, + { + "::winfsp_can_delete", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_winfsp_can_delete(request); + }, + }, + { + "::winfsp_cleanup", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_cleanup(request, response); + }, + }, + { + "::winfsp_close", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_winfsp_close(request); + }, + }, + { + "::winfsp_create", + [this](auto && /* service_flags */, auto &&client_id, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_create(client_id, request, response); + }, + }, + { + "::winfsp_flush", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_flush(request, response); + }, + }, + { + "::winfsp_get_file_info", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_get_file_info(request, response); + }, + }, + { + "::winfsp_get_security_by_name", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_get_security_by_name(request, response); + }, + }, + { + "::winfsp_get_volume_info", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, + auto && /* request */, auto &&response) -> auto { + return this->handle_winfsp_get_volume_info(response); + }, + }, + { + "::winfsp_mounted", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_winfsp_mounted(request); + }, + }, + { + "::winfsp_open", + [this](auto && /* service_flags */, auto &&client_id, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_open(client_id, request, response); + }, + }, + { + "::winfsp_overwrite", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_overwrite(request, response); + }, + }, + { + "::winfsp_read", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_read(request, response); + }, + }, + { + "::winfsp_read_directory", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_read_directory(request, response); + }, + }, + { + "::winfsp_rename", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_winfsp_rename(request); + }, + }, + { + "::winfsp_set_basic_info", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_set_basic_info(request, response); + }, + }, + { + "::winfsp_set_file_size", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_set_file_size(request, response); + }, + }, + { + "::winfsp_unmounted", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto && /* response */) -> auto { + return this->handle_winfsp_unmounted(request); + }, + }, + { + "::winfsp_write", + [this](auto && /* service_flags */, auto && /* client_id */, + auto && /* thread_id */, auto && /* method */, auto &&request, + auto &&response) -> auto { + return this->handle_winfsp_write(request, response); + }, + }, + }; private: void closed_handler(const std::string &client_id) { @@ -1414,34 +561,1240 @@ private: close_all(client_id); } + [[nodiscard]] auto handle_fuse_access(packet *request) -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::int32_t mask{}; + DECODE_OR_RETURN(request, mask); + + return this->fuse_access(path.data(), mask); + } + + [[nodiscard]] auto handle_fuse_chflags(packet *request) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::uint32_t flags{}; + DECODE_OR_RETURN(request, flags); + + return this->fuse_chflags(path.data(), flags); + } + + [[nodiscard]] auto handle_fuse_chmod(packet *request) -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_mode mode; + DECODE_OR_RETURN(request, mode); + + return this->fuse_chmod(path.c_str(), mode); + } + + [[nodiscard]] auto handle_fuse_chown(packet *request) -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::user_id uid{}; + DECODE_OR_RETURN(request, uid); + + remote::group_id gid{}; + DECODE_OR_RETURN(request, gid); + + return this->fuse_chown(path.c_str(), uid, gid); + } + + [[nodiscard]] auto handle_fuse_create(const std::string &client_id, + packet *request, packet &response) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_mode mode{}; + DECODE_OR_RETURN(request, mode); + + remote::open_flags flags{}; + DECODE_OR_RETURN(request, flags); + + remote::file_handle handle{}; + + ret = this->fuse_create(path.data(), mode, flags, handle); + if (ret >= 0) { +#if defined(_WIN32) + this->set_compat_client_id(handle, client_id); +#else // !defined(_WIN32) + this->set_client_id(static_cast(handle), client_id); +#endif // defined(_WIN32) + response.encode(handle); + } + return ret; + } + + [[nodiscard]] auto handle_fuse_destroy() -> packet::error_type { + return this->fuse_destroy(); + } + + [[nodiscard]] auto handle_fuse_fgetattr(packet *request, packet &response) { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_handle handle{}; + DECODE_OR_RETURN(request, handle); + + remote::user_id uid{}; + DECODE_OR_RETURN(request, uid); + + remote::group_id gid{}; + DECODE_OR_RETURN(request, gid); + + remote::stat st{}; + bool directory = false; + ret = this->fuse_fgetattr(path.data(), st, directory, handle); + if (ret == 0) { + st.st_uid = uid; + st.st_gid = gid; + response.encode(st); + response.encode(static_cast(directory)); + } + + return ret; + } + + [[nodiscard]] auto handle_fuse_fsetattr_x(packet *request) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::setattr_x attr{}; + DECODE_OR_RETURN(request, attr); + + remote::file_handle handle{}; + DECODE_OR_RETURN(request, handle); + + return this->fuse_fsetattr_x(path.data(), attr, handle); + } + + [[nodiscard]] auto handle_fuse_fsync(packet *request) -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::int32_t dataSync; + DECODE_OR_RETURN(request, dataSync); + + remote::file_handle handle; + DECODE_OR_RETURN(request, handle); + + return this->fuse_fsync(path.c_str(), dataSync, handle); + } + + [[nodiscard]] auto handle_fuse_ftruncate(packet *request) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_offset size; + DECODE_OR_RETURN(request, size); + + remote::file_handle handle; + DECODE_OR_RETURN(request, handle); + + return this->fuse_ftruncate(path.c_str(), size, handle); + } + + [[nodiscard]] auto handle_fuse_getattr(packet *request, packet &response) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::user_id uid; + DECODE_OR_RETURN(request, uid); + + remote::group_id gid; + DECODE_OR_RETURN(request, gid); + + remote::stat st{}; + bool directory = false; + ret = this->fuse_getattr(path.c_str(), st, directory); + if (ret == 0) { + st.st_uid = uid; + st.st_gid = gid; + response.encode(st); + response.encode(static_cast(directory)); + } + return ret; + } + + [[nodiscard]] auto handle_fuse_getxtimes(packet *request, packet &response) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_time bkuptime{}; + remote::file_time crtime{}; + ret = this->fuse_getxtimes(path.c_str(), bkuptime, crtime); + if (ret == 0) { + response.encode(bkuptime); + response.encode(crtime); + } + + return ret; + } + + [[nodiscard]] auto handle_fuse_init() -> packet::error_type { + return this->fuse_init(); + } + + [[nodiscard]] auto handle_fuse_mkdir(packet *request) -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_mode mode; + DECODE_OR_RETURN(request, mode); + + return this->fuse_mkdir(path.c_str(), mode); + } + + [[nodiscard]] auto handle_fuse_open(const std::string &client_id, + packet *request, packet &response) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::open_flags flags; + DECODE_OR_RETURN(request, flags); + + remote::file_handle handle; + ret = this->fuse_open(path.c_str(), flags, handle); + if (ret >= 0) { +#if defined(_WIN32) + this->set_compat_client_id(handle, client_id); +#else // !defined(_WIN32) + this->set_client_id(static_cast(handle), client_id); +#endif // defined(_WIN32) + response.encode(handle); + } + return ret; + } + + [[nodiscard]] auto handle_fuse_opendir(const std::string &client_id, + packet *request, packet &response) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_handle handle{0}; + ret = this->fuse_opendir(path.c_str(), handle); + if (ret >= 0) { + this->add_directory(client_id, handle); + response.encode(handle); + } + + return ret; + } + + [[nodiscard]] auto handle_fuse_read(packet *request, packet &response) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_size read_size; + DECODE_OR_RETURN(request, read_size); + + remote::file_offset read_offset; + DECODE_OR_RETURN(request, read_offset); + + remote::file_handle handle; + DECODE_OR_RETURN(request, handle); + + data_buffer buffer; + ret = this->fuse_read(path.c_str(), reinterpret_cast(&buffer), + read_size, read_offset, handle); + if (ret > 0) { + response.encode(buffer.data(), buffer.size()); + } + return ret; + } + + [[nodiscard]] auto handle_fuse_readdir(const std::string &client_id, + packet *request, packet &response) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_offset offset; + DECODE_OR_RETURN(request, offset); + + remote::file_handle handle; + DECODE_OR_RETURN(request, handle); + + if (this->has_open_directory(client_id, handle)) { + std::string file_path; + ret = this->fuse_readdir(path.c_str(), offset, handle, file_path); + if (ret == 0) { + response.encode(file_path); + } + } else { + ret = -EBADF; + } + + return ret; + } + + [[nodiscard]] auto handle_fuse_release(packet *request) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_handle handle; + DECODE_OR_RETURN(request, handle); + + return this->fuse_release(path.c_str(), handle); + } + + [[nodiscard]] auto handle_fuse_releasedir(const std::string &client_id, + packet *request) + -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_handle handle; + DECODE_OR_RETURN(request, handle); + + ret = this->fuse_releasedir(path.c_str(), handle); + if (this->remove_directory(client_id, handle)) { + return ret; + } + return -EBADF; + } + + [[nodiscard]] auto handle_fuse_rename(packet *request) -> packet::error_type { + std::int32_t ret{0}; + + std::string from; + DECODE_OR_RETURN(request, from); + + std::string to; + DECODE_OR_RETURN(request, to); + + return this->fuse_rename(from.data(), to.data()); + } + + [[nodiscard]] auto handle_fuse_rmdir(packet *request) -> packet::error_type { + std::int32_t ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + return this->fuse_rmdir(path.data()); + } + + [[nodiscard]] auto handle_fuse_setattr_x(packet *request) + -> packet::error_type { + std::int32_t ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::setattr_x attr{}; + DECODE_OR_RETURN(request, attr); + + return this->fuse_setattr_x(path.data(), attr); + } + + [[nodiscard]] auto handle_fuse_setbkuptime(packet *request) + -> packet::error_type { + std::int32_t ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_time bkuptime{}; + DECODE_OR_RETURN(request, bkuptime); + + return this->fuse_setbkuptime(path.data(), bkuptime); + } + + [[nodiscard]] auto handle_fuse_setchgtime(packet *request) + -> packet::error_type { + std::int32_t ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_time chgtime{}; + DECODE_OR_RETURN(request, chgtime); + + return this->fuse_setchgtime(path.data(), chgtime); + } + + [[nodiscard]] auto handle_fuse_setcrtime(packet *request) + -> packet::error_type { + std::int32_t ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_time crtime{}; + DECODE_OR_RETURN(request, crtime); + + return this->fuse_setcrtime(path.data(), crtime); + } + + [[nodiscard]] auto handle_fuse_setvolname(packet *request) + -> packet::error_type { + std::int32_t ret{0}; + + std::string name; + DECODE_OR_RETURN(request, name); + + return this->fuse_setvolname(name.data()); + } + + [[nodiscard]] auto handle_fuse_statfs(packet *request, packet &response) + -> packet::error_type { + std::int32_t ret{-1}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::uint64_t frsize{}; + DECODE_OR_RETURN(request, frsize); + + remote::statfs st{}; + ret = this->fuse_statfs(path.data(), frsize, st); + if (ret == 0) { + response.encode(st); + } + + return ret; + } + + [[nodiscard]] auto handle_fuse_statfs_x(packet *request, packet &response) + -> packet::error_type { + std::int32_t ret{-1}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::uint64_t bsize{}; + DECODE_OR_RETURN(request, bsize); + + remote::statfs_x st{}; + ret = this->fuse_statfs_x(path.data(), bsize, st); + if (ret == 0) { + response.encode(st); + } + return ret; + } + + [[nodiscard]] auto handle_fuse_truncate(packet *request) + -> packet::error_type { + std::int32_t ret{}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_offset size{}; + DECODE_OR_IGNORE(request, size); + + return this->fuse_truncate(path.data(), size); + } + + [[nodiscard]] auto handle_fuse_unlink(packet *request) -> packet::error_type { + std::int32_t ret{}; + + std::string path; + DECODE_OR_RETURN(request, path); + + return this->fuse_unlink(path.data()); + } + + [[nodiscard]] auto handle_fuse_utimens(packet *request) + -> packet::error_type { + std::int32_t ret{}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_time tv[2] = {0}; + ret = request->decode(&tv[0], sizeof(remote::file_time) * 2); + if (ret == 0) { + std::uint64_t op0{}; + DECODE_OR_RETURN(request, op0); + + std::uint64_t op1{}; + DECODE_OR_RETURN(request, op1); + + ret = this->fuse_utimens(path.data(), tv, op0, op1); + } + return ret; + } + + [[nodiscard]] auto handle_fuse_write(packet *request) -> packet::error_type { + std::int32_t ret{}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_size write_size{}; + DECODE_OR_RETURN(request, write_size); + + if (write_size > std::numeric_limits::max()) { + return -ERANGE; + } + + data_buffer buffer(write_size); + ret = request->decode(buffer.data(), buffer.size()); + if (ret == 0) { + remote::file_offset write_offset{}; + DECODE_OR_RETURN(request, write_offset); + + remote::file_handle handle{}; + DECODE_OR_RETURN(request, handle); + + ret = this->fuse_write(path.data(), + reinterpret_cast(buffer.data()), + write_size, write_offset, handle); + } + return ret; + } + + [[nodiscard]] auto handle_fuse_write_base64(packet *request) + -> packet::error_type { + std::int32_t ret{}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_size write_size{}; + DECODE_OR_RETURN(request, write_size); + + if (write_size > std::numeric_limits::max()) { + return -ERANGE; + } + + data_buffer buffer(write_size); + ret = request->decode(buffer.data(), buffer.size()); + if (ret == 0) { + buffer = + macaron::Base64::Decode(std::string(buffer.begin(), buffer.end())); + write_size = buffer.size(); + + remote::file_offset write_offset{}; + DECODE_OR_RETURN(request, write_offset); + + remote::file_handle handle{}; + DECODE_OR_RETURN(request, handle); + + ret = + this->fuse_write(path.data(), reinterpret_cast(buffer.data()), + write_size, write_offset, handle); + } + return ret; + } + + [[nodiscard]] auto + handle_json_create_directory_snapshot(const std::string &client_id, + packet *request, packet &response) + -> packet::error_type { + std::int32_t ret{}; + + std::string path; + DECODE_OR_RETURN(request, path); + + json json_data; + json_data["handle"] = -1; + json_data["page_count"] = 0; + json_data["path"] = path; + ret = this->json_create_directory_snapshot(path.data(), json_data); + if (ret == 0) { + this->add_directory(client_id, json_data["handle"].get()); + response.encode(json_data.dump(0)); + } + return ret; + } + + [[nodiscard]] auto + handle_json_read_directory_snapshot(const std::string &client_id, + packet *request, packet &response) + -> packet::error_type { + std::int32_t ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_handle handle{}; + DECODE_OR_RETURN(request, handle); + + std::uint32_t page{}; + DECODE_OR_RETURN(request, page); + + ret = -EBADF; + if (this->has_open_directory(client_id, handle)) { + json json_data; + json_data["directory_list"] = std::vector(); + json_data["page"] = page; + ret = this->json_read_directory_snapshot(path, handle, page, json_data); + if ((ret == 0) || (ret == -120)) { + response.encode(json_data.dump(0)); + } + } + + return ret; + } + + [[nodiscard]] auto handle_json_release_directory_snapshot( + const std::string &client_id, packet *request) -> packet::error_type { + std::int32_t ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_handle handle{}; + DECODE_OR_RETURN(request, handle); + + ret = this->json_release_directory_snapshot(path.data(), handle); + if (this->remove_directory(client_id, handle)) { + return ret; + } + return -EBADF; + } + + [[nodiscard]] auto handle_winfsp_can_delete(packet *request) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + std::wstring file_name; + DECODE_OR_RETURN(request, file_name); + + return this->winfsp_can_delete(file_desc, file_name.data()); + } + + [[nodiscard]] auto handle_winfsp_cleanup(packet *request, packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + std::wstring file_name; + DECODE_OR_RETURN(request, file_name); + + UINT32 flags{}; + DECODE_OR_RETURN(request, flags); + + BOOLEAN was_deleted{}; + ret = this->winfsp_cleanup(file_desc, file_name.data(), flags, was_deleted); + + response.encode(was_deleted); + return ret; + } + + [[nodiscard]] auto handle_winfsp_close(packet *request) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + return this->winfsp_close(file_desc); + } + + [[nodiscard]] auto handle_winfsp_create(const std::string &client_id, + packet *request, packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + std::wstring file_name; + DECODE_OR_RETURN(request, file_name); + + UINT32 create_options{}; + DECODE_OR_RETURN(request, create_options); + + UINT32 granted_access{}; + DECODE_OR_RETURN(request, granted_access); + + UINT32 attributes{}; + DECODE_OR_RETURN(request, attributes); + + UINT64 allocation_size{}; + DECODE_OR_RETURN(request, allocation_size); + + BOOLEAN exists{0}; + remote::file_info file_info{}; + std::string normalized_name; + PVOID file_desc{}; + ret = this->winfsp_create(file_name.data(), create_options, granted_access, + attributes, allocation_size, &file_desc, + &file_info, normalized_name, exists); + if (ret == STATUS_SUCCESS) { + if (exists == 0U) { +#if defined(_WIN32) + this->set_client_id(file_desc, client_id); +#else // !defined(_WIN32) + this->set_client_id(static_cast( + reinterpret_cast(file_desc)), + client_id); +#endif // defined(_WIN32) + } + + response.encode(file_desc); + response.encode(file_info); + response.encode(normalized_name); + response.encode(exists); + } + + return ret; + } + + [[nodiscard]] auto handle_winfsp_flush(packet *request, packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + remote::file_info file_info{}; + ret = this->winfsp_flush(file_desc, &file_info); + if (ret == STATUS_SUCCESS) { + response.encode(file_info); + } + + return ret; + } + + [[nodiscard]] auto handle_winfsp_get_file_info(packet *request, + packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + remote::file_info file_info{}; + ret = this->winfsp_get_file_info(file_desc, &file_info); + if (ret == STATUS_SUCCESS) { + response.encode(file_info); + } + return ret; + } + + [[nodiscard]] auto handle_winfsp_get_security_by_name(packet *request, + packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + std::wstring file_name; + DECODE_OR_RETURN(request, file_name); + + std::uint64_t descriptor_size{}; + DECODE_OR_RETURN(request, descriptor_size); + + std::uint8_t get_attributes{}; + DECODE_OR_RETURN(request, get_attributes); + + UINT32 attributes{}; + auto *attr_ptr = get_attributes == 0U ? nullptr : &attributes; + std::wstring string_descriptor; + ret = this->winfsp_get_security_by_name( + file_name.data(), attr_ptr, + descriptor_size == 0U ? nullptr : &descriptor_size, string_descriptor); + if (ret == STATUS_SUCCESS) { + response.encode(string_descriptor); + if (get_attributes != 0U) { + response.encode(attributes); + } + } + + return ret; + } + + [[nodiscard]] auto handle_winfsp_get_volume_info(packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + UINT64 total_size{}; + UINT64 free_size{}; + std::string volume_label; + ret = this->winfsp_get_volume_info(total_size, free_size, volume_label); + if (ret == STATUS_SUCCESS) { + response.encode(total_size); + response.encode(free_size); + response.encode(volume_label); + } + + return ret; + } + + [[nodiscard]] auto handle_winfsp_mounted(packet *request) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + std::string version; + DECODE_OR_RETURN(request, version); + + std::wstring location; + DECODE_OR_RETURN(request, location); + + ret = this->winfsp_mounted(location); + return ret; + } + + [[nodiscard]] auto handle_winfsp_open(const std::string &client_id, + packet *request, packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + std::wstring file_name; + DECODE_OR_RETURN(request, file_name); + + UINT32 create_options{}; + DECODE_OR_RETURN(request, create_options); + + UINT32 granted_access{}; + DECODE_OR_RETURN(request, granted_access); + + remote::file_info file_info{}; + std::string normalized_name; + PVOID file_desc{}; + ret = this->winfsp_open(file_name.data(), create_options, granted_access, + &file_desc, &file_info, normalized_name); + if (ret == STATUS_SUCCESS) { +#if defined(_WIN32) + this->set_client_id(file_desc, client_id); +#else // !defined(_WIN32) + this->set_client_id(static_cast( + reinterpret_cast(file_desc)), + client_id); +#endif // defined(_WIN32) + response.encode(file_desc); + response.encode(file_info); + response.encode(normalized_name); + } + + return ret; + } + + [[nodiscard]] auto handle_winfsp_overwrite(packet *request, packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + UINT32 attributes{}; + DECODE_OR_RETURN(request, attributes); + + BOOLEAN replace_attributes{}; + DECODE_OR_RETURN(request, replace_attributes); + + UINT64 allocation_size{}; + DECODE_OR_RETURN(request, allocation_size); + + remote::file_info file_info{}; + ret = this->winfsp_overwrite(file_desc, attributes, replace_attributes, + allocation_size, &file_info); + if (ret == STATUS_SUCCESS) { + response.encode(file_info); + } + return ret; + } + + [[nodiscard]] auto handle_winfsp_read(packet *request, packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + UINT64 offset{}; + DECODE_OR_RETURN(request, offset); + + UINT32 length{}; + DECODE_OR_RETURN(request, length); + + data_buffer buffer(length); + UINT32 bytes_transferred{0U}; + ret = this->winfsp_read(file_desc, buffer.data(), offset, length, + &bytes_transferred); + response.encode(bytes_transferred); + buffer.resize(bytes_transferred); + + if ((ret == STATUS_SUCCESS) && (bytes_transferred != 0U)) { + response.encode(buffer.data(), bytes_transferred); + } + + return ret; + } + + [[nodiscard]] auto handle_winfsp_read_directory(packet *request, + packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + std::wstring pattern; + DECODE_OR_IGNORE(request, pattern); + + std::wstring marker; + DECODE_OR_IGNORE(request, marker); + + json item_list; + ret = this->winfsp_read_directory( + file_desc, pattern.data(), + wcsnlen(marker.data(), marker.size()) == 0U ? nullptr : marker.data(), + item_list); + if (ret == STATUS_SUCCESS) { + response.encode(item_list.dump(0)); + } + return ret; + } + + [[nodiscard]] auto handle_winfsp_rename(packet *request) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + std::wstring file_name; + DECODE_OR_RETURN(request, file_name); + + std::wstring new_file_name; + DECODE_OR_RETURN(request, new_file_name); + + BOOLEAN replace_if_exists{}; + DECODE_OR_RETURN(request, replace_if_exists); + + ret = this->winfsp_rename(file_desc, file_name.data(), new_file_name.data(), + replace_if_exists); + return ret; + } + + [[nodiscard]] auto handle_winfsp_set_basic_info(packet *request, + packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + UINT32 attributes{}; + DECODE_OR_RETURN(request, attributes); + + UINT64 creation_time{}; + DECODE_OR_RETURN(request, creation_time); + + UINT64 last_access_time{}; + DECODE_OR_RETURN(request, last_access_time); + + UINT64 last_write_time{}; + DECODE_OR_RETURN(request, last_write_time); + + UINT64 change_time{}; + DECODE_OR_RETURN(request, change_time); + + remote::file_info file_info{}; + ret = this->winfsp_set_basic_info(file_desc, attributes, creation_time, + last_access_time, last_write_time, + change_time, &file_info); + if (ret == STATUS_SUCCESS) { + response.encode(file_info); + } + return ret; + } + + [[nodiscard]] auto handle_winfsp_set_file_size(packet *request, + packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + UINT64 new_size{}; + DECODE_OR_RETURN(request, new_size); + + BOOLEAN set_allocation_size{}; + DECODE_OR_RETURN(request, set_allocation_size); + + remote::file_info file_info{}; + ret = this->winfsp_set_file_size(file_desc, new_size, set_allocation_size, + &file_info); + if (ret == STATUS_SUCCESS) { + response.encode(file_info); + } + return ret; + } + + [[nodiscard]] auto handle_winfsp_unmounted(packet *request) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + std::wstring location; + DECODE_OR_RETURN(request, location); + + return this->winfsp_unmounted(location); + } + + [[nodiscard]] auto handle_winfsp_write(packet *request, packet &response) + -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); + + HANDLE file_desc{}; + DECODE_OR_RETURN(request, file_desc); + + UINT32 length{}; + DECODE_OR_RETURN(request, length); + + UINT64 offset{}; + DECODE_OR_RETURN(request, offset); + + BOOLEAN write_to_end{}; + DECODE_OR_RETURN(request, write_to_end); + + BOOLEAN constrained_io{}; + DECODE_OR_RETURN(request, constrained_io); + + auto *buffer = request->current_pointer(); + + UINT32 bytes_transferred{0U}; + remote::file_info file_info{}; + ret = this->winfsp_write(file_desc, buffer, offset, length, write_to_end, + constrained_io, &bytes_transferred, &file_info); + if (ret == STATUS_SUCCESS) { + response.encode(bytes_transferred); + response.encode(file_info); + } + return ret; + } + void message_handler(std::uint32_t service_flags, const std::string &client_id, std::uint64_t thread_id, const std::string &method, packet *request, packet &response, packet_server::message_complete_callback message_complete) { - const auto idx = method.find_last_of("::"); - const auto lookup_method_name = - ((idx == std::string::npos) ? "::" + method : method.substr(idx - 1)); + auto idx{method.find_last_of("::")}; + auto lookup_method_name{ + ((idx == std::string::npos) ? "::" + method : method.substr(idx - 1)), + }; if (handler_lookup_.find(lookup_method_name) == handler_lookup_.end()) { message_complete(static_cast(STATUS_NOT_IMPLEMENTED)); - } else { - client_pool_.execute( - client_id, thread_id, - [this, lookup_method_name, service_flags, client_id, thread_id, - method, request, &response]() -> packet::error_type { - return this->handler_lookup_[lookup_method_name]( - service_flags, client_id, thread_id, method, request, response); - }, - message_complete); + return; } + + client_pool_.execute( + client_id, thread_id, + [this, lookup_method_name, service_flags, client_id, thread_id, method, + request, &response]() -> packet::error_type { + return this->handler_lookup_.at(lookup_method_name)( + service_flags, client_id, thread_id, method, request, response); + }, + message_complete); } protected: [[nodiscard]] auto construct_api_path(std::string path) -> std::string { - path = utils::path::create_api_path(path.substr(mount_location_.size())); - return path; + return utils::path::create_api_path(path.substr(mount_location_.size())); } }; } // namespace repertory #endif // REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_ + +/*handlerLookup_.insert({"::fuse_fallocate", + [this](std::uint32_t serviceFlags, const + std::string &client_id, std::uint64_t threadId, const std::string + &method, packet *request, packet &response) -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::int32_t mode; + DECODE_OR_RETURN(request, mode); + + remote::file_offset offset; + DECODE_OR_RETURN(request, offset); + + remote::file_offset length; + DECODE_OR_RETURN(request, length); + + remote::file_handle handle; + DECODE_OR_RETURN(request, handle); + + return this->fuse_fallocate(path.c_str(), mode, + offset, length, handle); + }});*/ +/*handlerLookup_.insert({"::fuse_getxattr", + [this](std::uint32_t serviceFlags, const +std::string &client_id, std::uint64_t threadId, const std::string +&method, packet *request, packet &response) -> packet::error_type { auto +ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::string name; + DECODE_OR_RETURN(request, name); + + remote::file_size size; + DECODE_OR_RETURN(request, size); + + return this->fuse_getxattr(path.c_str(), +&name[0], nullptr, size); + }}); +handlerLookup_.insert({"::fuse_getxattr_osx", + [this](std::uint32_t serviceFlags, const +std::string &client_id, std::uint64_t threadId, const std::string +&method, packet *request, packet &response) -> packet::error_type { auto +ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::string name; + DECODE_OR_RETURN(request, name); + + remote::file_size size; + DECODE_OR_RETURN(request, size); + + std::uint32_t position; + DECODE_OR_RETURN(request, position); + + return this->fuse_getxattr_osx(path.c_str(), +&name[0], nullptr, size, position); + }});*/ +/*handlerLookup_.insert({"::remote_fuseListxattr", + [this](std::uint32_t serviceFlags, const + std::string &client_id, std::uint64_t threadId, const std::string + &method, packet *request, packet &response) -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + remote::file_size size; + DECODE_OR_RETURN(request, size); + + return this->fuse_listxattr(path.c_str(), + nullptr, size); + }});*/ +/*handlerLookup_.insert({"::fuse_removexattr", + [this](std::uint32_t serviceFlags, const + std::string &client_id, std::uint64_t threadId, const std::string + &method, packet *request, packet &response) -> packet::error_type { + auto ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::string name; + DECODE_OR_RETURN(request, name); + + return this->fuse_removexattr(path.c_str(), + &name[0]); + }});*/ +/*handlerLookup_.insert({"::fuse_setxattr", + [this](std::uint32_t serviceFlags, const +std::string &client_id, std::uint64_t threadId, const std::string +&method, packet *request, packet &response) -> packet::error_type { auto +ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::string name; + DECODE_OR_RETURN(request, name); + + remote::file_size size; + DECODE_OR_RETURN(request, size); + + if (size > +std::numeric_limits::max()) { return -ERANGE; + } + + data_buffer +value(static_cast(size)); ret = request->Decode(&value[0], +value.size()); if (ret == 0) { std::int32_t flags; + DECODE_OR_RETURN(request, flags); + + ret = this->fuse_setxattr(path.c_str(), +&name[0], &value[0], size, flags); + } + return ret; + }}); +handlerLookup_.insert({"::fuse_setxattr_osx", + [this](std::uint32_t serviceFlags, const +std::string &client_id, std::uint64_t threadId, const std::string +&method, packet *request, packet &response) -> packet::error_type { auto +ret{0}; + + std::string path; + DECODE_OR_RETURN(request, path); + + std::string name; + DECODE_OR_RETURN(request, name); + + remote::file_size size; + DECODE_OR_RETURN(request, size); + + if (size > +std::numeric_limits::max()) { return -ERANGE; + } + + data_buffer +value(static_cast(size)); ret = request->Decode(&value[0], +value.size()); if (ret == 0) { std::int32_t flags; + DECODE_OR_RETURN(request, flags); + + std::uint32_t position; + DECODE_OR_RETURN(request, position); + + ret = this->fuse_setxattr_osx(path.c_str(), +&name[0], &value[0], size, flags, position); + } + return ret; + }});*/ diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/i_remote_instance.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/i_remote_instance.hpp index 03c78ab5..819e0098 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/i_remote_instance.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/i_remote_instance.hpp @@ -29,87 +29,92 @@ class i_remote_instance : public virtual i_remote_json { INTERFACE_SETUP(i_remote_instance); public: - virtual auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) + [[nodiscard]] virtual auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) -> packet::error_type = 0; - virtual auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags, - BOOLEAN &was_deleted) -> packet::error_type = 0; - - virtual auto winfsp_close(PVOID file_desc) -> packet::error_type = 0; - - virtual auto winfsp_create(PWSTR file_name, UINT32 create_options, - UINT32 granted_access, UINT32 file_attributes, - UINT64 allocation_size, PVOID *file_desc, - remote::file_info *file_info, - std::string &normalized_name, BOOLEAN &exists) + [[nodiscard]] virtual auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, + UINT32 flags, BOOLEAN &was_deleted) -> packet::error_type = 0; - virtual auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) + [[nodiscard]] virtual auto winfsp_close(PVOID file_desc) -> packet::error_type = 0; - virtual auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) + [[nodiscard]] virtual auto + winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, + UINT32 file_attributes, UINT64 allocation_size, + PVOID *file_desc, remote::file_info *file_info, + std::string &normalized_name, BOOLEAN &exists) -> packet::error_type = 0; - virtual auto winfsp_get_file_info(PVOID file_desc, - remote::file_info *file_info) + [[nodiscard]] virtual auto winfsp_flush(PVOID file_desc, + remote::file_info *file_info) -> packet::error_type = 0; - virtual auto + [[nodiscard]] virtual auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) + -> packet::error_type = 0; + + [[nodiscard]] virtual auto winfsp_get_file_info(PVOID file_desc, + remote::file_info *file_info) + -> packet::error_type = 0; + + [[nodiscard]] virtual auto winfsp_get_security_by_name(PWSTR file_name, PUINT32 file_attributes, std::uint64_t *security_descriptor_size, std::wstring &str_descriptor) -> packet::error_type = 0; - virtual auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size, - std::string &volume_label) + [[nodiscard]] virtual auto winfsp_get_volume_info(UINT64 &total_size, + UINT64 &free_size, + std::string &volume_label) -> packet::error_type = 0; - virtual auto winfsp_mounted(const std::wstring &location) + [[nodiscard]] virtual auto winfsp_mounted(const std::wstring &location) -> packet::error_type = 0; - virtual auto winfsp_open(PWSTR file_name, UINT32 create_options, - UINT32 granted_access, PVOID *file_desc, - remote::file_info *file_info, - std::string &normalized_name) + [[nodiscard]] virtual 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 = 0; + + [[nodiscard]] virtual auto + winfsp_overwrite(PVOID file_desc, UINT32 file_attributes, + BOOLEAN replace_file_attributes, UINT64 allocation_size, + remote::file_info *file_info) -> packet::error_type = 0; + + [[nodiscard]] virtual auto winfsp_read(PVOID file_desc, PVOID buffer, + UINT64 offset, UINT32 length, + PUINT32 bytes_transferred) -> packet::error_type = 0; - virtual auto winfsp_overwrite(PVOID file_desc, UINT32 file_attributes, - BOOLEAN replace_file_attributes, - UINT64 allocation_size, - remote::file_info *file_info) + [[nodiscard]] virtual auto winfsp_read_directory(PVOID file_desc, + PWSTR pattern, PWSTR marker, + json &itemList) -> packet::error_type = 0; - virtual auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, - UINT32 length, PUINT32 bytes_transferred) + [[nodiscard]] virtual auto winfsp_rename(PVOID file_desc, PWSTR file_name, + PWSTR new_file_name, + BOOLEAN replace_if_exists) -> packet::error_type = 0; - virtual auto winfsp_read_directory(PVOID file_desc, PWSTR pattern, - PWSTR marker, json &itemList) + [[nodiscard]] virtual auto + winfsp_set_basic_info(PVOID file_desc, UINT32 file_attributes, + UINT64 creation_time, UINT64 last_access_time, + UINT64 last_write_time, UINT64 change_time, + remote::file_info *file_info) -> packet::error_type = 0; + + [[nodiscard]] virtual auto winfsp_set_file_size(PVOID file_desc, + UINT64 new_size, + BOOLEAN set_allocation_size, + remote::file_info *file_info) -> packet::error_type = 0; - virtual auto winfsp_rename(PVOID file_desc, PWSTR file_name, - PWSTR new_file_name, BOOLEAN replace_if_exists) + [[nodiscard]] virtual auto winfsp_unmounted(const std::wstring &location) -> packet::error_type = 0; - virtual auto winfsp_set_basic_info(PVOID file_desc, UINT32 file_attributes, - UINT64 creation_time, - UINT64 last_access_time, - UINT64 last_write_time, UINT64 change_time, - remote::file_info *file_info) - -> packet::error_type = 0; - - virtual auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, - remote::file_info *file_info) - -> packet::error_type = 0; - - virtual auto winfsp_unmounted(const std::wstring &location) - -> packet::error_type = 0; - - virtual 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) + [[nodiscard]] virtual 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 = 0; }; diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp index a8a8f7b6..15c858ae 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_client.hpp @@ -44,93 +44,105 @@ private: #if defined(_WIN32) #define to_handle(x) (x) #else // !defined(_WIN32) - static auto to_handle(PVOID file_desc) -> native_handle; + [[nodiscard]] static auto to_handle(PVOID file_desc) -> native_handle; #endif // defined(_WIN32) public: - auto json_create_directory_snapshot(const std::string &path, json &json_data) + [[nodiscard]] auto check() -> packet::error_type; + + [[nodiscard]] 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) + [[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; - auto json_release_directory_snapshot(const std::string &path, - const remote::file_handle &handle) + [[nodiscard]] auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) -> packet::error_type override; - auto winfsp_can_delete(PVOID file_desc, PWSTR file_name) + [[nodiscard]] auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, + UINT32 flags, BOOLEAN &was_deleted) -> packet::error_type override; - auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags, - BOOLEAN &was_deleted) -> packet::error_type override; - - auto winfsp_close(PVOID file_desc) -> packet::error_type override; - - auto 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 override; - - auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) + [[nodiscard]] auto winfsp_close(PVOID file_desc) -> packet::error_type override; - auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) + [[nodiscard]] auto + 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 override; + + [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) -> packet::error_type override; - auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info) + [[nodiscard]] auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) -> packet::error_type override; - auto winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes, - std::uint64_t *descriptor_size, - std::wstring &string_descriptor) + [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, + remote::file_info *file_info) -> packet::error_type override; - auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size, - std::string &volume_label) + [[nodiscard]] auto winfsp_get_security_by_name( + PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size, + std::wstring &string_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; - auto winfsp_mounted(const std::wstring &location) + [[nodiscard]] 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) + [[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; - auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, - BOOLEAN replace_attributes, UINT64 allocation_size, - remote::file_info *file_info) + [[nodiscard]] 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; - - auto winfsp_read_directory(PVOID file_desc, PWSTR pattern, PWSTR marker, - json &itemList) -> packet::error_type override; - - 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) + [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, + UINT32 length, PUINT32 bytes_transferred) -> packet::error_type override; - auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, - remote::file_info *file_info) + [[nodiscard]] auto winfsp_read_directory(PVOID file_desc, PWSTR pattern, + PWSTR marker, json &itemList) -> packet::error_type override; - auto winfsp_unmounted(const std::wstring &location) + [[nodiscard]] auto winfsp_rename(PVOID file_desc, PWSTR file_name, + PWSTR new_file_name, + BOOLEAN replace_if_exists) -> 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) + [[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_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; }; } // namespace remote_winfsp diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp index 8665277c..7ff71b42 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_server.hpp @@ -58,41 +58,46 @@ private: public: // FUSE Layer - auto fuse_access(const char *path, const std::int32_t &mask) + [[nodiscard]] 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) + [[nodiscard]] 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) + [[nodiscard]] 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; + [[nodiscard]] auto fuse_chown(const char *path, const remote::user_id &uid, + const remote::group_id &gid) + -> packet::error_type override; - auto fuse_destroy() -> packet::error_type override; + [[nodiscard]] auto fuse_destroy() -> packet::error_type override; /*packet::error_type fuse_fallocate(const char *path, const std::int32_t &mode, const remote::file_offset &offset, const remote::file_offset &length, const remote::file_handle &handle) override ;*/ - auto fuse_fgetattr(const char *path, remote::stat &r_stat, bool &directory, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_fgetattr(const char *path, remote::stat &r_stat, + bool &directory, + const remote::file_handle &handle) -> packet::error_type override; - auto fuse_fsetattr_x(const char *path, const remote::setattr_x &attr, - const remote::file_handle &handle) + [[nodiscard]] auto fuse_fsetattr_x(const char *path, + const remote::setattr_x &attr, + 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) + [[nodiscard]] 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) + [[nodiscard]] 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) + [[nodiscard]] 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 @@ -101,77 +106,90 @@ public: packet::error_type fuse_getxattrOSX(const char *path, const char *name, char *value, const remote::file_size &size, std::uint32_t position) override ;*/ - 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; - auto fuse_init() -> packet::error_type override; + [[nodiscard]] auto fuse_init() -> packet::error_type override; /*packet::error_type fuse_listxattr(const char *path, char *buffer, const remote::file_size &size) override ;*/ - auto fuse_mkdir(const char *path, const remote::file_mode &mode) + [[nodiscard]] 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) + [[nodiscard]] 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) + [[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; - 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) + [[nodiscard]] auto fuse_open(const char *path, + const remote::open_flags &flags, + remote::file_handle &handle) -> packet::error_type override; - auto fuse_rename(const char *from, const char *to) + [[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; - 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) + [[nodiscard]] auto fuse_rename(const char *from, const char *to) -> 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) + [[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; - auto fuse_readdir(const char *path, const remote::file_offset &offset, - const remote::file_handle &handle, std::string &item_path) + [[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; - auto fuse_release(const char *path, const remote::file_handle &handle) + [[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; - auto fuse_releasedir(const char *path, const remote::file_handle &handle) + [[nodiscard]] auto fuse_release(const char *path, + const remote::file_handle &handle) + -> packet::error_type override; + + [[nodiscard]] auto fuse_releasedir(const char *path, + const remote::file_handle &handle) -> packet::error_type override; /*packet::error_type fuse_removexattr(const char *path, const char *name) * override ;*/ - auto fuse_rmdir(const char *path) -> packet::error_type override; - - auto fuse_setattr_x(const char *path, remote::setattr_x &attr) + [[nodiscard]] auto fuse_rmdir(const char *path) -> packet::error_type override; - auto fuse_setbkuptime(const char *path, const remote::file_time &bkuptime) + [[nodiscard]] auto fuse_setattr_x(const char *path, remote::setattr_x &attr) -> packet::error_type override; - auto fuse_setchgtime(const char *path, const remote::file_time &chgtime) + [[nodiscard]] auto fuse_setbkuptime(const char *path, + const remote::file_time &bkuptime) -> packet::error_type override; - auto fuse_setcrtime(const char *path, const remote::file_time &crtime) + [[nodiscard]] auto fuse_setchgtime(const char *path, + const remote::file_time &chgtime) -> packet::error_type override; - auto fuse_setvolname(const char *volname) -> packet::error_type override; + [[nodiscard]] auto fuse_setcrtime(const char *path, + const remote::file_time &crtime) + -> packet::error_type override; + + [[nodiscard]] auto fuse_setvolname(const char *volname) + -> packet::error_type override; /*packet::error_type fuse_setxattr(const char *path, const char *name, const char *value, const remote::file_size &size, const std::int32_t &flags) @@ -181,109 +199,123 @@ public: char *value, const remote::file_size &size, const std::int32_t &flags, std::uint32_t position) override ;*/ - auto fuse_statfs(const char *path, std::uint64_t frsize, - remote::statfs &r_stat) -> packet::error_type override; - - auto fuse_statfs_x(const char *path, std::uint64_t bsize, - remote::statfs_x &r_stat) -> packet::error_type override; - - auto fuse_truncate(const char *path, const remote::file_offset &size) + [[nodiscard]] auto fuse_statfs(const char *path, std::uint64_t frsize, + remote::statfs &r_stat) -> packet::error_type override; - auto fuse_unlink(const char *path) -> 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; - auto fuse_utimens(const char *path, const remote::file_time *tv, - std::uint64_t op0, std::uint64_t op1) + [[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_utimens(const char *path, const remote::file_time *tv, + 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 {} // JSON Layer - auto json_create_directory_snapshot(const std::string &path, json &json_data) + [[nodiscard]] 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; + [[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; - auto json_release_directory_snapshot(const std::string &path, - const remote::file_handle &handle) + [[nodiscard]] 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) + [[nodiscard]] 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_deleted) -> packet::error_type override; - - auto winfsp_close(PVOID file_desc) -> packet::error_type override; - - auto 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 override; - - auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) + [[nodiscard]] auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, + UINT32 flags, BOOLEAN &was_deleted) -> packet::error_type override; - auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) + [[nodiscard]] auto winfsp_close(PVOID file_desc) -> packet::error_type override; - auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info) + [[nodiscard]] auto + 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 override; + + [[nodiscard]] auto winfsp_flush(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) + [[nodiscard]] auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) -> packet::error_type override; - auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size, - std::string &volume_label) + [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, + remote::file_info *file_info) -> packet::error_type override; - auto winfsp_mounted(const std::wstring &location) + [[nodiscard]] auto winfsp_get_security_by_name( + PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size, + std::wstring &string_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; - auto winfsp_open(PWSTR file_name, UINT32 create_options, - UINT32 granted_access, PVOID *file_desc, - remote::file_info *file_info, std::string &normalized_name) + [[nodiscard]] auto winfsp_mounted(const std::wstring &location) -> packet::error_type override; - auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, - BOOLEAN replace_attributes, UINT64 allocation_size, - remote::file_info *file_info) + [[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; - auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, - PUINT32 bytes_transferred) -> packet::error_type override; - - auto winfsp_read_directory(PVOID file_desc, PWSTR pattern, PWSTR marker, - json &item_list) -> packet::error_type override; - - 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) + [[nodiscard]] 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_set_file_size(PVOID file_desc, UINT64 new_size, - BOOLEAN set_allocation_size, - remote::file_info *file_info) + [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, + UINT32 length, PUINT32 bytes_transferred) -> packet::error_type override; - auto winfsp_unmounted(const std::wstring &location) + [[nodiscard]] auto winfsp_read_directory(PVOID file_desc, PWSTR pattern, + PWSTR marker, json &item_list) -> 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) + [[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_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; }; } // namespace remote_winfsp diff --git a/repertory/librepertory/include/events/consumers/logging_consumer.hpp b/repertory/librepertory/include/events/consumers/logging_consumer.hpp index 603f2ea1..d5750fd2 100644 --- a/repertory/librepertory/include/events/consumers/logging_consumer.hpp +++ b/repertory/librepertory/include/events/consumers/logging_consumer.hpp @@ -35,9 +35,8 @@ public: ~logging_consumer(); private: - static constexpr const std::uint8_t MAX_LOG_FILES{5U}; - static constexpr const std::uint64_t MAX_LOG_FILE_SIZE{1024ULL * 1024ULL * - 5ULL}; + static constexpr std::uint8_t MAX_LOG_FILES{5U}; + static constexpr std::uint64_t MAX_LOG_FILE_SIZE{1024ULL * 1024ULL * 5ULL}; private: static void process_event(const i_event &evt); diff --git a/repertory/librepertory/include/events/event_system.hpp b/repertory/librepertory/include/events/event_system.hpp index cefdfe14..53686257 100644 --- a/repertory/librepertory/include/events/event_system.hpp +++ b/repertory/librepertory/include/events/event_system.hpp @@ -27,7 +27,7 @@ class i_event; class event_system final { private: - static constexpr const std::uint8_t max_queue_retry{ + static constexpr std::uint8_t max_queue_retry{ 30U, }; @@ -35,7 +35,7 @@ private: std::thread::hardware_concurrency() * 4U, }; - static constexpr const std::chrono::seconds queue_wait_secs{ + static constexpr std::chrono::seconds queue_wait_secs{ 5s, }; diff --git a/repertory/librepertory/include/events/types/curl_error.hpp b/repertory/librepertory/include/events/types/curl_error.hpp index 6d6a547e..a255fd59 100644 --- a/repertory/librepertory/include/events/types/curl_error.hpp +++ b/repertory/librepertory/include/events/types/curl_error.hpp @@ -28,16 +28,19 @@ namespace repertory { struct curl_error final : public i_event { curl_error() = default; - curl_error(CURLcode code_, std::string_view function_name_, std::string url_) + curl_error(CURLcode code_, std::string_view function_name_, std::string type_, + std::string url_) : code(code_), function_name(std::string{function_name_}), + type(std::move(type_)), url(std::move(url_)) {} - static constexpr const event_level level{event_level::error}; - static constexpr const std::string_view name{"curl_error"}; + static constexpr event_level level{event_level::error}; + static constexpr std::string_view name{"curl_error"}; CURLcode code{}; std::string function_name; + std::string type; std::string url; [[nodiscard]] auto get_event_level() const -> event_level override { @@ -49,8 +52,8 @@ struct curl_error final : public i_event { } [[nodiscard]] auto get_single_line() const -> std::string override { - return fmt::format("{}|func|{}|url|{}|code|{}", name, function_name, url, - static_cast(code)); + return fmt::format("{}|func|{}|type|{}|url|{}|code|{}", name, function_name, + type, url, static_cast(code)); } }; } // namespace repertory @@ -60,12 +63,14 @@ template <> struct adl_serializer { static void to_json(json &data, const repertory::curl_error &value) { data["code"] = value.code; data["function_name"] = value.function_name; + data["type"] = value.type; data["url"] = value.url; } static void from_json(const json &data, repertory::curl_error &value) { data.at("code").get_to(value.code); data.at("function_name").get_to(value.function_name); + data.at("type").get_to(value.type); data.at("url").get_to(value.url); } }; diff --git a/repertory/librepertory/include/events/types/debug_log.hpp b/repertory/librepertory/include/events/types/debug_log.hpp index a5a29da7..2642d003 100644 --- a/repertory/librepertory/include/events/types/debug_log.hpp +++ b/repertory/librepertory/include/events/types/debug_log.hpp @@ -31,8 +31,8 @@ struct debug_log final : public i_event { debug_log(std::string_view function_name_, std::string msg_) : function_name(std::string(function_name_)), msg(std::move(msg_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"debug_log"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"debug_log"}; std::string function_name; std::string msg; diff --git a/repertory/librepertory/include/events/types/directory_remove_failed.hpp b/repertory/librepertory/include/events/types/directory_remove_failed.hpp index b79316e2..a044ed75 100644 --- a/repertory/librepertory/include/events/types/directory_remove_failed.hpp +++ b/repertory/librepertory/include/events/types/directory_remove_failed.hpp @@ -34,8 +34,8 @@ struct directory_remove_failed final : public i_event { error(error_), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::error}; - static constexpr const std::string_view name{"directory_remove_failed"}; + static constexpr event_level level{event_level::error}; + static constexpr std::string_view name{"directory_remove_failed"}; std::string api_path; api_error error{}; diff --git a/repertory/librepertory/include/events/types/directory_removed.hpp b/repertory/librepertory/include/events/types/directory_removed.hpp index 862d87fa..922e7047 100644 --- a/repertory/librepertory/include/events/types/directory_removed.hpp +++ b/repertory/librepertory/include/events/types/directory_removed.hpp @@ -32,8 +32,8 @@ struct directory_removed final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"directory_removed"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"directory_removed"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/directory_removed_externally.hpp b/repertory/librepertory/include/events/types/directory_removed_externally.hpp index 483e376d..95b87ae7 100644 --- a/repertory/librepertory/include/events/types/directory_removed_externally.hpp +++ b/repertory/librepertory/include/events/types/directory_removed_externally.hpp @@ -35,8 +35,8 @@ struct directory_removed_externally final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"directory_removed_externally"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"directory_removed_externally"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/download_begin.hpp b/repertory/librepertory/include/events/types/download_begin.hpp index 26be0adf..0fa3d3dd 100644 --- a/repertory/librepertory/include/events/types/download_begin.hpp +++ b/repertory/librepertory/include/events/types/download_begin.hpp @@ -34,8 +34,8 @@ struct download_begin final : public i_event { dest_path(std::move(dest_path_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"download_begin"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"download_begin"}; std::string api_path; std::string dest_path; diff --git a/repertory/librepertory/include/events/types/download_end.hpp b/repertory/librepertory/include/events/types/download_end.hpp index ac74e33e..e4cebe2d 100644 --- a/repertory/librepertory/include/events/types/download_end.hpp +++ b/repertory/librepertory/include/events/types/download_end.hpp @@ -35,8 +35,8 @@ struct download_end final : public i_event { error(error_), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"download_end"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"download_end"}; std::string api_path; std::string dest_path; diff --git a/repertory/librepertory/include/events/types/download_progress.hpp b/repertory/librepertory/include/events/types/download_progress.hpp index 289cf6fb..1361ef19 100644 --- a/repertory/librepertory/include/events/types/download_progress.hpp +++ b/repertory/librepertory/include/events/types/download_progress.hpp @@ -35,8 +35,8 @@ struct download_progress final : public i_event { function_name(std::string(function_name_)), progress(progress_) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"download_progress"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"download_progress"}; std::string api_path; std::string dest_path; diff --git a/repertory/librepertory/include/events/types/download_restore_failed.hpp b/repertory/librepertory/include/events/types/download_restore_failed.hpp index f75b6b59..2c834967 100644 --- a/repertory/librepertory/include/events/types/download_restore_failed.hpp +++ b/repertory/librepertory/include/events/types/download_restore_failed.hpp @@ -35,8 +35,8 @@ struct download_restore_failed final : public i_event { error(std::move(error_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::error}; - static constexpr const std::string_view name{"download_restore_failed"}; + static constexpr event_level level{event_level::error}; + static constexpr std::string_view name{"download_restore_failed"}; std::string api_path; std::string dest_path; diff --git a/repertory/librepertory/include/events/types/download_restored.hpp b/repertory/librepertory/include/events/types/download_restored.hpp index cfe17445..67536cf4 100644 --- a/repertory/librepertory/include/events/types/download_restored.hpp +++ b/repertory/librepertory/include/events/types/download_restored.hpp @@ -34,8 +34,8 @@ struct download_restored final : public i_event { dest_path(std::move(dest_path_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"download_restored"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"download_restored"}; std::string api_path; std::string dest_path; diff --git a/repertory/librepertory/include/events/types/download_resume_add_failed.hpp b/repertory/librepertory/include/events/types/download_resume_add_failed.hpp index 6c044109..7741caa6 100644 --- a/repertory/librepertory/include/events/types/download_resume_add_failed.hpp +++ b/repertory/librepertory/include/events/types/download_resume_add_failed.hpp @@ -36,8 +36,8 @@ struct download_resume_add_failed final : public i_event { error(std::move(error_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::error}; - static constexpr const std::string_view name{"download_resume_add_failed"}; + static constexpr event_level level{event_level::error}; + static constexpr std::string_view name{"download_resume_add_failed"}; std::string api_path; std::string dest_path; diff --git a/repertory/librepertory/include/events/types/download_resume_added.hpp b/repertory/librepertory/include/events/types/download_resume_added.hpp index 054e3f1e..a2935079 100644 --- a/repertory/librepertory/include/events/types/download_resume_added.hpp +++ b/repertory/librepertory/include/events/types/download_resume_added.hpp @@ -34,8 +34,8 @@ struct download_resume_added final : public i_event { dest_path(std::move(dest_path_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"download_resume_added"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"download_resume_added"}; std::string api_path; std::string dest_path; diff --git a/repertory/librepertory/include/events/types/download_resume_removed.hpp b/repertory/librepertory/include/events/types/download_resume_removed.hpp index f90f2df1..0ea3c0d9 100644 --- a/repertory/librepertory/include/events/types/download_resume_removed.hpp +++ b/repertory/librepertory/include/events/types/download_resume_removed.hpp @@ -34,8 +34,8 @@ struct download_resume_removed final : public i_event { dest_path(std::move(dest_path_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"download_resume_removed"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"download_resume_removed"}; std::string api_path; std::string dest_path; diff --git a/repertory/librepertory/include/events/types/download_type_selected.hpp b/repertory/librepertory/include/events/types/download_type_selected.hpp index 56cad897..92d15978 100644 --- a/repertory/librepertory/include/events/types/download_type_selected.hpp +++ b/repertory/librepertory/include/events/types/download_type_selected.hpp @@ -35,8 +35,8 @@ struct download_type_selected final : public i_event { function_name(std::string(function_name_)), type(type_) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"download_type_selected"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"download_type_selected"}; std::string api_path; std::string dest_path; diff --git a/repertory/librepertory/include/events/types/drive_mount_failed.hpp b/repertory/librepertory/include/events/types/drive_mount_failed.hpp index 90a8f8dd..ad76e9e0 100644 --- a/repertory/librepertory/include/events/types/drive_mount_failed.hpp +++ b/repertory/librepertory/include/events/types/drive_mount_failed.hpp @@ -35,8 +35,8 @@ struct drive_mount_failed final : public i_event { function_name(std::string(function_name_)), mount_location(std::move(mount_location_)) {} - static constexpr const event_level level{event_level::error}; - static constexpr const std::string_view name{"drive_mount_failed"}; + static constexpr event_level level{event_level::error}; + static constexpr std::string_view name{"drive_mount_failed"}; NTSTATUS error{}; std::string function_name; diff --git a/repertory/librepertory/include/events/types/drive_mount_result.hpp b/repertory/librepertory/include/events/types/drive_mount_result.hpp index 5c240d77..ada57745 100644 --- a/repertory/librepertory/include/events/types/drive_mount_result.hpp +++ b/repertory/librepertory/include/events/types/drive_mount_result.hpp @@ -34,8 +34,8 @@ struct drive_mount_result final : public i_event { mount_location(std::move(mount_location_)), result(std::move(result_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"drive_mount_result"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"drive_mount_result"}; std::string function_name; std::string mount_location; diff --git a/repertory/librepertory/include/events/types/drive_mounted.hpp b/repertory/librepertory/include/events/types/drive_mounted.hpp index 44b5a157..67c7c07d 100644 --- a/repertory/librepertory/include/events/types/drive_mounted.hpp +++ b/repertory/librepertory/include/events/types/drive_mounted.hpp @@ -32,8 +32,8 @@ struct drive_mounted final : public i_event { : function_name(std::string(function_name_)), mount_location(std::move(mount_location_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"drive_mounted"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"drive_mounted"}; std::string function_name; std::string mount_location; diff --git a/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp b/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp index fb50eb62..4f54f7e1 100644 --- a/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp +++ b/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp @@ -31,8 +31,8 @@ struct drive_stop_timed_out final : public i_event { drive_stop_timed_out(std::string_view function_name_) : function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"drive_stop_timed_out"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"drive_stop_timed_out"}; std::string function_name; diff --git a/repertory/librepertory/include/events/types/drive_unmount_pending.hpp b/repertory/librepertory/include/events/types/drive_unmount_pending.hpp index f0d0c82b..75162598 100644 --- a/repertory/librepertory/include/events/types/drive_unmount_pending.hpp +++ b/repertory/librepertory/include/events/types/drive_unmount_pending.hpp @@ -33,8 +33,8 @@ struct drive_unmount_pending final : public i_event { : function_name(std::string(function_name_)), mount_location(std::move(mount_location_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"drive_unmount_pending"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"drive_unmount_pending"}; std::string function_name; std::string mount_location; diff --git a/repertory/librepertory/include/events/types/drive_unmounted.hpp b/repertory/librepertory/include/events/types/drive_unmounted.hpp index 8ae128a3..e9d69aad 100644 --- a/repertory/librepertory/include/events/types/drive_unmounted.hpp +++ b/repertory/librepertory/include/events/types/drive_unmounted.hpp @@ -32,8 +32,8 @@ struct drive_unmounted final : public i_event { : function_name(std::string(function_name_)), mount_location(std::move(mount_location_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"drive_unmounted"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"drive_unmounted"}; std::string function_name; std::string mount_location; diff --git a/repertory/librepertory/include/events/types/event_level_changed.hpp b/repertory/librepertory/include/events/types/event_level_changed.hpp index 4ebac75e..aca9122b 100644 --- a/repertory/librepertory/include/events/types/event_level_changed.hpp +++ b/repertory/librepertory/include/events/types/event_level_changed.hpp @@ -31,8 +31,8 @@ struct event_level_changed final : public i_event { event_level_changed(std::string_view function_name_, event_level new_level_) : function_name(std::string(function_name_)), new_level(new_level_) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"event_level_changed"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"event_level_changed"}; std::string function_name; event_level new_level{}; diff --git a/repertory/librepertory/include/events/types/file_pinned.hpp b/repertory/librepertory/include/events/types/file_pinned.hpp index 5551c54d..fdc742a8 100644 --- a/repertory/librepertory/include/events/types/file_pinned.hpp +++ b/repertory/librepertory/include/events/types/file_pinned.hpp @@ -32,8 +32,8 @@ struct file_pinned final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"file_pinned"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"file_pinned"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/file_remove_failed.hpp b/repertory/librepertory/include/events/types/file_remove_failed.hpp index ecf7a8c7..37c2c6f3 100644 --- a/repertory/librepertory/include/events/types/file_remove_failed.hpp +++ b/repertory/librepertory/include/events/types/file_remove_failed.hpp @@ -34,8 +34,8 @@ struct file_remove_failed final : public i_event { error(error_), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::error}; - static constexpr const std::string_view name{"file_remove_failed"}; + static constexpr event_level level{event_level::error}; + static constexpr std::string_view name{"file_remove_failed"}; std::string api_path; api_error error{}; diff --git a/repertory/librepertory/include/events/types/file_removed.hpp b/repertory/librepertory/include/events/types/file_removed.hpp index 081587ae..b1156b8b 100644 --- a/repertory/librepertory/include/events/types/file_removed.hpp +++ b/repertory/librepertory/include/events/types/file_removed.hpp @@ -32,8 +32,8 @@ struct file_removed final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"file_removed"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"file_removed"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/file_removed_externally.hpp b/repertory/librepertory/include/events/types/file_removed_externally.hpp index 854f927c..079f3110 100644 --- a/repertory/librepertory/include/events/types/file_removed_externally.hpp +++ b/repertory/librepertory/include/events/types/file_removed_externally.hpp @@ -35,8 +35,8 @@ struct file_removed_externally final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"file_removed_externally"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"file_removed_externally"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/file_unpinned.hpp b/repertory/librepertory/include/events/types/file_unpinned.hpp index 2675a805..eb3b629f 100644 --- a/repertory/librepertory/include/events/types/file_unpinned.hpp +++ b/repertory/librepertory/include/events/types/file_unpinned.hpp @@ -32,8 +32,8 @@ struct file_unpinned final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"file_unpinned"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"file_unpinned"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/file_upload_completed.hpp b/repertory/librepertory/include/events/types/file_upload_completed.hpp index 2e8fb101..3ecb7766 100644 --- a/repertory/librepertory/include/events/types/file_upload_completed.hpp +++ b/repertory/librepertory/include/events/types/file_upload_completed.hpp @@ -37,8 +37,8 @@ struct file_upload_completed final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"file_upload_completed"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"file_upload_completed"}; std::string api_path; bool cancelled{}; diff --git a/repertory/librepertory/include/events/types/file_upload_failed.hpp b/repertory/librepertory/include/events/types/file_upload_failed.hpp index d7232f5b..93800b8c 100644 --- a/repertory/librepertory/include/events/types/file_upload_failed.hpp +++ b/repertory/librepertory/include/events/types/file_upload_failed.hpp @@ -35,8 +35,8 @@ struct file_upload_failed final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"file_upload_failed"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"file_upload_failed"}; std::string api_path; std::string error; diff --git a/repertory/librepertory/include/events/types/file_upload_not_found.hpp b/repertory/librepertory/include/events/types/file_upload_not_found.hpp index 90c42ed4..1b74330e 100644 --- a/repertory/librepertory/include/events/types/file_upload_not_found.hpp +++ b/repertory/librepertory/include/events/types/file_upload_not_found.hpp @@ -34,8 +34,8 @@ struct file_upload_not_found final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"file_upload_not_found"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"file_upload_not_found"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/file_upload_queued.hpp b/repertory/librepertory/include/events/types/file_upload_queued.hpp index efa3adae..41949302 100644 --- a/repertory/librepertory/include/events/types/file_upload_queued.hpp +++ b/repertory/librepertory/include/events/types/file_upload_queued.hpp @@ -34,8 +34,8 @@ struct file_upload_queued final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"file_upload_queued"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"file_upload_queued"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/file_upload_removed.hpp b/repertory/librepertory/include/events/types/file_upload_removed.hpp index e1b60dfd..04ba865e 100644 --- a/repertory/librepertory/include/events/types/file_upload_removed.hpp +++ b/repertory/librepertory/include/events/types/file_upload_removed.hpp @@ -32,8 +32,8 @@ struct file_upload_removed final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"file_upload_removed"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"file_upload_removed"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/file_upload_retry.hpp b/repertory/librepertory/include/events/types/file_upload_retry.hpp index 50514b42..7296a364 100644 --- a/repertory/librepertory/include/events/types/file_upload_retry.hpp +++ b/repertory/librepertory/include/events/types/file_upload_retry.hpp @@ -35,8 +35,8 @@ struct file_upload_retry final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"file_upload_retry"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"file_upload_retry"}; std::string api_path; api_error error{}; diff --git a/repertory/librepertory/include/events/types/filesystem_item_added.hpp b/repertory/librepertory/include/events/types/filesystem_item_added.hpp index 1b77df57..853da92b 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_added.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_added.hpp @@ -35,8 +35,8 @@ struct filesystem_item_added final : public i_event { directory(directory_), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"filesystem_item_added"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"filesystem_item_added"}; std::string api_parent; std::string api_path; diff --git a/repertory/librepertory/include/events/types/filesystem_item_closed.hpp b/repertory/librepertory/include/events/types/filesystem_item_closed.hpp index 22083891..b5d1340c 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_closed.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_closed.hpp @@ -37,8 +37,8 @@ struct filesystem_item_closed final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::trace}; - static constexpr const std::string_view name{"filesystem_item_closed"}; + static constexpr event_level level{event_level::trace}; + static constexpr std::string_view name{"filesystem_item_closed"}; std::string api_path; bool changed{}; diff --git a/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp b/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp index c58bbace..5821d896 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp @@ -35,8 +35,8 @@ struct filesystem_item_evicted final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"filesystem_item_evicted"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"filesystem_item_evicted"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp b/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp index 8930b19b..b84627d9 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp @@ -39,8 +39,8 @@ struct filesystem_item_handle_closed final : public i_event { handle(handle_), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::trace}; - static constexpr const std::string_view name{"filesystem_item_handle_closed"}; + static constexpr event_level level{event_level::trace}; + static constexpr std::string_view name{"filesystem_item_handle_closed"}; std::string api_path; bool changed{}; diff --git a/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp b/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp index e61d6539..0ea6f0ad 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp @@ -37,8 +37,8 @@ struct filesystem_item_handle_opened final : public i_event { handle(handle_), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::trace}; - static constexpr const std::string_view name{"filesystem_item_handle_opened"}; + static constexpr event_level level{event_level::trace}; + static constexpr std::string_view name{"filesystem_item_handle_opened"}; std::string api_path; bool directory{}; diff --git a/repertory/librepertory/include/events/types/filesystem_item_opened.hpp b/repertory/librepertory/include/events/types/filesystem_item_opened.hpp index b9f508d4..5d19f839 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_opened.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_opened.hpp @@ -36,8 +36,8 @@ struct filesystem_item_opened final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::trace}; - static constexpr const std::string_view name{"filesystem_item_opened"}; + static constexpr event_level level{event_level::trace}; + static constexpr std::string_view name{"filesystem_item_opened"}; std::string api_path; bool directory{}; diff --git a/repertory/librepertory/include/events/types/fuse_args_parsed.hpp b/repertory/librepertory/include/events/types/fuse_args_parsed.hpp index c38a71c2..795bf4e5 100644 --- a/repertory/librepertory/include/events/types/fuse_args_parsed.hpp +++ b/repertory/librepertory/include/events/types/fuse_args_parsed.hpp @@ -32,8 +32,8 @@ struct fuse_args_parsed final : public i_event { fuse_args_parsed(std::string_view args_, std::string_view function_name_) : args(std::move(args_)), function_name(std::string{function_name_}) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"fuse_args_parsed"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"fuse_args_parsed"}; std::string args; std::string function_name; diff --git a/repertory/librepertory/include/events/types/fuse_event.hpp b/repertory/librepertory/include/events/types/fuse_event.hpp index 5f50c7fa..a1f717ce 100644 --- a/repertory/librepertory/include/events/types/fuse_event.hpp +++ b/repertory/librepertory/include/events/types/fuse_event.hpp @@ -35,8 +35,8 @@ struct fuse_event final : public i_event { error(error_), function_name(std::string{function_name_}) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"fuse_event"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"fuse_event"}; std::string api_path; std::int32_t error{}; diff --git a/repertory/librepertory/include/events/types/info_log.hpp b/repertory/librepertory/include/events/types/info_log.hpp new file mode 100644 index 00000000..36e1e1cb --- /dev/null +++ b/repertory/librepertory/include/events/types/info_log.hpp @@ -0,0 +1,68 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_INFO_LOG_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_INFO_LOG_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct info_log final : public i_event { + info_log() = default; + info_log(std::string_view function_name_, std::string msg_) + : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"info_log"}; + + std::string function_name; + std::string msg; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|msg|{}", name, function_name, msg); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::info_log &value) { + data["function_name"] = value.function_name; + data["msg"] = value.msg; + } + + static void from_json(const json &data, repertory::info_log &value) { + data.at("function_name").get_to(value.function_name); + data.at("msg").get_to(value.msg); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_INFO_LOG_HPP_ diff --git a/repertory/librepertory/include/events/types/invalid_cache_size.hpp b/repertory/librepertory/include/events/types/invalid_cache_size.hpp index f47e1adb..b6f21ab7 100644 --- a/repertory/librepertory/include/events/types/invalid_cache_size.hpp +++ b/repertory/librepertory/include/events/types/invalid_cache_size.hpp @@ -34,8 +34,8 @@ struct invalid_cache_size final : public i_event { function_name(std::string{function_name_}), invalid_size(invalid_size_) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"invalid_cache_size"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"invalid_cache_size"}; std::uint64_t cache_size{}; std::string function_name; diff --git a/repertory/librepertory/include/events/types/item_timeout.hpp b/repertory/librepertory/include/events/types/item_timeout.hpp index f477e90b..ac128a16 100644 --- a/repertory/librepertory/include/events/types/item_timeout.hpp +++ b/repertory/librepertory/include/events/types/item_timeout.hpp @@ -32,8 +32,8 @@ struct item_timeout final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::trace}; - static constexpr const std::string_view name{"item_timeout"}; + static constexpr event_level level{event_level::trace}; + static constexpr std::string_view name{"item_timeout"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/max_cache_size_reached.hpp b/repertory/librepertory/include/events/types/max_cache_size_reached.hpp index 55d68dd3..3da04e59 100644 --- a/repertory/librepertory/include/events/types/max_cache_size_reached.hpp +++ b/repertory/librepertory/include/events/types/max_cache_size_reached.hpp @@ -35,8 +35,8 @@ struct max_cache_size_reached final : public i_event { function_name(std::string{function_name_}), max_cache_size(max_cache_size_) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"max_cache_size_reached"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"max_cache_size_reached"}; std::uint64_t cache_size{}; std::string function_name; diff --git a/repertory/librepertory/include/events/types/orphaned_file_detected.hpp b/repertory/librepertory/include/events/types/orphaned_file_detected.hpp index 99078f0b..d299a0a5 100644 --- a/repertory/librepertory/include/events/types/orphaned_file_detected.hpp +++ b/repertory/librepertory/include/events/types/orphaned_file_detected.hpp @@ -33,8 +33,8 @@ struct orphaned_file_detected final : public i_event { : function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"orphaned_file_detected"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"orphaned_file_detected"}; std::string function_name; std::string source_path; diff --git a/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp b/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp index 0ec43dff..9476a972 100644 --- a/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp +++ b/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp @@ -36,8 +36,8 @@ struct orphaned_file_processing_failed final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::error}; - static constexpr const std::string_view name{ + static constexpr event_level level{event_level::error}; + static constexpr std::string_view name{ "orphaned_file_processing_failed", }; diff --git a/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp b/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp index a51e6566..14aeb11a 100644 --- a/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp +++ b/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp @@ -33,8 +33,8 @@ struct orphaned_source_file_detected final : public i_event { : function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"orphaned_source_file_detected"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"orphaned_source_file_detected"}; std::string function_name; std::string source_path; diff --git a/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp b/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp index 289a577f..22d81529 100644 --- a/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp +++ b/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp @@ -33,8 +33,8 @@ struct orphaned_source_file_removed final : public i_event { : function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"orphaned_source_file_removed"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"orphaned_source_file_removed"}; std::string function_name; std::string source_path; diff --git a/repertory/librepertory/include/events/types/packet_client_timeout.hpp b/repertory/librepertory/include/events/types/packet_client_timeout.hpp index 72596b60..1c36b242 100644 --- a/repertory/librepertory/include/events/types/packet_client_timeout.hpp +++ b/repertory/librepertory/include/events/types/packet_client_timeout.hpp @@ -34,8 +34,8 @@ struct packet_client_timeout final : public i_event { function_name(std::string(function_name_)), msg(std::move(msg_)) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"packet_client_timeout"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"packet_client_timeout"}; std::string event_name; std::string function_name; diff --git a/repertory/librepertory/include/events/types/polling_item_begin.hpp b/repertory/librepertory/include/events/types/polling_item_begin.hpp index e2ae2a9a..fd98cbe5 100644 --- a/repertory/librepertory/include/events/types/polling_item_begin.hpp +++ b/repertory/librepertory/include/events/types/polling_item_begin.hpp @@ -32,8 +32,8 @@ struct polling_item_begin final : public i_event { : function_name(std::string(function_name_)), item_name(std::move(item_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"polling_item_begin"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"polling_item_begin"}; std::string function_name; std::string item_name; diff --git a/repertory/librepertory/include/events/types/polling_item_end.hpp b/repertory/librepertory/include/events/types/polling_item_end.hpp index 3da7e18f..5bc6075e 100644 --- a/repertory/librepertory/include/events/types/polling_item_end.hpp +++ b/repertory/librepertory/include/events/types/polling_item_end.hpp @@ -32,8 +32,8 @@ struct polling_item_end final : public i_event { : function_name(std::string(function_name_)), item_name(std::move(item_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"polling_item_end"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"polling_item_end"}; std::string function_name; std::string item_name; diff --git a/repertory/librepertory/include/events/types/provider_invalid_version.hpp b/repertory/librepertory/include/events/types/provider_invalid_version.hpp index 4b535868..cc6e84b0 100644 --- a/repertory/librepertory/include/events/types/provider_invalid_version.hpp +++ b/repertory/librepertory/include/events/types/provider_invalid_version.hpp @@ -35,8 +35,8 @@ struct provider_invalid_version final : public i_event { required_version(std::move(required_version_)), returned_version(std::move(returned_version_)) {} - static constexpr const event_level level{event_level::error}; - static constexpr const std::string_view name{"provider_invalid_version"}; + static constexpr event_level level{event_level::error}; + static constexpr std::string_view name{"provider_invalid_version"}; std::string function_name; std::string required_version; diff --git a/repertory/librepertory/include/events/types/provider_offline.hpp b/repertory/librepertory/include/events/types/provider_offline.hpp index d55a3e7c..e1f3b82e 100644 --- a/repertory/librepertory/include/events/types/provider_offline.hpp +++ b/repertory/librepertory/include/events/types/provider_offline.hpp @@ -34,8 +34,8 @@ struct provider_offline final : public i_event { host_name_or_ip(std::move(host_name_or_ip_)), port(port_) {} - static constexpr const event_level level{event_level::warn}; - static constexpr const std::string_view name{"provider_offline"}; + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"provider_offline"}; std::string function_name; std::string host_name_or_ip; diff --git a/repertory/librepertory/include/events/types/provider_upload_begin.hpp b/repertory/librepertory/include/events/types/provider_upload_begin.hpp index 9042e0b3..5a7fc5e2 100644 --- a/repertory/librepertory/include/events/types/provider_upload_begin.hpp +++ b/repertory/librepertory/include/events/types/provider_upload_begin.hpp @@ -34,8 +34,8 @@ struct provider_upload_begin final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"provider_upload_begin"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"provider_upload_begin"}; std::string api_path; std::string function_name; diff --git a/repertory/librepertory/include/events/types/provider_upload_end.hpp b/repertory/librepertory/include/events/types/provider_upload_end.hpp index 3cee2a89..7e69118a 100644 --- a/repertory/librepertory/include/events/types/provider_upload_end.hpp +++ b/repertory/librepertory/include/events/types/provider_upload_end.hpp @@ -35,8 +35,8 @@ struct provider_upload_end final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"provider_upload_end"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"provider_upload_end"}; std::string api_path; api_error error{}; diff --git a/repertory/librepertory/include/events/types/remote_server_event.hpp b/repertory/librepertory/include/events/types/remote_server_event.hpp index 52d456e6..d13d368a 100644 --- a/repertory/librepertory/include/events/types/remote_server_event.hpp +++ b/repertory/librepertory/include/events/types/remote_server_event.hpp @@ -35,8 +35,8 @@ struct remote_server_event final : public i_event { error(error_), function_name(std::string{function_name_}) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"remote_server_event"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"remote_server_event"}; std::string api_path; packet::error_type error{}; diff --git a/repertory/librepertory/include/events/types/repertory_exception.hpp b/repertory/librepertory/include/events/types/repertory_exception.hpp index 8ffa1ecb..6b901ec7 100644 --- a/repertory/librepertory/include/events/types/repertory_exception.hpp +++ b/repertory/librepertory/include/events/types/repertory_exception.hpp @@ -31,8 +31,8 @@ struct repertory_exception final : public i_event { repertory_exception(std::string_view function_name_, std::string msg_) : function_name(std::string(function_name_)), msg(std::move(msg_)) {} - static constexpr const event_level level{event_level::error}; - static constexpr const std::string_view name{"repertory_exception"}; + static constexpr event_level level{event_level::error}; + static constexpr std::string_view name{"repertory_exception"}; std::string function_name; std::string msg; diff --git a/repertory/librepertory/include/events/types/service_start_begin.hpp b/repertory/librepertory/include/events/types/service_start_begin.hpp index 74022c3e..384c437a 100644 --- a/repertory/librepertory/include/events/types/service_start_begin.hpp +++ b/repertory/librepertory/include/events/types/service_start_begin.hpp @@ -33,8 +33,8 @@ struct service_start_begin final : public i_event { : function_name(std::string(function_name_)), service_name(std::move(service_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"service_start_begin"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"service_start_begin"}; std::string function_name; std::string service_name; diff --git a/repertory/librepertory/include/events/types/service_start_end.hpp b/repertory/librepertory/include/events/types/service_start_end.hpp index 7e9c2633..470bdddd 100644 --- a/repertory/librepertory/include/events/types/service_start_end.hpp +++ b/repertory/librepertory/include/events/types/service_start_end.hpp @@ -32,8 +32,8 @@ struct service_start_end final : public i_event { : function_name(std::string(function_name_)), service_name(std::move(service_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"service_start_end"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"service_start_end"}; std::string function_name; std::string service_name; diff --git a/repertory/librepertory/include/events/types/service_stop_begin.hpp b/repertory/librepertory/include/events/types/service_stop_begin.hpp index 829bfe38..8b41a6f1 100644 --- a/repertory/librepertory/include/events/types/service_stop_begin.hpp +++ b/repertory/librepertory/include/events/types/service_stop_begin.hpp @@ -32,8 +32,8 @@ struct service_stop_begin final : public i_event { : function_name(std::string(function_name_)), service_name(std::move(service_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"service_stop_begin"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"service_stop_begin"}; std::string function_name; std::string service_name; diff --git a/repertory/librepertory/include/events/types/service_stop_end.hpp b/repertory/librepertory/include/events/types/service_stop_end.hpp index be0b0611..ad4c3a89 100644 --- a/repertory/librepertory/include/events/types/service_stop_end.hpp +++ b/repertory/librepertory/include/events/types/service_stop_end.hpp @@ -32,8 +32,8 @@ struct service_stop_end final : public i_event { : function_name(std::string(function_name_)), service_name(std::move(service_name_)) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"service_stop_end"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"service_stop_end"}; std::string function_name; std::string service_name; diff --git a/repertory/librepertory/include/events/types/trace_log.hpp b/repertory/librepertory/include/events/types/trace_log.hpp new file mode 100644 index 00000000..7ad52be0 --- /dev/null +++ b/repertory/librepertory/include/events/types/trace_log.hpp @@ -0,0 +1,68 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_TRACE_LOG_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_TRACE_LOG_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct trace_log final : public i_event { + trace_log() = default; + trace_log(std::string_view function_name_, std::string msg_) + : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + + static constexpr event_level level{event_level::trace}; + static constexpr std::string_view name{"trace_log"}; + + std::string function_name; + std::string msg; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|msg|{}", name, function_name, msg); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::trace_log &value) { + data["function_name"] = value.function_name; + data["msg"] = value.msg; + } + + static void from_json(const json &data, repertory::trace_log &value) { + data.at("function_name").get_to(value.function_name); + data.at("msg").get_to(value.msg); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_TRACE_LOG_HPP_ diff --git a/repertory/librepertory/include/events/types/unmount_requested.hpp b/repertory/librepertory/include/events/types/unmount_requested.hpp index b1f274c8..ab470889 100644 --- a/repertory/librepertory/include/events/types/unmount_requested.hpp +++ b/repertory/librepertory/include/events/types/unmount_requested.hpp @@ -31,8 +31,8 @@ struct unmount_requested final : public i_event { unmount_requested(std::string_view function_name_) : function_name(std::string(function_name_)) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"unmount_requested"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"unmount_requested"}; std::string function_name; diff --git a/repertory/librepertory/include/events/types/unmount_result.hpp b/repertory/librepertory/include/events/types/unmount_result.hpp index a08da22f..1ae99aea 100644 --- a/repertory/librepertory/include/events/types/unmount_result.hpp +++ b/repertory/librepertory/include/events/types/unmount_result.hpp @@ -35,8 +35,8 @@ struct unmount_result final : public i_event { mount_location(std::move(mount_location_)), result(result_) {} - static constexpr const event_level level{event_level::info}; - static constexpr const std::string_view name{"unmount_result"}; + static constexpr event_level level{event_level::info}; + static constexpr std::string_view name{"unmount_result"}; std::string function_name; std::string mount_location; diff --git a/repertory/librepertory/include/events/types/warn_log.hpp b/repertory/librepertory/include/events/types/warn_log.hpp new file mode 100644 index 00000000..f75d48ad --- /dev/null +++ b/repertory/librepertory/include/events/types/warn_log.hpp @@ -0,0 +1,68 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_WARN_LOG_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_WARN_LOG_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct warn_log final : public i_event { + warn_log() = default; + warn_log(std::string_view function_name_, std::string msg_) + : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + + static constexpr event_level level{event_level::warn}; + static constexpr std::string_view name{"warn_log"}; + + std::string function_name; + std::string msg; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|msg|{}", name, function_name, msg); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::warn_log &value) { + data["function_name"] = value.function_name; + data["msg"] = value.msg; + } + + static void from_json(const json &data, repertory::warn_log &value) { + data.at("function_name").get_to(value.function_name); + data.at("msg").get_to(value.msg); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_WARN_LOG_HPP_ diff --git a/repertory/librepertory/include/events/types/winfsp_event.hpp b/repertory/librepertory/include/events/types/winfsp_event.hpp index 638e2ce3..21fb01df 100644 --- a/repertory/librepertory/include/events/types/winfsp_event.hpp +++ b/repertory/librepertory/include/events/types/winfsp_event.hpp @@ -35,8 +35,8 @@ struct winfsp_event final : public i_event { error(error_), function_name(std::string{function_name_}) {} - static constexpr const event_level level{event_level::debug}; - static constexpr const std::string_view name{"winfsp_event"}; + static constexpr event_level level{event_level::debug}; + static constexpr std::string_view name{"winfsp_event"}; std::string api_path; NTSTATUS error{}; diff --git a/repertory/librepertory/include/file_manager/cache_size_mgr.hpp b/repertory/librepertory/include/file_manager/cache_size_mgr.hpp index 7da3f278..b621e875 100644 --- a/repertory/librepertory/include/file_manager/cache_size_mgr.hpp +++ b/repertory/librepertory/include/file_manager/cache_size_mgr.hpp @@ -29,7 +29,7 @@ class app_config; class cache_size_mgr final { private: - static constexpr const std::chrono::seconds cache_wait_secs{ + static constexpr std::chrono::seconds cache_wait_secs{ 5s, }; diff --git a/repertory/librepertory/include/file_manager/file_manager.hpp b/repertory/librepertory/include/file_manager/file_manager.hpp index b27aee71..1c2b0f98 100644 --- a/repertory/librepertory/include/file_manager/file_manager.hpp +++ b/repertory/librepertory/include/file_manager/file_manager.hpp @@ -40,7 +40,7 @@ class file_manager final : public i_file_manager, public i_upload_manager { E_CONSUMER(); private: - static constexpr const std::chrono::seconds queue_wait_secs{ + static constexpr std::chrono::seconds queue_wait_secs{ 5s, }; diff --git a/repertory/librepertory/include/file_manager/open_file_base.hpp b/repertory/librepertory/include/file_manager/open_file_base.hpp index df5d15be..ab527159 100644 --- a/repertory/librepertory/include/file_manager/open_file_base.hpp +++ b/repertory/librepertory/include/file_manager/open_file_base.hpp @@ -66,7 +66,7 @@ public: std::condition_variable notify_; public: - void notify(const api_error &err); + void notify(api_error err); auto wait() -> api_error; }; @@ -149,7 +149,7 @@ protected: void reset_timeout(); - auto set_api_error(const api_error &err) -> api_error; + auto set_api_error(api_error err) -> api_error; void set_file_size(std::uint64_t size); diff --git a/repertory/librepertory/include/file_manager/ring_buffer_base.hpp b/repertory/librepertory/include/file_manager/ring_buffer_base.hpp index 863f7a53..7da05a35 100644 --- a/repertory/librepertory/include/file_manager/ring_buffer_base.hpp +++ b/repertory/librepertory/include/file_manager/ring_buffer_base.hpp @@ -48,7 +48,7 @@ public: -> ring_buffer_base & = delete; public: - static constexpr const auto min_ring_size{5U}; + static constexpr auto min_ring_size{5U}; private: boost::dynamic_bitset<> read_state_; diff --git a/repertory/librepertory/include/providers/encrypt/encrypt_provider.hpp b/repertory/librepertory/include/providers/encrypt/encrypt_provider.hpp index 984f8500..d104aefb 100644 --- a/repertory/librepertory/include/providers/encrypt/encrypt_provider.hpp +++ b/repertory/librepertory/include/providers/encrypt/encrypt_provider.hpp @@ -84,6 +84,8 @@ private: void remove_deleted_files(stop_type &stop_requested); + void remove_expired_files(); + public: [[nodiscard]] auto check_version(std::string &required_version, std::string &returned_version) const diff --git a/repertory/librepertory/include/providers/s3/s3_provider.hpp b/repertory/librepertory/include/providers/s3/s3_provider.hpp index 4d9f1f04..22c5b518 100644 --- a/repertory/librepertory/include/providers/s3/s3_provider.hpp +++ b/repertory/librepertory/include/providers/s3/s3_provider.hpp @@ -70,8 +70,9 @@ private: -> api_error; [[nodiscard]] auto get_last_modified(bool directory, - const std::string &api_path) const - -> std::uint64_t; + const std::string &api_path, + std::uint64_t &last_modified) const + -> api_error; [[nodiscard]] auto get_object_info(bool directory, const std::string &api_path, diff --git a/repertory/librepertory/include/providers/sia/sia_provider.hpp b/repertory/librepertory/include/providers/sia/sia_provider.hpp index cdde708e..e2897d29 100644 --- a/repertory/librepertory/include/providers/sia/sia_provider.hpp +++ b/repertory/librepertory/include/providers/sia/sia_provider.hpp @@ -49,16 +49,28 @@ private: sia_config sia_config_; private: + [[nodiscard]] auto create_directory_key(const std::string &api_path) const + -> repertory::api_error; + + [[nodiscard]] auto ensure_directory_exists(const std::string &api_path) const + -> api_error; + [[nodiscard]] auto get_object_info(const std::string &api_path, json &object_info) const -> api_error; - [[nodiscard]] auto get_object_list(const std::string &api_path, - nlohmann::json &object_list) const -> bool; + [[nodiscard]] auto + get_object_list(const std::string &api_path, nlohmann::json &object_list, + std::optional marker = std::nullopt) const + -> bool; [[nodiscard]] auto get_sia_config() const -> const auto & { return sia_config_; } + void iterate_objects( + const std::string &api_path, const json &object_list, + std::function handle_entry) const; + protected: [[nodiscard]] auto create_directory_impl(const std::string &api_path, api_meta_map &meta) diff --git a/repertory/librepertory/include/rpc/server/server.hpp b/repertory/librepertory/include/rpc/server/server.hpp index 5892d732..88d09aa0 100644 --- a/repertory/librepertory/include/rpc/server/server.hpp +++ b/repertory/librepertory/include/rpc/server/server.hpp @@ -30,8 +30,13 @@ class app_config; class server { public: explicit server(app_config &config); + server(const server &) = delete; + server(server &&) = delete; - virtual ~server() { stop(); } + auto operator=(const server &) -> server & = delete; + auto operator=(server &&) -> server & = delete; + + virtual ~server(); private: app_config &config_; diff --git a/repertory/librepertory/include/types/remote.hpp b/repertory/librepertory/include/types/remote.hpp index b5bdc71c..0bc92b40 100644 --- a/repertory/librepertory/include/types/remote.hpp +++ b/repertory/librepertory/include/types/remote.hpp @@ -24,19 +24,20 @@ #include "types/repertory.hpp" -inline constexpr const auto PACKET_SERVICE_FUSE{1U}; -inline constexpr const auto PACKET_SERVICE_WINFSP{2U}; +inline constexpr auto PACKET_SERVICE_FUSE{1U}; +inline constexpr auto PACKET_SERVICE_WINFSP{2U}; #if defined(_WIN32) -inline constexpr const auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_WINFSP}; +inline constexpr auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_WINFSP}; #else // !defined(_WIN32) -inline constexpr const auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_FUSE}; +inline constexpr auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_FUSE}; #endif // defined(_WIN32) -constexpr const auto default_remote_client_pool_size{20U}; -constexpr const auto default_remote_max_connections{20U}; -constexpr const auto default_remote_receive_timeout_ms{120U * 1000U}; -constexpr const auto default_remote_send_timeout_ms{30U * 1000U}; +inline constexpr auto default_remote_directory_page_size{std::size_t(100U)}; +inline constexpr auto default_remote_client_pool_size{20U}; +inline constexpr auto default_remote_max_connections{20U}; +inline constexpr auto default_remote_receive_timeout_ms{120U * 1000U}; +inline constexpr auto default_remote_send_timeout_ms{30U * 1000U}; namespace repertory::remote { struct remote_config final { @@ -217,8 +218,8 @@ struct statfs_x final : public statfs { #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 // !defined(_WIN32) } // namespace repertory::remote diff --git a/repertory/librepertory/include/types/repertory.hpp b/repertory/librepertory/include/types/repertory.hpp index 434fc6f0..9e59cad3 100644 --- a/repertory/librepertory/include/types/repertory.hpp +++ b/repertory/librepertory/include/types/repertory.hpp @@ -23,32 +23,36 @@ #define REPERTORY_INCLUDE_TYPES_REPERTORY_HPP_ namespace repertory { -constexpr const auto default_api_password_size{48U}; -constexpr const auto default_download_timeout_secs{30U}; -constexpr const auto default_eviction_delay_mins{1U}; -constexpr const auto default_high_freq_interval_secs{std::uint16_t{30U}}; -constexpr const auto default_low_freq_interval_secs{std::uint16_t(60U * 60U)}; -constexpr const auto default_max_cache_size_bytes{ +inline constexpr auto default_api_password_size{48U}; +inline constexpr auto default_download_timeout_secs{30U}; +inline constexpr auto default_eviction_delay_mins{1U}; +inline constexpr auto default_high_freq_interval_secs{std::uint16_t{30U}}; +inline constexpr auto default_low_freq_interval_secs{ + std::uint16_t(60U * 60U), +}; +inline constexpr auto default_max_cache_size_bytes{ std::uint64_t(20ULL * 1024ULL * 1024ULL * 1024ULL), }; -constexpr const auto default_max_upload_count{5U}; -constexpr const auto default_med_freq_interval_secs{std::uint16_t{2U * 60U}}; -constexpr const auto default_online_check_retry_secs{60U}; -constexpr const auto default_retry_read_count{6U}; -constexpr const auto default_ring_buffer_file_size{512U}; -constexpr const auto default_task_wait_ms{100U}; -constexpr const auto default_timeout_ms{60000U}; -constexpr const auto default_ui_mgmt_port{std::uint16_t{30000U}}; -constexpr const auto max_ring_buffer_file_size{std::uint16_t(1024U)}; -constexpr const auto max_s3_object_name_length{1024U}; -constexpr const auto min_cache_size_bytes{ +inline constexpr auto default_max_upload_count{5U}; +inline constexpr auto default_med_freq_interval_secs{ + std::uint16_t{2U * 60U}, +}; +inline constexpr auto default_online_check_retry_secs{60U}; +inline constexpr auto default_retry_read_count{6U}; +inline constexpr auto default_ring_buffer_file_size{512U}; +inline constexpr auto default_task_wait_ms{100U}; +inline constexpr auto default_timeout_ms{60000U}; +inline constexpr auto default_ui_mgmt_port{std::uint16_t{30000U}}; +inline constexpr auto max_ring_buffer_file_size{std::uint16_t(1024U)}; +inline constexpr auto max_s3_object_name_length{1024U}; +inline constexpr auto min_cache_size_bytes{ std::uint64_t(100ULL * 1024ULL * 1024ULL), }; -constexpr const auto min_download_timeout_secs{std::uint8_t(5U)}; -constexpr const auto min_online_check_retry_secs{std::uint16_t(15U)}; -constexpr const auto min_retry_read_count{std::uint16_t(2U)}; -constexpr const auto min_ring_buffer_file_size{std::uint16_t(64U)}; -constexpr const auto min_task_wait_ms{std::uint16_t(50U)}; +inline constexpr auto min_download_timeout_secs{std::uint8_t(5U)}; +inline constexpr auto min_online_check_retry_secs{std::uint16_t(15U)}; +inline constexpr auto min_retry_read_count{std::uint16_t(2U)}; +inline constexpr auto min_ring_buffer_file_size{std::uint16_t(64U)}; +inline constexpr auto min_task_wait_ms{std::uint16_t(50U)}; template class atomic final { public: @@ -139,28 +143,28 @@ public: [[nodiscard]] operator data_t() const { return load(); } }; -inline constexpr const auto max_time{ +inline constexpr auto max_time{ std::numeric_limits::max(), }; -inline constexpr const std::string META_ACCESSED{"accessed"}; -inline constexpr const std::string META_ATTRIBUTES{"attributes"}; -inline constexpr const std::string META_BACKUP{"backup"}; -inline constexpr const std::string META_CHANGED{"changed"}; -inline constexpr const std::string META_CREATION{"creation"}; -inline constexpr const std::string META_DIRECTORY{"directory"}; -inline constexpr const std::string META_GID{"gid"}; -inline constexpr const std::string META_KEY{"key"}; -inline constexpr const std::string META_MODE{"mode"}; -inline constexpr const std::string META_MODIFIED{"modified"}; -inline constexpr const std::string META_OSXFLAGS{"flags"}; -inline constexpr const std::string META_PINNED{"pinned"}; -inline constexpr const std::string META_SIZE{"size"}; -inline constexpr const std::string META_SOURCE{"source"}; -inline constexpr const std::string META_UID{"uid"}; -inline constexpr const std::string META_WRITTEN{"written"}; +inline constexpr std::string META_ACCESSED{"accessed"}; +inline constexpr std::string META_ATTRIBUTES{"attributes"}; +inline constexpr std::string META_BACKUP{"backup"}; +inline constexpr std::string META_CHANGED{"changed"}; +inline constexpr std::string META_CREATION{"creation"}; +inline constexpr std::string META_DIRECTORY{"directory"}; +inline constexpr std::string META_GID{"gid"}; +inline constexpr std::string META_KEY{"key"}; +inline constexpr std::string META_MODE{"mode"}; +inline constexpr std::string META_MODIFIED{"modified"}; +inline constexpr std::string META_OSXFLAGS{"flags"}; +inline constexpr std::string META_PINNED{"pinned"}; +inline constexpr std::string META_SIZE{"size"}; +inline constexpr std::string META_SOURCE{"source"}; +inline constexpr std::string META_UID{"uid"}; +inline constexpr std::string META_WRITTEN{"written"}; -inline constexpr const std::array META_USED_NAMES = { +inline constexpr std::array META_USED_NAMES = { META_ACCESSED, META_ATTRIBUTES, META_BACKUP, META_CHANGED, META_CREATION, META_DIRECTORY, META_GID, META_KEY, META_MODE, META_MODIFIED, META_OSXFLAGS, META_PINNED, @@ -217,8 +221,7 @@ enum class api_error { [[nodiscard]] auto api_error_from_string(std::string_view str) -> api_error; -[[nodiscard]] auto api_error_to_string(const api_error &error) - -> const std::string &; +[[nodiscard]] auto api_error_to_string(api_error error) -> const std::string &; enum class database_type { rocksdb, @@ -283,11 +286,13 @@ enum class exit_code : std::int32_t { init_failed = -18, ui_mount_failed = -19, exception = -20, + provider_offline = -21 }; enum http_error_codes : std::int32_t { ok = 200, multiple_choices = 300, + bad_request = 400, unauthorized = 401, not_found = 404, internal_error = 500, @@ -465,66 +470,58 @@ using api_item_added_callback = std::function; using directory_item_list = std::vector; using meta_provider_callback = std::function; -inline constexpr const auto JSON_ACCESS_KEY{"AccessKey"}; -inline constexpr const auto JSON_AGENT_STRING{"AgentString"}; -inline constexpr const auto JSON_API_PARENT{"ApiParent"}; -inline constexpr const auto JSON_API_PASSWORD{"ApiPassword"}; -inline constexpr const auto JSON_API_PATH{"ApiPath"}; -inline constexpr const auto JSON_API_PORT{"ApiPort"}; -inline constexpr const auto JSON_API_USER{"ApiUser"}; -inline constexpr const auto JSON_BUCKET{"Bucket"}; -inline constexpr const auto JSON_CLIENT_POOL_SIZE{"ClientPoolSize"}; -inline constexpr const auto JSON_DATABASE_TYPE{"DatabaseType"}; -inline constexpr const auto JSON_DIRECTORY{"Directory"}; -inline constexpr const auto JSON_DOWNLOAD_TIMEOUT_SECS{ - "DownloadTimeoutSeconds"}; -inline constexpr const auto JSON_ENABLE_DRIVE_EVENTS{"EnableDriveEvents"}; -inline constexpr const auto JSON_ENABLE_DOWNLOAD_TIMEOUT{ - "EnableDownloadTimeout"}; -inline constexpr const auto JSON_ENABLE_MOUNT_MANAGER{"EnableMountManager"}; -inline constexpr const auto JSON_ENABLE_REMOTE_MOUNT{"Enable"}; -inline constexpr const auto JSON_ENCRYPTION_TOKEN{"EncryptionToken"}; -inline constexpr const auto JSON_ENCRYPT_CONFIG{"EncryptConfig"}; -inline constexpr const auto JSON_EVENT_LEVEL{"EventLevel"}; -inline constexpr const auto JSON_EVICTION_DELAY_MINS{"EvictionDelayMinutes"}; -inline constexpr const auto JSON_EVICTION_USE_ACCESS_TIME{ - "EvictionUseAccessedTime"}; -inline constexpr const auto JSON_HIGH_FREQ_INTERVAL_SECS{ - "HighFreqIntervalSeconds"}; -inline constexpr const auto JSON_HOST_CONFIG{"HostConfig"}; -inline constexpr const auto JSON_HOST_NAME_OR_IP{"HostNameOrIp"}; -inline constexpr const auto JSON_LOW_FREQ_INTERVAL_SECS{ - "LowFreqIntervalSeconds"}; -inline constexpr const auto JSON_MAX_CACHE_SIZE_BYTES{"MaxCacheSizeBytes"}; -inline constexpr const auto JSON_MAX_CONNECTIONS{"MaxConnections"}; -inline constexpr const auto JSON_MAX_UPLOAD_COUNT{"MaxUploadCount"}; -inline constexpr const auto JSON_MED_FREQ_INTERVAL_SECS{ - "MedFreqIntervalSeconds"}; -inline constexpr const auto JSON_META{"Meta"}; -inline constexpr const auto JSON_MOUNT_LOCATIONS{"MountLocations"}; -inline constexpr const auto JSON_ONLINE_CHECK_RETRY_SECS{ - "OnlineCheckRetrySeconds"}; -inline constexpr const auto JSON_PATH{"Path"}; -inline constexpr const auto JSON_PREFERRED_DOWNLOAD_TYPE{ - "PreferredDownloadType"}; -inline constexpr const auto JSON_PROTOCOL{"Protocol"}; -inline constexpr const auto JSON_RECV_TIMEOUT_MS{"ReceiveTimeoutMs"}; -inline constexpr const auto JSON_REGION{"Region"}; -inline constexpr const auto JSON_REMOTE_CONFIG{"RemoteConfig"}; -inline constexpr const auto JSON_REMOTE_MOUNT{"RemoteMount"}; -inline constexpr const auto JSON_RETRY_READ_COUNT{"RetryReadCount"}; -inline constexpr const auto JSON_RING_BUFFER_FILE_SIZE{"RingBufferFileSize"}; -inline constexpr const auto JSON_S3_CONFIG{"S3Config"}; -inline constexpr const auto JSON_SECRET_KEY{"SecretKey"}; -inline constexpr const auto JSON_SEND_TIMEOUT_MS{"SendTimeoutMs"}; -inline constexpr const auto JSON_SIA_CONFIG{"SiaConfig"}; -inline constexpr const auto JSON_SIZE{"Size"}; -inline constexpr const auto JSON_TASK_WAIT_MS{"TaskWaitMs"}; -inline constexpr const auto JSON_TIMEOUT_MS{"TimeoutMs"}; -inline constexpr const auto JSON_URL{"URL"}; -inline constexpr const auto JSON_USE_PATH_STYLE{"UsePathStyle"}; -inline constexpr const auto JSON_USE_REGION_IN_URL{"UseRegionInURL"}; -inline constexpr const auto JSON_VERSION{"Version"}; +inline constexpr auto JSON_ACCESS_KEY{"AccessKey"}; +inline constexpr auto JSON_AGENT_STRING{"AgentString"}; +inline constexpr auto JSON_API_PARENT{"ApiParent"}; +inline constexpr auto JSON_API_PASSWORD{"ApiPassword"}; +inline constexpr auto JSON_API_PATH{"ApiPath"}; +inline constexpr auto JSON_API_PORT{"ApiPort"}; +inline constexpr auto JSON_API_USER{"ApiUser"}; +inline constexpr auto JSON_BUCKET{"Bucket"}; +inline constexpr auto JSON_CLIENT_POOL_SIZE{"ClientPoolSize"}; +inline constexpr auto JSON_DATABASE_TYPE{"DatabaseType"}; +inline constexpr auto JSON_DIRECTORY{"Directory"}; +inline constexpr auto JSON_DOWNLOAD_TIMEOUT_SECS{"DownloadTimeoutSeconds"}; +inline constexpr auto JSON_ENABLE_DRIVE_EVENTS{"EnableDriveEvents"}; +inline constexpr auto JSON_ENABLE_DOWNLOAD_TIMEOUT{"EnableDownloadTimeout"}; +inline constexpr auto JSON_ENABLE_MOUNT_MANAGER{"EnableMountManager"}; +inline constexpr auto JSON_ENABLE_REMOTE_MOUNT{"Enable"}; +inline constexpr auto JSON_ENCRYPTION_TOKEN{"EncryptionToken"}; +inline constexpr auto JSON_ENCRYPT_CONFIG{"EncryptConfig"}; +inline constexpr auto JSON_EVENT_LEVEL{"EventLevel"}; +inline constexpr auto JSON_EVICTION_DELAY_MINS{"EvictionDelayMinutes"}; +inline constexpr auto JSON_EVICTION_USE_ACCESS_TIME{"EvictionUseAccessedTime"}; +inline constexpr auto JSON_HIGH_FREQ_INTERVAL_SECS{"HighFreqIntervalSeconds"}; +inline constexpr auto JSON_HOST_CONFIG{"HostConfig"}; +inline constexpr auto JSON_HOST_NAME_OR_IP{"HostNameOrIp"}; +inline constexpr auto JSON_LOW_FREQ_INTERVAL_SECS{"LowFreqIntervalSeconds"}; +inline constexpr auto JSON_MAX_CACHE_SIZE_BYTES{"MaxCacheSizeBytes"}; +inline constexpr auto JSON_MAX_CONNECTIONS{"MaxConnections"}; +inline constexpr auto JSON_MAX_UPLOAD_COUNT{"MaxUploadCount"}; +inline constexpr auto JSON_MED_FREQ_INTERVAL_SECS{"MedFreqIntervalSeconds"}; +inline constexpr auto JSON_META{"Meta"}; +inline constexpr auto JSON_MOUNT_LOCATIONS{"MountLocations"}; +inline constexpr auto JSON_ONLINE_CHECK_RETRY_SECS{"OnlineCheckRetrySeconds"}; +inline constexpr auto JSON_PATH{"Path"}; +inline constexpr auto JSON_PREFERRED_DOWNLOAD_TYPE{"PreferredDownloadType"}; +inline constexpr auto JSON_PROTOCOL{"Protocol"}; +inline constexpr auto JSON_RECV_TIMEOUT_MS{"ReceiveTimeoutMs"}; +inline constexpr auto JSON_REGION{"Region"}; +inline constexpr auto JSON_REMOTE_CONFIG{"RemoteConfig"}; +inline constexpr auto JSON_REMOTE_MOUNT{"RemoteMount"}; +inline constexpr auto JSON_RETRY_READ_COUNT{"RetryReadCount"}; +inline constexpr auto JSON_RING_BUFFER_FILE_SIZE{"RingBufferFileSize"}; +inline constexpr auto JSON_S3_CONFIG{"S3Config"}; +inline constexpr auto JSON_SECRET_KEY{"SecretKey"}; +inline constexpr auto JSON_SEND_TIMEOUT_MS{"SendTimeoutMs"}; +inline constexpr auto JSON_SIA_CONFIG{"SiaConfig"}; +inline constexpr auto JSON_SIZE{"Size"}; +inline constexpr auto JSON_TASK_WAIT_MS{"TaskWaitMs"}; +inline constexpr auto JSON_TIMEOUT_MS{"TimeoutMs"}; +inline constexpr auto JSON_URL{"URL"}; +inline constexpr auto JSON_USE_PATH_STYLE{"UsePathStyle"}; +inline constexpr auto JSON_USE_REGION_IN_URL{"UseRegionInURL"}; +inline constexpr auto JSON_VERSION{"Version"}; } // namespace repertory NLOHMANN_JSON_NAMESPACE_BEGIN diff --git a/repertory/librepertory/include/types/s3.hpp b/repertory/librepertory/include/types/s3.hpp index 1b9f2690..add306a1 100644 --- a/repertory/librepertory/include/types/s3.hpp +++ b/repertory/librepertory/include/types/s3.hpp @@ -50,15 +50,15 @@ using list_objects_result = std::vector; struct head_object_result { std::uint64_t content_length{}; - std::string content_type{}; - std::uint64_t last_modified{}; + std::string content_type; + std::uint64_t last_modified; - inline auto from_headers(http_headers headers) -> head_object_result & { + auto from_headers(http_headers headers) -> head_object_result & { content_length = utils::string::to_uint64(headers["content-length"]); content_type = headers["content-type"]; auto date = headers["last-modified"]; if (not date.empty()) { - struct tm tm1 {}; + struct tm tm1{}; // Mon, 17 Dec 2012 02:14:10 GMT #if defined(_WIN32) utils::time::strptime(date.c_str(), "%a, %d %b %Y %H:%M:%S %Z", &tm1); diff --git a/repertory/librepertory/include/utils/cli_utils.hpp b/repertory/librepertory/include/utils/cli_utils.hpp index c0f9ed01..bcbd5f9b 100644 --- a/repertory/librepertory/include/utils/cli_utils.hpp +++ b/repertory/librepertory/include/utils/cli_utils.hpp @@ -28,35 +28,36 @@ namespace repertory::utils::cli { using option = std::array; namespace options { -static const option check_version_option = {"-cv", "--check_version"}; -static const option display_config_option = {"-dc", "--display_config"}; -static const option data_directory_option = {"-dd", "--data_directory"}; -static const option encrypt_option = {"-en", "--encrypt"}; -static const option drive_information_option = {"-di", "--drive_information"}; -static const option name_option = {"-na", "--name"}; -static const option s3_option = {"-s3", "--s3"}; -static const option generate_config_option = {"-gc", "--generate_config"}; -static const option get_option = {"-get", "--get"}; -static const option get_directory_items_option = {"-gdi", +inline const option check_version_option = {"-cv", "--check_version"}; +inline const option display_config_option = {"-dc", "--display_config"}; +inline const option data_directory_option = {"-dd", "--data_directory"}; +inline const option encrypt_option = {"-en", "--encrypt"}; +inline const option drive_information_option = {"-di", "--drive_information"}; +inline const option name_option = {"-na", "--name"}; +inline const option s3_option = {"-s3", "--s3"}; +inline const option generate_config_option = {"-gc", "--generate_config"}; +inline const option get_option = {"-get", "--get"}; +inline const option get_directory_items_option = {"-gdi", "--get_directory_items"}; -static const option get_pinned_files_option = {"-gpf", "--get_pinned_files"}; -static const option help_option = {"-h", "--help"}; -static const option hidden_option = {"-hidden", "--hidden"}; -static const option open_files_option = {"-of", "--open_files"}; -static const option pin_file_option = {"-pf", "--pin_file"}; -static const option pinned_status_option = {"-ps", "--pinned_status"}; -static const option password_option = {"-pw", "--password"}; -static const option remote_mount_option = {"-rm", "--remote_mount"}; -static const option set_option = {"-set", "--set"}; -static const option status_option = {"-status", "--status"}; -static const option ui_option = {"-ui", "--ui"}; -static const option ui_port_option = {"-up", "--ui_port"}; -static const option unmount_option = {"-unmount", "--unmount"}; -static const option unpin_file_option = {"-uf", "--unpin_file"}; -static const option user_option = {"-us", "--user"}; -static const option version_option = {"-V", "--version"}; +inline const option get_pinned_files_option = {"-gpf", "--get_pinned_files"}; +inline const option help_option = {"-h", "--help"}; +inline const option hidden_option = {"-hidden", "--hidden"}; +inline const option open_files_option = {"-of", "--open_files"}; +inline const option pin_file_option = {"-pf", "--pin_file"}; +inline const option pinned_status_option = {"-ps", "--pinned_status"}; +inline const option password_option = {"-pw", "--password"}; +inline const option remote_mount_option = {"-rm", "--remote_mount"}; +inline const option set_option = {"-set", "--set"}; +inline const option status_option = {"-status", "--status"}; +inline const option test_option = {"-test", "--test"}; +inline const option ui_option = {"-ui", "--ui"}; +inline const option ui_port_option = {"-up", "--ui_port"}; +inline const option unmount_option = {"-unmount", "--unmount"}; +inline const option unpin_file_option = {"-uf", "--unpin_file"}; +inline const option user_option = {"-us", "--user"}; +inline const option version_option = {"-V", "--version"}; -static const std::vector