Created
February 19, 2016 23:20
-
-
Save aman-tiwari/daa815b4c6e938875017 to your computer and use it in GitHub Desktop.
Recursive directory search in openframeworks
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
const string allowed_ext[] = {"jpg", "png", "gif", "jpeg"}; //File types detected by the search | |
vector<ofFile> files; | |
void ofApp::scan_dir(ofDirectory dir){ | |
ofDirectory new_dir; | |
int size = dir.listDir(); | |
for (int i = 0; i < size; i++){ | |
if (dir.getFile(i).isDirectory()){ | |
new_dir = ofDirectory(dir.getFile(i).getAbsolutePath()); | |
new_dir.listDir(); | |
new_dir.sort(); | |
scan_dir(new_dir); | |
} else if (std::find(std::begin(allowed_ext), | |
std::end(allowed_ext), | |
dir.getFile(i).getExtension()) != std::end(allowed_ext)) { | |
files.push_back(dir.getFile(i)); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment