Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Examination_IT / ComputerScience_LaboratoryWork_ForStudent

.pdf
Скачиваний:
13
Добавлен:
16.05.2015
Размер:
5.86 Mб
Скачать

191

%

:

( )

 

 

-

 

%

 

 

 

 

 

 

 

 

 

 

18

4

 

1.

- >

 

 

 

 

.

 

 

 

2.

D .

 

 

 

3.

D -

 

 

 

 

.

 

 

 

4.

-

 

 

 

 

.

 

 

 

5.

` >.

 

 

 

6.

e >

15.4.( *( 641(. - , +E(34

1.; B C

.

2.H ,

C , [

h->. - R > -

>, , R -

15.1.

3.- 15.4 C, -

A .

4.A > A.

5.- 15.1 >

.

6.- .

7.; , -.

8. .> .

9. R .

192

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)?

193

16. 16. 16.

-( " % 1 1

-( " % 1 1

16.1. %-./ .+E( +3( (5 +E(34

G A -

> > ,

.

> C B ( ) -1, ( . 16.1).

H. 16.1. . FindFil-, AB > -

B

16.2. -( -3,D- ,- 6-*- ,

` > B -

A , C

> . D > R

C C A R .

1 2 B - R > ,

>,

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];

};

196

H [ .

unsigned attrib >. D attrib

A AB > io.h : _A_ARCH >;

_A_HIDDEN >;

_A_NORMAL >

;

_A_RDONLY

> ;

_A_SUBDIR

– ;

_A_SYSTEM

>

time_t time_create >. 4

UTC (Coordinated Universal Time) >. - B

UTC A :-(GMT) A : (GMT) « » (UTC). > ctime_s.

time_t time_write >. 4 UTC >.

> ctime_s.

fsize_t size > .

UTC A > c_times, AB

errno_t ctime_s(

 

char * buffer,

>,

size_t numberOfElements,

 

>

const time_t *time

> UTC

);

 

. FindFile . 16.1.

> B

.

197

% "

-> -

. 2 -

, -

n14. 2 n14, -

[C:\]

[Document and Settings] [Wiktor]

[All Users]

[Downloads]

Jv16.rar

QIMP Infium.zip

PDF Creator Free.zip

[Program Files] [Windows]

Winnt.bmp

Explorer.exe

Mixer.exe

H. 16.2. =

>

>

A

A.

- , >

>, ^-

( . 16.2), - B

. e R -

, -

:

>, -

B R ,

>, B -

, R

FindFile ( 16.2).

, 3, 0 16.2. #+5. FindFile.cpp (63( + 6- , )

int SumFiles = 0; using namespace std;

bool FindFile(char *Path, char *Mask);

/////////////////////////////////////////////////////////////////

//

void _tmain()

{

setlocale(LC_CTYPE, "Russian_Russia.1251");

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.

Соседние файлы в папке Examination_IT