Skip to content

Commit ae0e796

Browse files
author
FlameCyclone
committed
update README.md
1 parent 73ed8fc commit ae0e796

23 files changed

+139
-18
lines changed

Assets/image-20241220164520003.png

14.2 KB
Loading

Assets/image-20241220164542610.png

10.9 KB
Loading

Assets/image-20241220164721752.png

11 KB
Loading

Assets/image-20241220164743397.png

14.9 KB
Loading

NTFS_Search_App/main.cpp

+114-7
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,9 @@ using _tstring = std::string;
5454

5555
std::wstring _MultiStrToWStr(UINT CodePage, const std::string& str)
5656
{
57-
//计算缓冲区所需的字符长度
5857
int cchWideChar = ::MultiByteToWideChar(CodePage, 0, str.c_str(), -1, NULL, 0);
5958
std::wstring strResult(cchWideChar, 0);
60-
61-
//成功则返回写入到指示的缓冲区的字符数
6259
size_t nConverted = ::MultiByteToWideChar(CodePage, 0, str.c_str(), (int)str.size(), &strResult[0], (int)strResult.size());
63-
64-
//调整内容长度
6560
strResult.resize(nConverted);
6661
return strResult;
6762
}
@@ -75,7 +70,15 @@ _tstring AStrToTStr(const std::string& str)
7570
#endif
7671
}
7772

