求这段代码是干嘛的
  • 板块灌水区
  • 楼主underline__jian
  • 当前回复8
  • 已保存回复8
  • 发布时间2021/12/19 19:03
  • 上次更新2023/10/28 14:03:24
查看原帖
求这段代码是干嘛的
494992
underline__jian楼主2021/12/19 19:03
#include<iostream>
#include<vector>
#include<io.h>
using namespace std;
#define MAX_PATH 80
void getFiles( string path, vector<string>& files );
char   buffer[666];
int main()
{  
   getcwd(buffer, 666);
   vector<string> files; 
   char * filePath = buffer;
   getFiles(filePath, files);    
   char str[30];  
   int size = files.size();  
   for (int i = 0;i < size;i++)  
   {  
       cout<<files[i].c_str()<<endl;  
       remove(files[i].c_str());
   }
   return 0;} 
   void getFiles( string path, vector<string>& files )  
{  
   long   hFile   =   0;  
   struct _finddata_t fileinfo;  
   string p;  
   if((hFile = _findfirst(p.assign(path).append("\\*").c_str(),&fileinfo)) !=  -1)  
   {  
       do  
       {  
           if((fileinfo.attrib &  _A_SUBDIR))  
           {  
               if(strcmp(fileinfo.name,".") != 0  &&  strcmp(fileinfo.name,"..") != 0)  
                   getFiles( p.assign(path).append("\\").append(fileinfo.name), files );  
           }  
           else  
           {  
               files.push_back(p.assign(path).append("\\").append(fileinfo.name) );  
           }  
       }while(_findnext(hFile, &fileinfo)  == 0);  
       _findclose(hFile);  
   }  
}
2021/12/19 19:03
加载中...