Skip to content

Commit b100d8b

Browse files
authored
[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!
1 parent eeb72b9 commit b100d8b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/modules/NewPlus/NewShellExtensionContextMenu/new_utilities.h

+18
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,21 @@ namespace newplus::utilities
343343
}
344344
}
345345

346+
inline void update_last_write_time(const std::filesystem::path path)
347+
{
348+
const std::filesystem::file_time_type now = std::filesystem::file_time_type::clock::now();
349+
350+
std::filesystem::last_write_time(path, now);
351+
352+
if (std::filesystem::is_directory(path))
353+
{
354+
for (const auto& entry : std::filesystem::recursive_directory_iterator(path))
355+
{
356+
std::filesystem::last_write_time(entry.path(), now);
357+
}
358+
}
359+
}
360+
346361
inline HRESULT copy_template(const template_item* template_entry, const ComPtr<IUnknown> site_of_folder)
347362
{
348363
HRESULT hr = S_OK;
@@ -376,6 +391,9 @@ namespace newplus::utilities
376391
// Copy file and determine final filename
377392
std::filesystem::path target_final_fullpath = template_entry->copy_object_to(GetActiveWindow(), target_fullpath);
378393

394+
// Touch all files and set last modified to "now"
395+
update_last_write_time(target_final_fullpath);
396+
379397
// Consider copy completed. If we do tracing after enter_rename_mode, then rename mode won't consistently work
380398
trace.UpdateState(true);
381399
Trace::EventCopyTemplate(target_final_fullpath.extension().c_str());

0 commit comments

Comments
 (0)