@igorrr37
1815 / 1433 / 214
Регистрация: 21.12.2010
Сообщений: 2,341
|
19.12.2012, 13:49
|
|
борланда нет, на студии работает
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
| #include <iostream>
#include <string>
#include <cstdio>
#include <Windows.h>
#include <tchar.h>
typedef std::basic_string<TCHAR> tstring;
tstring indent, incindent(_T(" "));
DWORD counter;
void PrintRecursive(tstring const& dirpath, PWIN32_FIND_DATA pfd, DWORD const limit)
{
indent += incindent;
HANDLE hFile = FindFirstFile((dirpath + _T('/') + _T("*.*")).c_str(), pfd);
if(INVALID_HANDLE_VALUE != hFile)
{
do
{
if(tstring(pfd->cFileName) != tstring(_T(".")) &&
tstring(pfd->cFileName) != tstring(_T("..")))
{
if(FILE_ATTRIBUTE_DIRECTORY == pfd->dwFileAttributes)
{
_tprintf(_T("%s%s\n"), indent.c_str(), (dirpath + _T('/') + pfd->cFileName).c_str());
PrintRecursive(dirpath + _T('/') + pfd->cFileName, pfd, limit);
}
else if(pfd->nFileSizeLow <= limit)
{
_tprintf(_T("%s%-24s%u\n"), indent.c_str(), pfd->cFileName, pfd->nFileSizeLow);
++counter;
}
}
}
while(FindNextFile(hFile, pfd));
FindClose(hFile);
}
else
std::cerr << "FindFirstFile failed: " << GetLastError() << std::endl;
indent.resize(indent.size() - incindent.size());
}
int main ()
{
SetConsoleOutputCP(1251);
WIN32_FIND_DATA fd;
DWORD limit = 2612; // максимальный размер файла
tstring dirpath(_T("c:/Test")); // директория для поиска
_tprintf(_T("%s\n"), dirpath.c_str());
PrintRecursive(dirpath, &fd, limit);
_tprintf(_T("\ncounter: %u\n"), counter);
return 0;
} |
|
1
|