-
-
- #include "stdafx.h"
- #include <string>
- #include <io.h>
- #include <vector>
- #include <iostream>
-
- using namespace std;
-
-
-
-
-
-
-
-
-
-
-
-
-
- void getFiles(string path, string exd, vector<string>& files)
- {
-
-
- long hFile = 0;
-
- struct _finddata_t fileinfo;
- string pathName, exdName;
-
- if (0 != strcmp(exd.c_str(), ""))
- {
- exdName = "\\*." + exd;
- }
- else
- {
- exdName = "\\*";
- }
-
- if ((hFile = _findfirst(pathName.assign(path).append(exdName).c_str(), &fileinfo)) != -1)
- {
- do
- {
-
-
-
-
- if ((fileinfo.attrib & _A_SUBDIR))
- {
- if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
- getFiles(pathName.assign(path).append("\\").append(fileinfo.name), exd, files);
- }
- else
- {
- if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
- files.push_back(pathName.assign(path).append("\\").append(fileinfo.name));
- }
- } while (_findnext(hFile, &fileinfo) == 0);
- _findclose(hFile);
- }
- }
-
- void main()
- {
- cout << "start list" << endl;
- vector<string> files;
- char * filePath = "D:\\SeetaFaceEngine-master";
-
-
-
-
-
- getFiles(filePath, "*", files);
-
-
- FILE* fp;
- fopen_s(&fp, "d:\\dir_list.txt", "w");
-
- int size = files.size();
- for (int i = 0; i < size; i++)
- {
- cout << files[i] << endl;
-
- fputs(files[i].c_str(), fp);
- fputs("\n", fp);
-
- }
- fclose(fp);
-
- cout << "end list" << endl;
- getchar();
-
- }