mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
FileView: Change wildcard matching to use PathMatchSpec
This commit is contained in:
parent
7cdd6853aa
commit
68dce478d5
@ -44,7 +44,6 @@ typedef struct // 22 bytes
|
|||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
unsigned __stdcall SystemThreadProc(void* pParam);
|
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 GetFolderInfo(std::queue<std::wstring>& folderQueue, std::wstring& folder, ParentMeasure* parent, RecursiveType rType);
|
||||||
void GetIcon(std::wstring filePath, const std::wstring& iconPath, IconSize iconSize);
|
void GetIcon(std::wstring filePath, const std::wstring& iconPath, IconSize iconSize);
|
||||||
HRESULT SaveIcon(HICON hIcon, FILE* fp);
|
HRESULT SaveIcon(HICON hIcon, FILE* fp);
|
||||||
@ -741,11 +740,6 @@ unsigned __stdcall SystemThreadProc(void* pParam)
|
|||||||
std::wstring folder = tmp->path;
|
std::wstring folder = tmp->path;
|
||||||
|
|
||||||
RecursiveType rType = tmp->recursiveType;
|
RecursiveType rType = tmp->recursiveType;
|
||||||
if (rType == RECURSIVE_FULL && tmp->wildcardSearch != L"*")
|
|
||||||
{
|
|
||||||
EscapeRegex(tmp->wildcardSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
GetFolderInfo(folderQueue, folder, tmp, (rType == RECURSIVE_PARTIAL) ? RECURSIVE_NONE : rType);
|
GetFolderInfo(folderQueue, folder, tmp, (rType == RECURSIVE_PARTIAL) ? RECURSIVE_NONE : rType);
|
||||||
|
|
||||||
while (rType != RECURSIVE_NONE && !folderQueue.empty())
|
while (rType != RECURSIVE_NONE && !folderQueue.empty())
|
||||||
@ -912,37 +906,6 @@ unsigned __stdcall SystemThreadProc(void* pParam)
|
|||||||
return 0;
|
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)
|
void GetFolderInfo(std::queue<std::wstring>& folderQueue, std::wstring& folder, ParentMeasure* parent, RecursiveType rType)
|
||||||
{
|
{
|
||||||
std::wstring path = folder;
|
std::wstring path = folder;
|
||||||
@ -969,8 +932,7 @@ void GetFolderInfo(std::queue<std::wstring>& folderQueue, std::wstring& folder,
|
|||||||
|
|
||||||
if (rType == RECURSIVE_FULL && parent->wildcardSearch != L"*" && !file.isFolder)
|
if (rType == RECURSIVE_FULL && parent->wildcardSearch != L"*" && !file.isFolder)
|
||||||
{
|
{
|
||||||
std::wregex pattern(parent->wildcardSearch, std::wregex::icase | std::wregex::optimize);
|
if (!PathMatchSpec(file.fileName.c_str(), parent->wildcardSearch.c_str()))
|
||||||
if (!std::regex_match(file.fileName, pattern))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
@ -31,6 +34,9 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
@ -39,6 +45,9 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
@ -47,6 +56,9 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="PluginFileView.h" />
|
<ClInclude Include="PluginFileView.h" />
|
||||||
|
@ -24,12 +24,12 @@
|
|||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <commoncontrols.h>
|
#include <commoncontrols.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
#include <Shlwapi.h>
|
||||||
|
|
||||||
// STL
|
// STL
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <regex>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
// Rainmeter API
|
// Rainmeter API
|
||||||
|
Loading…
x
Reference in New Issue
Block a user