/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/NewPlus/NewShellExtensionContextMenu/template_folder.cpp
57 строк
1 KB
Christian Gaarden Gaardmark
New+: Fixed issue with files and folders containing only numbers (#45439)
02 мар 2026, 17:16
Не верифицирован
02 мар 2026, 17:16
7e3f9f0
Код
Авторство
О чём код?
#include "pch.h" #include <shellapi.h> #include "template_folder.h" using namespace newplus; template_folder::template_folder(){}; template_folder::template_folder(const std::filesystem::path newplus_template_folder) { this->template_folder_path = newplus_template_folder; } template_folder::~template_folder() { list_of_templates.clear(); } void template_folder::init() { rescan_template_folder(); } void template_folder::rescan_template_folder() { list_of_templates.clear(); std::list<std::pair<std::wstring, template_item*>> dirs; std::list<std::pair<std::wstring, template_item*>> files; for (const auto& entry : std::filesystem::directory_iterator(template_folder_path)) { if (entry.is_directory()) { dirs.push_back({ entry.path().wstring(), new template_item(entry) }); } else { if (!newplus::helpers::variables::exclude_item(entry.path())) { files.push_back({ entry.path().wstring(), new template_item(entry) }); } } } // List of templates are sorted, with template-directories/folders first then followed by template-files dirs.sort(); files.sort(); list_of_templates = dirs; list_of_templates.splice(list_of_templates.end(), files); } template_item* template_folder::get_template_item(const int index) const { auto it = list_of_templates.begin(); std::advance(it, index); return it->second; }