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
| 81 void listImages()
82 {
83 vector<string> imgPaths;
84 string abs = getcwd(NULL, 256);
85 cout << abs << "!!!!!" << endl;
86
87 struct dirent *l;
88 DIR *rep;
89 rep = opendir(".");
90 string tmp, fileName;
91 int pos;
92 while (l = readdir(rep))
93 {
94 fileName = l->d_name;
95 for (int i=fileName.size()-1 ; i >= 0 ; i--)
96 {
97 if (fileName[i] == '.')
98 {
99 tmp = fileName.substr(i);
100 if (tmp == ".jpg" || tmp == ".bmp" || tmp == ".png" || tmp == ".tga" || tmp == ".gif")
101 imgPaths.push_back(fileName);
102 break;
103 }
104 }
105 }
106 closedir(rep);
107 for (int i=0 ; i<imgPaths.size() ; i++)
108 cout << imgPaths[i] << endl;
109 } |
Partager