forked from controny/LogoReader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread.cpp
46 lines (39 loc) · 1.35 KB
/
read.cpp
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
# include <iostream>
# include <io.h>
# include <string>
# include <vector>
using namespace std;
int order = 0;
void getFiles(string path, vector<vector<string> >& infor) {
long hFile = 0;
struct _finddata_t fileinfor;
string p;
hFile = _findfirst(p.assign(path).append("/*").c_str(), &fileinfor);
if (hFile != -1) {
do {
if (fileinfor.attrib & _A_SUBDIR) {
string curFile = fileinfor.name;
cout << p.assign(path).append("/").append(curFile) << endl;
getFiles(p.assign(path).append("/").append(curFile), infor);
infor.push_back(vector<string>());
} else {
infor[order].push_back(p.assign(path).append("/").append(fileinfor.name));
}
} while(_findnext(hFile, &fileinfor) == 0);
++order;
// cout << order << endl;
_findclose(hFile);
}
}
int main() {
string path = "/root/Desktop/LogoReader/data/CarLogos51";
cout << path << endl;
vector<vector<string> > all;
getFiles(path, all);
for (int i = 0; i < all.size(); ++i) {
for (int j = 0; j < all[i].size(); ++j) {
cout << all[i][j] << " ";
}
cout << endl;
}
}