Examination_IT / ComputerScience_LaboratoryWork_ForStudent
.pdf192
15.5. -E(6+ , (*- 2+ ,j (3D-3+
. :
1);
2)> cpp h;
3)R .
( 3 (./ 4- 6(1 ( 4
1.D .
2.! >?
3.; A A ?
4.! C ?
5.!
#ifndef __LIST__H__
> List.h ( 15.1)?
194
.0( ,3>4 1(, + 9+5.(6 + 2- 3 (> *, -
7 >, ,
: . -
> B -
, , -
A.
% " "
> A >:
_findfirst _findnext. Q _findfirst -
> B AB -1, - C, > _findnext AB -. D C > A _findclose, AB A B . D
R > > cpp B ,
16.1.
, 3, 0 16.1. #+5. FindFile.cpp (1- 6+ 6- , )
// ! : I J K L. #include "stdafx.h"
#include <stdlib.h> #include <io.h> #include <time.h> #include <cstringt.h> #include <iostream>
#define LIM_STR 255
void _tmain()
{
setlocale(LC_CTYPE, "Russian_Russia.1251"); char szBuffer[LIM_STR];
struct _finddata_t findData; intptr_t hFile;
195
//K L ; cpp e L
//% %.
if( (hFile = _findfirst( "*.cpp", &findData )) == -1L )
cout << "~ L J *.cpp e L % %" " :!" << endl;
else
{
cout << "~ L J *.cpp" << endl << endl; cout << setw(18) << "" K L" << setw(28)
<< " I!";
cout << setw(12) << "w I" << setw(12) << "{ J"<<endl << endl;
do
{
//I K UTC
//: .
ctime_s( szBuffer, _countof(szBuffer), &findData.time_write );
szBuffer[strlen(szBuffer)-1] = NULL;
cout << setw(18) << findData.name << setw(28)
<<szBuffer << setw(12) << findData.size
<<" ";
cout << setfill(' ') << setw(8); findData.attrib & _A_RDONLY ?
cout << "r" : cout << "-";
//k(v † ! !, J% :e L J !
//_ , L! K L. cout << endl;
}while( _findnext( hFile, &findData ) == 0 );
_findclose( hFile );
}
system("pause");
}
; _finddata_t findData > A
>. 4 AB .
struct _finddata_t { unsigned attrib; time_t time_create; time_t time_access; time_t time_write; fsize_t size;
char name[_MAX_PATH];
};
198
FindFile("C:\\Windows", "*.bmp");
cout << " I . " "R L! K L: " << SumFiles << endl;
system("pause");
}
bool FindFile(char *Path, char *Mask)
{
struct _finddata_t findData; intptr_t hFile;
char FullName1[_MAX_PATH];
//k(v † K L K L % % % I Q J
//; % _ FullName1.
//% %
if( (hFile = _findfirst( FullName1, &findData )) != -1L ) do
{
if( findData.attrib & _A_SUBDIR && (_strcmpi(findData.name, ".") && _strcmpi(findData.name, "..")))
{
//R{j " rŸvRR‘• { z‘. char NextPath[_MAX_PATH];
//k(v † K L 9 L % %
//% _ NextPath.
//w JL JI K FindFile. FindFile(NextPath, Mask);
}
} while (_findnext( hFile, &findData ) == 0); _findclose( hFile );
//K L % e L % %. char FullName2[_MAX_PATH];
//k(v † K L K L, ! 9 e Mask,
//% FullName2.
if( (hFile = _findfirst( FullName2, &findData )) == -1L ) return true;
do
{
SumFiles++; |
// L! J |
//K L.
//k(v † I ! J ! _ K
//L! J K L.
}while (_findnext( hFile, &findData ) == 0);
_findclose( hFile );
return true;
}
199
e ,
1, [ .
16.3.+ ,+ 34 )+*+ ,5
% |
: |
; |
|
||
1 |
1 |
D > B |
2 |
1 |
D > B |
|
|
A > |
3 |
2 |
D > B - |
|
|
|
4 |
3 |
D > B |
|
|
A > - |
|
|
A > |
5 |
3 |
D > B - |
|
|
A |
|
|
> |
6 |
4 |
D > B - |
|
|
A > |
|
|
|
|
|
> |
H 3 6.
1.= > A > R -
, B ( n15), R-
struct DItem
{
// , ! ! J K L. struct _finddata_t findData;
DItem *prev, *next;
};
AB
1V B , . -
– . ; ‘*’ – ,
A B
A . D ‘?’ . D
A ‘\’. H C > – ‘.’.
200
>:
//I! JL _ %. DItem* CreateItem();
//( JL _ % . void Add(DItem *end, DItem *NewElem);
2.D -
_finddata_t.
3.D .
4. .
R ( n12).
16.4.( *( 641(. - , +E(34
1.P C .
2.; -.
3.D .
4.D .
5.R .
16.5.-E(6+ , (*- 2+ ,j (3D-3+
. :
1)> ;
2);
3), B:
>;
>;
4)> B A -
, -
Windows.