73+
int _tmain_cn(int argc, LPCTSTR argv[]);
74+
int _tmain_en(int argc, LPCTSTR argv[]);
75+
7876
int _tmain(int argc, LPCTSTR argv[])
77+
{
78+
return _tmain_cn(argc, argv);
79+
}
80+
81+
int _tmain_cn(int argc, LPCTSTR argv[])
7982
{
8083
setlocale(LC_ALL, "");
8184

@@ -84,18 +87,18 @@ int _tmain(int argc, LPCTSTR argv[])
8487

8588
_tstring strDriveList = _T("");
8689
_tstring strDbPath = _T("");
87-
tmBegin = ::clock();
8890

8991
// 初始化
9092
NTFS_Search_Initialize_By_Drive_Letter(strDriveList.c_str(), strDbPath.c_str(), false);
9193
if (0 == NTFS_Search_GetCount())
9294
{
9395
_tprintf(_T("扫描指定驱动器: %s\n"), strDriveList.c_str());
96+
tmBegin = ::clock();
9497
NTFS_Search_Reset_By_Drive_Letter(strDriveList.c_str(), strDbPath.c_str(), true);
98+
tmEnd = ::clock();
9599
_tprintf(_T("扫描耗时: %d毫秒\n"), tmEnd - tmBegin);
96100
}
97101

98-
tmEnd = ::clock();
99102

100103
_tstring strKey;
101104

@@ -178,3 +181,107 @@ int _tmain(int argc, LPCTSTR argv[])
178181

179182
return 0;
180183
};
184+
185+
int _tmain_en(int argc, LPCTSTR argv[])
186+
{
187+
setlocale(LC_ALL, "");
188+
189+
clock_t tmBegin = ::clock();
190+
clock_t tmEnd = ::clock();
191+
192+
_tstring strDriveList = _T("");
193+
_tstring strDbPath = _T("");
194+
195+
// Initialize
196+
NTFS_Search_Initialize_By_Drive_Letter(strDriveList.c_str(), strDbPath.c_str(), false);
197+
if (0 == NTFS_Search_GetCount())
198+
{
199+
_tprintf(_T("Scan the specified drive: %s\n"), strDriveList.c_str());
200+
tmBegin = ::clock();
201+
NTFS_Search_Reset_By_Drive_Letter(strDriveList.c_str(), strDbPath.c_str(), true);
202+
tmEnd = ::clock();
203+
_tprintf(_T("Scanning Time Taken: %dms\n"), tmEnd - tmBegin);
204+
}
205+
206+
_tstring strKey;
207+
208+
while (true)
209+
{
210+
char szBuf[MAX_PATH] = { 0 };
211+
212+
_tprintf(_T("File count: %llu\n"), NTFS_Search_GetCount());
213+
_tprintf(_T("Command: \n"));
214+
_tprintf(_T(" :r Rescan, such as: :r\n"));
215+
_tprintf(_T(" :: Rescan the specified drive, such as: ::CDEF\n"));
216+
_tprintf(_T(" :q Quit, such as: :q\n"));
217+
_tprintf(_T("Find keyword: "));
218+
219+
strKey.clear();
220+
while (strKey.empty())
221+
{
222+
gets_s(szBuf, sizeof(szBuf));
223+
strKey = AStrToTStr(szBuf);
224+
}
225+
226+
if (0 == _strnicmp(szBuf, "::", 2))
227+
{
228+
strDriveList = strKey.substr(2);
229+
_tprintf(_T("Rescan the specified drive: %s\n"), strDriveList.c_str());
230+
tmBegin = ::clock();
231+
NTFS_Search_Reset_By_Drive_Letter(strDriveList.c_str(), strDbPath.c_str(), true);
232+
tmEnd = ::clock();
233+
_tprintf(_T("Total time taken: %dms\n"), tmEnd - tmBegin);
234+
continue;
235+
}
236+
237+
if (0 == _stricmp(szBuf, ":r"))
238+
{
239+
_tprintf(_T("Rescan\n"));
240+
tmBegin = ::clock();
241+
NTFS_Search_Reset_By_Drive_Letter(strDriveList.c_str(), strDbPath.c_str(), true);
242+
tmEnd = ::clock();
243+
_tprintf(_T("Total time taken: %dms\n"), tmEnd - tmBegin);
244+
continue;
245+
}
246+
247+
if (0 == _stricmp(szBuf, ":q"))
248+
{
249+
_tprintf(_T("Quit\n"));
250+
break;
251+
}
252+
253+
_tprintf(_T(R"(Searching...)"));
254+
_tprintf(_T("\n"));
255+
256+
std::vector<_tstring> fileList;
257+
tmBegin = ::clock();
258+
int nRes = NTFS_Search_Query(strKey.c_str(), [](LPVOID lpData, LPCTSTR lpPath) -> bool {
259+
260+
std::vector<_tstring>* pList = (std::vector<_tstring>*)lpData;
261+
pList->push_back(lpPath);
262+
return true;
263+
264+
},
265+
266+
&fileList
267+
);
268+
tmEnd = ::clock();
269+
270+
int nIndex = 0;
271+
for (const auto& item : fileList)
272+
{
273+
_tprintf(_T("%d: %s\r\n"), ++nIndex, item.c_str());
274+
if (nIndex >= 100)
275+
{
276+
break;
277+
}
278+
}
279+
_tprintf(_T("\n"));
280+
_tprintf(_T("Time taken: %gs Number of files: %d \n"), (double)((tmEnd - tmBegin)) / 1000.0f, (int)fileList.size());
281+
}
282+
283+
// Uninitialize
284+
NTFS_Search_Uninitialize();
285+
286+
return 0;
287+
}
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
-190 Bytes
Binary file not shown.
-184 Bytes
Binary file not shown.
-104 Bytes
Binary file not shown.
-104 Bytes
Binary file not shown.
-172 Bytes
Binary file not shown.
-184 Bytes
Binary file not shown.
-108 Bytes
Binary file not shown.
-104 Bytes
Binary file not shown.

README.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# NTFS File Search Library
22

3-
English | [中文](README_cn.md)
3+
[中文 ](README_cn.md) | English
44

55
A library for quickly searching files on an NTFS volume.
66

77

88

9+
![image-20241220164542610](./assets/image-20241220164542610.png)
10+
11+
12+
13+
![image-20241220164520003](./assets/image-20241220164520003.png)
14+
915
## Features
1016

1117
- Quickly scan all files on NTFS formatted drives
@@ -15,6 +21,10 @@ A library for quickly searching files on an NTFS volume.
1521

1622

1723

24+
![image-20241220163023105](./assets/image-20241220163023105.png)
25+
26+
27+
1828
## API Description
1929

