,   CyberForum.ru

. - C++

 
d2funlife
0 / 0 / 0
: 08.03.2011
: 17
15.04.2011, 20:39     . #1
:
txt, , : ...
, ?
Similar
41792 / 34177 / 6122
: 12.04.2006
: 57,940
15.04.2011, 20:39     .
:

C++
C++
C++
C++
C++
C++
C++
C++
C++
C++
2 C++
C++



:
.
kravam
   kravam
1513 / 873 / 44
: 04.06.2008
: 5,301
15.04.2011, 21:29     . #2
,
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <windows.h>
#include <stdio.h>
 
long int rez= 0;
 
void GetFileList(LPTSTR sPath, LPTSTR sExt, LPTSTR sEXT);
 
int main(){
 
//Ïîñêîëüêó sPath è sExt è sEXT îäè**êîâû âî âñåõ âûçîâ*õ GetFileList, èõ ìîæ*î áûëî áû ñäåë*òü
//ãëîá*ëü*ûìè, *î ÿ ò*ê îñò*âèë. 
//        char sPath[MAX_PATH]= "E:\\Microsoft_Visual_Studio_9.0";
        char sPath[MAX_PATH]= "C:\\";
//        char sPath[MAX_PATH]= "C:\\vso_moio";
//        char sPath[MAX_PATH]= "C:\\vso_moio";
 
//Îáð*òèòü  â*èì**èå ** ð*çìåð ì*ññèâ*!
        char sExt[10]= "exe";
        char sEXT[10]= "EXE";
        GetFileList(sPath, sExt, sEXT);
//Ïîðòèò âñ¸ äåëî: Åñëè ïåðå**ïð*âëÿòü â ô*éë ñ êî*ñîëè, òî ïîëó*÷*åòñÿ, ÷òî â êî*ñîë âåäóò 
//ç*ïèñü äâ* ð*ç*ûõ ïîòîê*- òîò,êîòîðûé *óæå*ò è ýòîò,êîòîðûé ç*ïèñûâ*åò "Äëÿ ïðîäëæå*èÿ **æìèòå ëþáóþ
//êë*âèøó" è ýò* **äïèñü âêëè*èâ*åòñÿ â ñåð¸äêó è ïîðòèò âñ¸ äåëî
      printf("rez= %d\n", rez);
  system ("PAUSE");
}
 
void GetFileList(LPTSTR sPath, LPTSTR sExt, LPTSTR sEXT) {
 
 WIN32_FIND_DATA pFILEDATA;
 
 HANDLE hFile = FindFirstFile(strcat(sPath,"\\*.*"),&pFILEDATA);
 
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!Íåîáõîäèìî èìå**î çäåñü ïðîïèñûâ*òü äëè*ó ïóòè!!!!!!!!!!!!!!!!!!!!!!!
 sPath[strlen(sPath) - strlen(strstr(sPath,"*.*"))] = '\0';
//Åñëè ïðîïèøåì ïîñëå if (ê*ê ïðåäë*ã*åò Þð*), òî òîãä*, åñëè âäðóã **òûê*åìñÿ ** ñèñòåì*óþ äèðåêòîðèþ
// èëè ô*éë, òî FindFirstFile âîçâð*ù*åò -1. Ñëåäîâ*òåëü*î, âñ¸, ÷òî âûïë**ÿåòñÿ ïî óñëîâèþ
//(hFile!=INVALID_HANDLE_VALUE) *å âûîë*èòñÿ è â ÷*ñò*îñòè, *å áóäåò ïîñò*âëå* êî*åö ñòðîêè!
//À ýòî ç**÷èò, ÷òî ïî âûõîäó èç  ðåêóðñèâ*îé ôó*êöèè GetFileList â òîì ìåñòå, ãäå ìû âîññò***âëèâ*åì
//Äëè*ó, î** áóäåò âîññò**îâëå** *åïð*âèëü*î
 if (hFile!=INVALID_HANDLE_VALUE)    {
  char * chBuf;
  //sPath[strlen(sPath) - strlen(strstr(sPath,"*.*"))] = '\0';
  do {
   //Ïðîïóñê*åì . è ..
   if (strlen(pFILEDATA.cFileName) == 1 &&  strchr(pFILEDATA.cFileName,'.') !=NULL)
    if (FindNextFile(hFile,&pFILEDATA) == 0)
      break;
   if (strlen(pFILEDATA.cFileName) == 2 && strstr(pFILEDATA.cFileName,"..") !=NULL)
    if(FindNextFile(hFile,&pFILEDATA) == 0)
      break;
     //Åñëè **øëè äèðåêòîðèþ, ç*ïóñê*åì ïîèñê â *åé ðåêóðñèâ*ûé ïîèñê
   if(pFILEDATA.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
     GetFileList(strcat(sPath,pFILEDATA.cFileName), sExt, sEXT);
 
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!îÁßÇÀÒÅËÜÍ âîñò***âëèâ*òü äëëè*ó ïóòè................................     
     sPath[strlen(sPath) - strlen(pFILEDATA.cFileName)- 1] = '\0';
   }
   else {
    //Ïðîâåðÿåì ** ñîîòâåñòâèå sExt ð*ñøèðå*èÿ pFILEDATA.cFileName
    if((chBuf = strrchr(pFILEDATA.cFileName,'.'))) {
     if(strstr(chBuf + 1,sExt)|| strstr(chBuf + 1,sEXT)) {
      //Åñëè *å áóäåì èñïîëüçîâ*òü CharToOem() òî ** ýêð**å ðóññêèé øðèôò ê*ð*êóëÿìè âûéäåò
      CharToOem(sPath,sPath);
      printf("%s",sPath);
      OemToChar(sPath,sPath);
      CharToOem(pFILEDATA.cFileName,pFILEDATA.cFileName);
      printf("%s\n",pFILEDATA.cFileName);
      rez++;
     }
    }
   }
  }
  while (FindNextFile(hFile,&pFILEDATA));
 }
}
.
Yandex
15.04.2011, 21:29     .

: 01:31. GMT +3.
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
@Mail.ru