mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
FileView: When using Recursive=2, Option WildcardSearch now only searches for files instead of folders.
This commit is contained in:
parent
a80af60dbc
commit
60286236f6
@ -44,6 +44,7 @@ typedef struct // 22 bytes
|
||||
#pragma pack(pop)
|
||||
|
||||
unsigned __stdcall SystemThreadProc(void* pParam);
|
||||
void EscapeRegex(std::wstring& regex);
|
||||
void GetFolderInfo(std::queue<std::wstring>& folderQueue, std::wstring& folder, ParentMeasure* parent, RecursiveType rType);
|
||||
void GetIcon(std::wstring filePath, std::wstring iconPath, IconSize iconSize);
|
||||
HRESULT SaveIcon(HICON hIcon, FILE* fp);
|
||||
@ -729,6 +730,11 @@ unsigned __stdcall SystemThreadProc(void* pParam)
|
||||
std::wstring folder = tmp->path;
|
||||
|
||||
RecursiveType rType = tmp->recursiveType;
|
||||
if (rType == RECURSIVE_FULL && tmp->wildcardSearch != L"*")
|
||||
{
|
||||
EscapeRegex(tmp->wildcardSearch);
|
||||
}
|
||||
|
||||
GetFolderInfo(folderQueue, folder, tmp, (rType == RECURSIVE_PARTIAL) ? RECURSIVE_NONE : rType);
|
||||
|
||||
while (rType != RECURSIVE_NONE && !folderQueue.empty())
|
||||
@ -893,10 +899,41 @@ unsigned __stdcall SystemThreadProc(void* pParam)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EscapeRegex(std::wstring& regex)
|
||||
{
|
||||
auto replace = [®ex](std::wstring from, std::wstring to)
|
||||
{
|
||||
size_t start = 0;
|
||||
while ((start = regex.find(from, start)) != std::wstring::npos)
|
||||
{
|
||||
regex.replace(start, from.size(), to);
|
||||
start += to.size();
|
||||
}
|
||||
};
|
||||
|
||||
replace(L"\\", L"\\\\");
|
||||
replace(L"^", L"\\^");
|
||||
replace(L"$", L"\\$");
|
||||
replace(L"|", L"\\|");
|
||||
replace(L"(", L"\\(");
|
||||
replace(L")", L"\\)");
|
||||
replace(L"[", L"\\[");
|
||||
replace(L"]", L"\\]");
|
||||
replace(L".", L"\\.");
|
||||
replace(L"+", L"\\+");
|
||||
replace(L"/", L"\\/");
|
||||
replace(L"&", L"\\&");
|
||||
replace(L"{", L"\\{");
|
||||
replace(L"}", L"\\}");
|
||||
|
||||
replace(L"*", L".*");
|
||||
replace(L"?", L".");
|
||||
}
|
||||
|
||||
void GetFolderInfo(std::queue<std::wstring>& folderQueue, std::wstring& folder, ParentMeasure* parent, RecursiveType rType)
|
||||
{
|
||||
std::wstring path = folder;
|
||||
folder += (rType == RECURSIVE_PARTIAL) ? L"*" : parent->wildcardSearch;
|
||||
folder += (rType == RECURSIVE_NONE) ? parent->wildcardSearch : L"*";
|
||||
|
||||
WIN32_FIND_DATA fd;
|
||||
HANDLE find = FindFirstFileEx(folder.c_str(), FindExInfoStandard, &fd, FindExSearchNameMatch, nullptr, 0);
|
||||
@ -917,6 +954,15 @@ void GetFolderInfo(std::queue<std::wstring>& folderQueue, std::wstring& folder,
|
||||
bool isHidden = (fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) > 0;
|
||||
bool isSystem = (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) > 0;
|
||||
|
||||
if (rType == RECURSIVE_FULL && parent->wildcardSearch != L"*" && !file.isFolder)
|
||||
{
|
||||
std::wregex pattern(parent->wildcardSearch, std::wregex::icase | std::wregex::optimize);
|
||||
if (!std::regex_match(file.fileName, pattern))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((rType != RECURSIVE_PARTIAL) &&
|
||||
((rType != RECURSIVE_FULL && !parent->showFile && !file.isFolder) ||
|
||||
(rType != RECURSIVE_FULL && !parent->showFolder && file.isFolder) ||
|
||||
|
@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,0,0,0
|
||||
FILEVERSION 2,0,1,0
|
||||
PRODUCTVERSION PRODUCTVER
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
@ -23,7 +23,7 @@ VS_VERSION_INFO VERSIONINFO
|
||||
{
|
||||
BLOCK "040904E4"
|
||||
{
|
||||
VALUE "FileVersion", "2.0.0.0"
|
||||
VALUE "FileVersion", "2.0.1.0"
|
||||
VALUE "LegalCopyright", "© 2012 - Brian Ferguson"
|
||||
VALUE "ProductName", "Rainmeter"
|
||||
#ifdef _WIN64
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <regex>
|
||||
#include <algorithm>
|
||||
|
||||
// Rainmeter API
|
||||
|
Loading…
Reference in New Issue
Block a user