diff --git a/.cspell/words.txt b/.cspell/words.txt index ee19abee..0d896b01 100644 --- a/.cspell/words.txt +++ b/.cspell/words.txt @@ -93,6 +93,7 @@ flarge fontconfig_version freetype2_version fsetattr_x +futimens getxtimes glapi gmock diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp index 38d3ec4d..ec7d3df5 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp @@ -163,7 +163,7 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode, { std::shared_ptr open_file; if (is_create_op) { - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); #if defined(__APPLE__) const auto osx_flags = static_cast(file_info->flags); #else // !defined(__APPLE__) @@ -614,7 +614,7 @@ auto fuse_drive::mkdir_impl(std::string api_path, mode_t mode) -> api_error { return res; } - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes(now, FILE_ATTRIBUTE_DIRECTORY, now, now, true, get_effective_gid(), "", mode, now, 0U, 0U, 0U, "", get_effective_uid(), now); @@ -1311,14 +1311,14 @@ auto fuse_drive::utimens_impl(std::string api_path, meta.clear(); if ((tv == nullptr) || (tv[0U].tv_nsec == UTIME_NOW)) { - meta[META_ACCESSED] = std::to_string(utils::time::get_file_time_now()); + meta[META_ACCESSED] = std::to_string(utils::time::get_time_now()); } else if (tv[0U].tv_nsec != UTIME_OMIT) { const auto val = tv[0U].tv_nsec + (tv[0U].tv_sec * NANOS_PER_SECOND); meta[META_ACCESSED] = std::to_string(val); } if ((tv == nullptr) || (tv[1U].tv_nsec == UTIME_NOW)) { - meta[META_MODIFIED] = std::to_string(utils::time::get_file_time_now()); + meta[META_MODIFIED] = std::to_string(utils::time::get_time_now()); } else if (tv[1U].tv_nsec != UTIME_OMIT) { const auto val = tv[1U].tv_nsec + (tv[1U].tv_sec * NANOS_PER_SECOND); meta[META_MODIFIED] = std::to_string(val); @@ -1370,7 +1370,7 @@ void fuse_drive::update_accessed_time(const std::string &api_path) { if (atime_enabled_) { auto res = provider_.set_item_meta( api_path, META_ACCESSED, - std::to_string(utils::time::get_file_time_now())); + std::to_string(utils::time::get_time_now())); if (res != api_error::success) { utils::error::raise_api_path_error(function_name, api_path, res, "failed to set accessed time"); diff --git a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp index d98f3ea4..f59f4b1a 100644 --- a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp +++ b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp @@ -827,7 +827,7 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, FILETIME *write_time_ptr = nullptr; if ((tv[0U] == 0U) || (op0 == UTIME_NOW)) { - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); access_time.dwHighDateTime = static_cast((now >> 32U) & 0xFFFFFFFF); access_time.dwLowDateTime = now & 0xFFFFFFFF; @@ -838,7 +838,7 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, } if ((tv[1U] == 0U) || (op1 == UTIME_NOW)) { - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); write_time.dwHighDateTime = static_cast((now >> 32U) & 0xFFFFFFFF); write_time.dwLowDateTime = now & 0xFFFFFFFF; write_time_ptr = &write_time; diff --git a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp index e03bdffe..4df411e7 100644 --- a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp +++ b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp @@ -230,7 +230,7 @@ auto remote_winfsp_drive::Init(PVOID host) -> NTSTATUS { file_system_host->SetPersistentAcls(FALSE); file_system_host->SetPostCleanupWhenModifiedOnly(TRUE); file_system_host->SetPassQueryDirectoryPattern(FALSE); - file_system_host->SetVolumeCreationTime(utils::time::get_file_time_now()); + file_system_host->SetVolumeCreationTime(utils::time::get_time_now()); file_system_host->SetVolumeSerialNumber(0); return STATUS_SUCCESS; } diff --git a/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp b/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp index 16a746a9..d0c11b6c 100644 --- a/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp +++ b/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp @@ -215,7 +215,7 @@ VOID winfsp_drive::Cleanup(PVOID file_node, PVOID file_desc, if ((flags & (FspCleanupSetLastAccessTime | FspCleanupSetLastWriteTime | FspCleanupSetChangeTime)) != 0U) { - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); if ((flags & FspCleanupSetLastAccessTime) != 0U) { auto res = provider_.set_item_meta(api_path, META_ACCESSED, std::to_string(now)); @@ -310,7 +310,7 @@ auto winfsp_drive::Create(PWSTR file_name, UINT32 create_options, attributes = FILE_ATTRIBUTE_NORMAL; } - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, attributes, now, now, (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0U, 0U, "", 0U, now, 0U, 0U, 0U, @@ -579,7 +579,7 @@ auto winfsp_drive::Init(PVOID host) -> NTSTATUS { file_system_host->SetPersistentAcls(FALSE); file_system_host->SetPostCleanupWhenModifiedOnly(TRUE); file_system_host->SetPassQueryDirectoryPattern(FALSE); - file_system_host->SetVolumeCreationTime(utils::time::get_file_time_now()); + file_system_host->SetVolumeCreationTime(utils::time::get_time_now()); file_system_host->SetVolumeSerialNumber(0); return STATUS_SUCCESS; } @@ -868,7 +868,7 @@ auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer, data.clear(); auto res = provider_.set_item_meta( api_path, META_ACCESSED, - std::to_string(utils::time::get_file_time_now())); + std::to_string(utils::time::get_time_now())); if (res != api_error::success) { utils::error::raise_api_path_error( function_name, api_path, res, diff --git a/repertory/librepertory/src/file_manager/file_manager.cpp b/repertory/librepertory/src/file_manager/file_manager.cpp index 66efe502..67d21421 100644 --- a/repertory/librepertory/src/file_manager/file_manager.cpp +++ b/repertory/librepertory/src/file_manager/file_manager.cpp @@ -514,7 +514,7 @@ void file_manager::queue_upload(const std::string &api_path, .or_replace() .column_value("api_path", api_path) .column_value("date_time", static_cast( - utils::time::get_file_time_now())) + utils::time::get_time_now())) .column_value("source_path", source_path) .go(); if (result.ok()) { diff --git a/repertory/librepertory/src/file_manager/file_manager_open_file.cpp b/repertory/librepertory/src/file_manager/file_manager_open_file.cpp index b0360510..9690265c 100644 --- a/repertory/librepertory/src/file_manager/file_manager_open_file.cpp +++ b/repertory/librepertory/src/file_manager/file_manager_open_file.cpp @@ -320,7 +320,7 @@ auto file_manager::open_file::native_operation( set_modified(); fsi_.size = new_file_size; - const auto now = std::to_string(utils::time::get_file_time_now()); + const auto now = std::to_string(utils::time::get_time_now()); res = provider_.set_item_meta( fsi_.api_path, { {META_CHANGED, now}, @@ -586,7 +586,7 @@ auto file_manager::open_file::write(std::uint64_t write_offset, return set_api_error(res); } - const auto now = std::to_string(utils::time::get_file_time_now()); + const auto now = std::to_string(utils::time::get_time_now()); res = provider_.set_item_meta(fsi_.api_path, { {META_CHANGED, now}, {META_MODIFIED, now}, diff --git a/repertory/librepertory/src/providers/base_provider.cpp b/repertory/librepertory/src/providers/base_provider.cpp index 411ae390..97c9b6ae 100644 --- a/repertory/librepertory/src/providers/base_provider.cpp +++ b/repertory/librepertory/src/providers/base_provider.cpp @@ -37,10 +37,10 @@ auto base_provider::create_api_file(std::string path, std::string key, api_file file{}; file.api_path = utils::path::create_api_path(path); file.api_parent = utils::path::get_parent_api_path(file.api_path); - file.accessed_date = utils::time::get_file_time_now(); - file.changed_date = utils::time::get_file_time_now(); - file.creation_date = utils::time::get_file_time_now(); - file.modified_date = utils::time::get_file_time_now(); + file.accessed_date = utils::time::get_time_now(); + file.changed_date = utils::time::get_time_now(); + file.creation_date = utils::time::get_time_now(); + file.modified_date = utils::time::get_time_now(); file.key = key; file.file_size = size; return file; diff --git a/repertory/librepertory/src/providers/s3/s3_provider.cpp b/repertory/librepertory/src/providers/s3/s3_provider.cpp index 107b127a..50d36da0 100644 --- a/repertory/librepertory/src/providers/s3/s3_provider.cpp +++ b/repertory/librepertory/src/providers/s3/s3_provider.cpp @@ -392,7 +392,7 @@ auto s3_provider::get_file(const std::string &api_path, return res; } - file.accessed_date = utils::time::get_file_time_now(); + file.accessed_date = utils::time::get_time_now(); file.api_path = api_path; file.api_parent = utils::path::get_parent_api_path(file.api_path); file.changed_date = utils::aws::format_time(result.last_modified); @@ -447,7 +447,7 @@ auto s3_provider::get_file_list(api_file_list &list) const -> api_error { api_file file{}; file.api_path = utils::path::create_api_path(api_path); file.api_parent = utils::path::get_parent_api_path(file.api_path); - file.accessed_date = utils::time::get_file_time_now(); + file.accessed_date = utils::time::get_time_now(); file.changed_date = utils::convert_api_date( node.node().select_node("LastModified").node().text().as_string()); file.creation_date = file.changed_date; diff --git a/repertory/librepertory/src/utils/file_utils.cpp b/repertory/librepertory/src/utils/file_utils.cpp index d1fd27f0..1240792c 100644 --- a/repertory/librepertory/src/utils/file_utils.cpp +++ b/repertory/librepertory/src/utils/file_utils.cpp @@ -462,8 +462,8 @@ auto reset_modified_time(const std::string &path) -> bool { auto retry_delete_directory(const std::string &dir) -> bool { auto deleted = false; - for (std::uint8_t i = 0U; not(deleted = remove_directory(dir)) && (i < 200U); - i++) { + for (std::uint8_t i = 0U; + not(deleted = directory(dir).remove()) && (i < 200U); i++) { std::this_thread::sleep_for(10ms); } diff --git a/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp b/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp index 3da3d60a..71cda2f4 100644 --- a/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp +++ b/repertory/repertory_test/include/mocks/mock_fuse_drive.hpp @@ -68,10 +68,10 @@ public: dir_item.size = 0; dir_item.meta = { {META_ATTRIBUTES, "16"}, - {META_MODIFIED, std::to_string(utils::time::get_file_time_now())}, - {META_WRITTEN, std::to_string(utils::time::get_file_time_now())}, - {META_ACCESSED, std::to_string(utils::time::get_file_time_now())}, - {META_CREATION, std::to_string(utils::time::get_file_time_now())}}; + {META_MODIFIED, std::to_string(utils::time::get_time_now())}, + {META_WRITTEN, std::to_string(utils::time::get_time_now())}, + {META_ACCESSED, std::to_string(utils::time::get_time_now())}, + {META_CREATION, std::to_string(utils::time::get_time_now())}}; list.emplace_back(dir_item); dir_item.api_path = ".."; diff --git a/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp b/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp index 180dfc01..cee27b20 100644 --- a/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp +++ b/repertory/repertory_test/include/mocks/mock_winfsp_drive.hpp @@ -57,10 +57,10 @@ public: di.size = 0u; di.meta = { {META_ATTRIBUTES, "16"}, - {META_MODIFIED, std::to_string(utils::time::get_file_time_now())}, - {META_WRITTEN, std::to_string(utils::time::get_file_time_now())}, - {META_ACCESSED, std::to_string(utils::time::get_file_time_now())}, - {META_CREATION, std::to_string(utils::time::get_file_time_now())}}; + {META_MODIFIED, std::to_string(utils::time::get_time_now())}, + {META_WRITTEN, std::to_string(utils::time::get_time_now())}, + {META_ACCESSED, std::to_string(utils::time::get_time_now())}, + {META_CREATION, std::to_string(utils::time::get_time_now())}}; list.emplace_back(di); di.api_path = ".."; diff --git a/repertory/repertory_test/src/file_manager_test.cpp b/repertory/repertory_test/src/file_manager_test.cpp index e5754fd2..5e316957 100644 --- a/repertory/repertory_test/src/file_manager_test.cpp +++ b/repertory/repertory_test/src/file_manager_test.cpp @@ -117,7 +117,7 @@ TEST(file_manager, can_create_and_close_file) { { std::shared_ptr f; - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, false, 1, "key", 2, now + 3u, 3u, 4u, 0u, source_path, 10, @@ -232,7 +232,7 @@ TEST(file_manager, can_open_and_close_file) { std::uint64_t handle{}; { - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, false, 1, "key", 2, now + 3u, 3u, 4u, 0u, source_path, 10, @@ -339,7 +339,7 @@ TEST(file_manager, can_open_and_close_multiple_handles_for_same_file) { const auto source_path = utils::path::combine( cfg.get_cache_directory(), {utils::create_uuid_string()}); - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, false, 1, "key", 2, now + 3u, 3u, 4u, 0u, source_path, 10, @@ -419,7 +419,7 @@ TEST(file_manager, download_is_stored_after_write_if_partially_downloaded) { event_capture ec({"download_stored"}, {"file_upload_completed", "file_upload_queued"}); - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, false, 1, "key", 2, now + 3u, 3u, 4u, @@ -580,7 +580,7 @@ TEST(file_manager, upload_occurs_after_write_if_fully_downloaded) { }); event_capture ec({"download_end"}); - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, false, 1, "key", 2, now + 3u, 3u, 4u, @@ -689,7 +689,7 @@ TEST(file_manager, can_evict_file) { const auto source_path = utils::path::combine( cfg.get_cache_directory(), {utils::create_uuid_string()}); - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, @@ -955,7 +955,7 @@ TEST(file_manager, evict_file_fails_if_file_is_uploading) { const auto source_path = utils::path::combine( cfg.get_cache_directory(), {utils::create_uuid_string()}); - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, @@ -1188,7 +1188,7 @@ TEST(file_manager, file_is_not_opened_if_provider_create_file_fails) { EXPECT_CALL(mp, is_direct_only()).WillRepeatedly(Return(false)); - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, false, 1, "", 2, now + 3u, 3u, 4u, 0u, "/test_create.src", 10, @@ -1740,7 +1740,7 @@ TEST(file_manager, file_is_closed_after_download_timeout) { ee.get_api_path().get().c_str()); }); - const auto now = utils::time::get_file_time_now(); + const auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( now, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_ARCHIVE, now + 1u, now + 2u, false, 1, "key", 2, now + 3u, 3u, 4u, diff --git a/repertory/repertory_test/src/providers_test.cpp b/repertory/repertory_test/src/providers_test.cpp index 7e528dbe..fc7fe195 100644 --- a/repertory/repertory_test/src/providers_test.cpp +++ b/repertory/repertory_test/src/providers_test.cpp @@ -57,7 +57,7 @@ const auto check_forced_dirs = [](const repertory::directory_item_list &list) { const auto create_directory = [](repertory::i_provider &provider, const std::string &api_path) { - auto date = repertory::utils::time::get_file_time_now(); + auto date = repertory::utils::time::get_time_now(); auto meta = repertory::create_meta_attributes( date, 1U, date + 1U, date + 2U, true, getgid(), "", 0700, date + 3U, 2U, 3U, 0U, api_path + "_src", getuid(), date + 4U); @@ -109,7 +109,7 @@ const auto create_file = [](repertory::i_provider &provider, const std::string &api_path) { auto source_path = repertory::test::generate_test_file_name("providers_test"); - auto date = repertory::utils::time::get_file_time_now(); + auto date = repertory::utils::time::get_time_now(); auto meta = repertory::create_meta_attributes( date, 1U, date + 1U, date + 2U, false, getgid(), "", 0700, date + 3U, 2U, 3U, 0U, source_path, getuid(), date + 4U); diff --git a/repertory/repertory_test/src/remote_fuse_test.cpp b/repertory/repertory_test/src/remote_fuse_test.cpp index 1faf464c..529517c1 100644 --- a/repertory/repertory_test/src/remote_fuse_test.cpp +++ b/repertory/repertory_test/src/remote_fuse_test.cpp @@ -687,7 +687,7 @@ static void setbkuptime_test(repertory::remote_fuse::remote_client &client) { if (ret == 0) { EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); - remote::file_time ts = utils::time::get_file_time_now(); + remote::file_time ts = utils::time::get_time_now(); #if defined(_WIN32) EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setbkuptime(api_path.c_str(), ts)); #else @@ -712,7 +712,7 @@ static void setchgtime_test(repertory::remote_fuse::remote_client &client) { if (ret == 0) { EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); - remote::file_time ts = utils::time::get_file_time_now(); + remote::file_time ts = utils::time::get_time_now(); #if defined(_WIN32) EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setchgtime(api_path.c_str(), ts)); #else @@ -737,7 +737,7 @@ static void setcrtime_test(repertory::remote_fuse::remote_client &client) { if (ret == 0) { EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle)); - remote::file_time ts = utils::time::get_file_time_now(); + remote::file_time ts = utils::time::get_time_now(); #if defined(_WIN32) EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setcrtime(api_path.c_str(), ts)); #else diff --git a/support/include/utils/time.hpp b/support/include/utils/time.hpp index 2db765ef..35b77f88 100644 --- a/support/include/utils/time.hpp +++ b/support/include/utils/time.hpp @@ -46,8 +46,6 @@ filetime_to_unix_time(const FILETIME &file_time) -> std::uint64_t; } #endif // defined(PROJECT_ENABLE_SPDLOG) || defined(PROJECT_ENABLE_FMT) -[[nodiscard]] auto get_file_time_now() -> std::uint64_t; - void get_local_time_now(struct tm &local_time); [[nodiscard]] auto get_time_now() -> std::uint64_t;