Created
July 21, 2014 07:21
-
-
Save luoyetx/c6e754fcf257d82d2bc3 to your computer and use it in GitHub Desktop.
read Dir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <io.h> | |
/** | |
* readDir("F://pic", files, "jpg") | |
*/ | |
bool readDir(string dirPath, vector<string>& files, string extension) | |
{ | |
long fd; | |
_finddata_t fileInfo; | |
string matchPath = dirPath + "/*." + extension; | |
if ((fd=_findfirst(matchPath.c_str(), &fileInfo)) == -1) { | |
return false; | |
} | |
do { | |
files.push_back(fileInfo.name); | |
} while (_findnext(fd, &fileInfo) == 0); | |
_findclose(fd); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment