From 9248a8a0650e453eb09c3def628705b85372235a Mon Sep 17 00:00:00 2001 From: Christian Gaarden Gaardmark Date: Wed, 27 Nov 2024 15:43:51 -0800 Subject: [PATCH] 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 adf186a5098..4b8809cb409 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();