From 9248a8a0650e453eb09c3def628705b85372235a Mon Sep 17 00:00:00 2001 From: Christian Gaarden Gaardmark Date: Wed, 27 Nov 2024 15:43:51 -0800 Subject: [PATCH 1/2] Update last modified date to now for all templates created --- .../new_utilities.h | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/modules/NewPlus/NewShellExtensionContextMenu/new_utilities.h b/src/modules/NewPlus/NewShellExtensionContextMenu/new_utilities.h index adf186a50986..4b8809cb409d 100644 --- a/src/modules/NewPlus/NewShellExtensionContextMenu/new_utilities.h +++ b/src/modules/NewPlus/NewShellExtensionContextMenu/new_utilities.h @@ -343,6 +343,25 @@ namespace newplus::utilities } } + inline void update_last_write_time(const std::filesystem::path path) + { + const std::filesystem::file_time_type now = std::filesystem::file_time_type::clock::now(); + if (std::filesystem::is_regular_file(path)) + { + std::filesystem::last_write_time(path, now); + } + else if (std::filesystem::is_directory(path)) + { + for (const auto& entry : std::filesystem::recursive_directory_iterator(path)) + { + if (std::filesystem::is_regular_file(entry.path())) + { + std::filesystem::last_write_time(entry.path(), now); + } + } + } + } + inline HRESULT copy_template(const template_item* template_entry, const ComPtr site_of_folder) { HRESULT hr = S_OK; @@ -376,6 +395,9 @@ namespace newplus::utilities // Copy file and determine final filename std::filesystem::path target_final_fullpath = template_entry->copy_object_to(GetActiveWindow(), target_fullpath); + // Touch all files and set last modified to "now" + update_last_write_time(target_final_fullpath); + trace.UpdateState(true); Trace::EventCopyTemplate(target_final_fullpath.extension().c_str()); trace.Flush(); From 8a520b766fc8e70e6ee15278237169ee4b541301 Mon Sep 17 00:00:00 2001 From: Christian Gaarden Gaardmark Date: Tue, 3 Dec 2024 19:17:00 -0800 Subject: [PATCH 2/2] Now also set last update for directories. Thank you htcfreek! --- .../NewShellExtensionContextMenu/new_utilities.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/modules/NewPlus/NewShellExtensionContextMenu/new_utilities.h b/src/modules/NewPlus/NewShellExtensionContextMenu/new_utilities.h index 51f7735333b4..5df9dda1fea1 100644 --- a/src/modules/NewPlus/NewShellExtensionContextMenu/new_utilities.h +++ b/src/modules/NewPlus/NewShellExtensionContextMenu/new_utilities.h @@ -346,18 +346,14 @@ namespace newplus::utilities inline void update_last_write_time(const std::filesystem::path path) { const std::filesystem::file_time_type now = std::filesystem::file_time_type::clock::now(); - if (std::filesystem::is_regular_file(path)) - { - std::filesystem::last_write_time(path, now); - } - else if (std::filesystem::is_directory(path)) + + std::filesystem::last_write_time(path, now); + + if (std::filesystem::is_directory(path)) { for (const auto& entry : std::filesystem::recursive_directory_iterator(path)) { - if (std::filesystem::is_regular_file(entry.path())) - { - std::filesystem::last_write_time(entry.path(), now); - } + std::filesystem::last_write_time(entry.path(), now); } } }