[New+]Update last modified date to now for all templates created (#36133)

* Update last modified date to now for all templates created

* Now also set last update for directories. Thank you htcfreek!
This commit is contained in:
Christian Gaarden Gaardmark 2025-01-21 05:58:55 -08:00 коммит произвёл GitHub
Родитель eeb72b9d80
Коммит b100d8b174
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -343,6 +343,21 @@ 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();
std::filesystem::last_write_time(path, now);
if (std::filesystem::is_directory(path))
{
for (const auto& entry : std::filesystem::recursive_directory_iterator(path))
{
std::filesystem::last_write_time(entry.path(), now);
}
}
}
inline HRESULT copy_template(const template_item* template_entry, const ComPtr<IUnknown> site_of_folder) inline HRESULT copy_template(const template_item* template_entry, const ComPtr<IUnknown> site_of_folder)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
@ -376,6 +391,9 @@ namespace newplus::utilities
// Copy file and determine final filename // Copy file and determine final filename
std::filesystem::path target_final_fullpath = template_entry->copy_object_to(GetActiveWindow(), target_fullpath); 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);
// Consider copy completed. If we do tracing after enter_rename_mode, then rename mode won't consistently work // Consider copy completed. If we do tracing after enter_rename_mode, then rename mode won't consistently work
trace.UpdateState(true); trace.UpdateState(true);
Trace::EventCopyTemplate(target_final_fullpath.extension().c_str()); Trace::EventCopyTemplate(target_final_fullpath.extension().c_str());