Skip to content

Commit 4975764

Browse files
committed
version 1.0.2
1 parent ba20b46 commit 4975764

24 files changed

+232
-26
lines changed

HelpUploadFiles/CEscapeRegex.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "pch.h"
2+
#include "CEscapeRegex.h"
3+
4+
std::wstring CEscapeRegex::escapeRegex(const std::wstring& str)
5+
{
6+
// Escape special characters in a regex pattern
7+
std::wstring result;
8+
for (wchar_t c : str) {
9+
if (c == '\\' || c == '.' || c == '^' || c == '$' || c == '|' || c == '?' ||
10+
c == '*' || c == '+' || c == '(' || c == ')' || c == '[' || c == ']' || c == '{' || c == '}') {
11+
result += '\\';
12+
}
13+
result += c;
14+
}
15+
return result;
16+
}

HelpUploadFiles/CEscapeRegex.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
class CEscapeRegex
3+
{
4+
public:
5+
static std::wstring escapeRegex(const std::wstring& str);
6+
};
7+

HelpUploadFiles/CMainDlg.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ void CMainDlg::DoAdd()
100100
void CMainDlg::OnRemove()
101101
{
102102
int curSel = ListBox_GetCurSel(this->hListBox);
103+
if (curSel < 0) {
104+
return;
105+
}
106+
103107
ListBox_GetText(this->hListBox, curSel, this->szInput);
104108
CIgnoreFileManager::getSingleton()->removeIgnoreFile(this->szInput);
105109
ListBox_DeleteString(this->hListBox, curSel);
@@ -162,6 +166,9 @@ void CMainDlg::OnDropFile()
162166
// 在这里处理拖放的文件,比如显示文件名
163167
fs::path path = this->szInput;
164168
_tcscpy_s(this->szInput, _countof(this->szInput), path.filename().c_str());
169+
170+
// 拖拽将逃逸正则规则
171+
std::swprintf(this->szInput, _countof(this->szInput), _T("%s"), CEscapeRegex::escapeRegex(this->szInput).c_str());
165172

166173
DoAdd();
167174
}

HelpUploadFiles/CMainDlg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "resource.h"
55
#include "CIgnoreFileManager.h"
66
#include "CAboutDlg.h"
7+
#include "CEscapeRegex.h"
78

89
class CMainDlg
910
{

HelpUploadFiles/HelpUploadFiles.rc

-82 Bytes
Binary file not shown.

HelpUploadFiles/HelpUploadFiles.vcxproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
<ItemGroup>
143143
<ClInclude Include="CAboutDlg.h" />
144144
<ClInclude Include="CContext.h" />
145+
<ClInclude Include="CEscapeRegex.h" />
145146
<ClInclude Include="CIgnoreFileManager.h" />
146147
<ClInclude Include="CInjectDll.h" />
147148
<ClInclude Include="CMainDlg.h" />
@@ -154,6 +155,7 @@
154155
<ItemGroup>
155156
<ClCompile Include="CAboutDlg.cpp" />
156157
<ClCompile Include="CContext.cpp" />
158+
<ClCompile Include="CEscapeRegex.cpp" />
157159
<ClCompile Include="CIgnoreFileManager.cpp" />
158160
<ClCompile Include="CInjectDll.cpp" />
159161
<ClCompile Include="CMainDlg.cpp" />
@@ -164,14 +166,11 @@
164166
<ResourceCompile Include="HelpUploadFiles.rc" />
165167
</ItemGroup>
166168
<ItemGroup>
167-
<Image Include="helpuplo.ico" />
168169
<Image Include="HelpUploadFiles.ico" />
169-
<Image Include="small.ico" />
170170
</ItemGroup>
171171
<ItemGroup>
172172
<None Include="cpp.hint" />
173173
<None Include="cursor.cur" />
174-
<None Include="D:\cursor.cur" />
175174
</ItemGroup>
176175
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
177176
<ImportGroup Label="ExtensionTargets">

HelpUploadFiles/HelpUploadFiles.vcxproj.filters

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
<ClInclude Include="CSkin.h">
4646
<Filter>头文件</Filter>
4747
</ClInclude>
48+
<ClInclude Include="CEscapeRegex.h">
49+
<Filter>头文件</Filter>
50+
</ClInclude>
4851
</ItemGroup>
4952
<ItemGroup>
5053
<ClCompile Include="HelpUploadFiles.cpp">
@@ -68,28 +71,22 @@
6871
<ClCompile Include="CSkin.cpp">
6972
<Filter>源文件</Filter>
7073
</ClCompile>
74+
<ClCompile Include="CEscapeRegex.cpp">
75+
<Filter>源文件</Filter>
76+
</ClCompile>
7177
</ItemGroup>
7278
<ItemGroup>
7379
<ResourceCompile Include="HelpUploadFiles.rc">
7480
<Filter>资源文件</Filter>
7581
</ResourceCompile>
7682
</ItemGroup>
7783
<ItemGroup>
78-
<Image Include="small.ico">
79-
<Filter>资源文件</Filter>
80-
</Image>
8184
<Image Include="HelpUploadFiles.ico">
8285
<Filter>资源文件</Filter>
8386
</Image>
84-
<Image Include="helpuplo.ico">
85-
<Filter>资源文件</Filter>
86-
</Image>
8787
</ItemGroup>
8888
<ItemGroup>
8989
<None Include="cpp.hint" />
90-
<None Include="D:\cursor.cur">
91-
<Filter>资源文件</Filter>
92-
</None>
9390
<None Include="cursor.cur">
9491
<Filter>资源文件</Filter>
9592
</None>

HelpUploadFiles/Resource.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#define IDM_ABOUT 104
1010
#define IDM_EXIT 105
1111
#define IDI_HELPUPLOADFILES 107
12-
#define IDI_HELPUPLOADFILES1 108
1312
#define IDC_HELPUPLOADFILES 109
1413
#define IDR_MAINFRAME 128
1514
#define IDD_MAINDIALOG 129
@@ -32,7 +31,7 @@
3231
#ifdef APSTUDIO_INVOKED
3332
#ifndef APSTUDIO_READONLY_SYMBOLS
3433
#define _APS_NO_MFC 1
35-
#define _APS_NEXT_RESOURCE_VALUE 132
34+
#define _APS_NEXT_RESOURCE_VALUE 133
3635
#define _APS_NEXT_COMMAND_VALUE 32776
3736
#define _APS_NEXT_CONTROL_VALUE 1006
3837
#define _APS_NEXT_SYMED_VALUE 110

HelpUploadFiles/cursor.cur

3.87 KB
Binary file not shown.

HelpUploadFiles/helpuplo.ico

-94 KB
Binary file not shown.

0 commit comments

Comments
 (0)