Project 1
#include <fstream>
#include <stdio.h>
#include <afx.h>
using namespace std;
fstream f("mytest.txt",ios::binary|ios::trunc|ios::out);
void Find(CString str)
{
WIN32_FIND_DATA fd;
HANDLE hf;
hf = FindFirstFile(str+"/*.*", &fd);
do
{
if((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)&& strcmp(fd.cFileName,"..")!=0 && strcmp(fd.cFileName,".")!=0)
{
Find(str+"/"+fd.cFileName);
}
if((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)!=FILE_ATTRIBUTE_DIRECTORY)
{//f << str+"/"+fd.cFileName <<"\r\n";
if((fd.cFileName[strlen(fd.cFileName)-4]=='.'&&fd.cFileName[strlen(fd.cFileName)-3]=='t'&&fd.cFileName[strlen(fd.cFileName)-2]=='x'&&fd.cFileName[strlen(fd.cFileName)-1]=='t')||
(fd.cFileName[strlen(fd.cFileName)-4]=='.'&&fd.cFileName[strlen(fd.cFileName)-3]=='c'&&fd.cFileName[strlen(fd.cFileName)-2]=='p'&&fd.cFileName[strlen(fd.cFileName)-1]=='p')||
(fd.cFileName[strlen(fd.cFileName)-3]=='.'&&fd.cFileName[strlen(fd.cFileName)-2]=='c'&&fd.cFileName[strlen(fd.cFileName)-1]=='s')||
(fd.cFileName[strlen(fd.cFileName)-2]=='.'&&fd.cFileName[strlen(fd.cFileName)-1]=='h'))
f << str+"/"+fd.cFileName <<"\r\n";
}
}while(FindNextFile(hf,&fd));
FindClose(hf);
}
void main(int argc, char *argv[])
{
CString str=argv[1];
Find(str);
return;
}
//文件路径分析基本完成!