2030
- Initialize and specify the drive you are concerned with.
@@ -147,6 +157,9 @@ using _tstring = std::wstring;
147157
using _tstring = std::string;
148158
#endif
149159

160+
#ifndef _DEBUG
161+
162+
150163
#ifndef _DEBUG
151164

152165
#ifdef _UNICODE
@@ -215,19 +228,18 @@ int _tmain(int argc, LPCTSTR argv[])
215228

216229
_tstring strDriveList = _T("");
217230
_tstring strDbPath = _T("");
218-
tmBegin = ::clock();
219231

220232
// Initialize
221233
NTFS_Search_Initialize_By_Drive_Letter(strDriveList.c_str(), strDbPath.c_str(), false);
222234
if (0 == NTFS_Search_GetCount())
223235
{
224236
_tprintf(_T("Scan the specified drive: %s\n"), strDriveList.c_str());
237+
tmBegin = ::clock();
225238
NTFS_Search_Reset_By_Drive_Letter(strDriveList.c_str(), strDbPath.c_str(), true);
239+
tmEnd = ::clock();
226240
_tprintf(_T("Scanning Time Taken: %dms\n"), tmEnd - tmBegin);
227241
}
228242

229-
tmEnd = ::clock();
230-
231243
_tstring strKey;
232244

233245
while (true)
@@ -239,10 +251,9 @@ int _tmain(int argc, LPCTSTR argv[])
239251
_tprintf(_T(" :r Rescan, such as: :r\n"));
240252
_tprintf(_T(" :: Rescan the specified drive, such as: ::CDEF\n"));
241253
_tprintf(_T(" :q Quit, such as: :q\n"));
242-
_tprintf(_T("Find keyword:
243-
: "));
254+
_tprintf(_T("Find keyword: "));
244255

245-
strKey.clear();
256+
strKey.clear();
246257
while (strKey.empty())
247258
{
248259
gets_s(szBuf, sizeof(szBuf));
@@ -303,7 +314,7 @@ int _tmain(int argc, LPCTSTR argv[])
303314
}
304315
}
305316
_tprintf(_T("\n"));
306-
_tprintf(_T("Time taken: %gseconds Number of files: %d \n"), (double)((tmEnd - tmBegin)) / 1000.0f, (int)fileList.size());
317+
_tprintf(_T("Time taken: %gs Number of files: %d \n"), (double)((tmEnd - tmBegin)) / 1000.0f, (int)fileList.size());
307318
}
308319

309320
// Uninitialize

README_cn.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# NTFS 文件搜索库
22

3-
[English](README.md) | 中文
3+
中文 | [English](README.md)
44

55
一个快速搜索NTFS卷文件的库
66

7+
![image-20241220164721752](./assets/image-20241220164721752.png)
78

9+
![image-20241220164743397](./assets/image-20241220164743397.png)
810

911
## 特性
1012

@@ -147,6 +149,7 @@ using _tstring = std::wstring;
147149
using _tstring = std::string;
148150
#endif
149151

152+
150153
#ifndef _DEBUG
151154

152155
#ifdef _UNICODE
@@ -215,18 +218,18 @@ int _tmain(int argc, LPCTSTR argv[])
215218

216219
_tstring strDriveList = _T("");
217220
_tstring strDbPath = _T("");
218-
tmBegin = ::clock();
219221

220222
// 初始化
221223
NTFS_Search_Initialize_By_Drive_Letter(strDriveList.c_str(), strDbPath.c_str(), false);
222224
if (0 == NTFS_Search_GetCount())
223225
{
224226
_tprintf(_T("扫描指定驱动器: %s\n"), strDriveList.c_str());
227+
tmBegin = ::clock();
225228
NTFS_Search_Reset_By_Drive_Letter(strDriveList.c_str(), strDbPath.c_str(), true);
229+
tmEnd = ::clock();
226230
_tprintf(_T("扫描耗时: %d毫秒\n"), tmEnd - tmBegin);
227231
}
228232

229-
tmEnd = ::clock();
230233

231234
_tstring strKey;
232235

0 commit comments

Comments
 (0)