Skip to content

Instantly share code, notes, and snippets.

@nariakiiwatani
Last active May 17, 2021 04:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nariakiiwatani/dabf4cd2d04ad015bb6fabdedef7b2aa to your computer and use it in GitHub Desktop.
Save nariakiiwatani/dabf4cd2d04ad015bb6fabdedef7b2aa to your computer and use it in GitHub Desktop.
namespace ImGui
{
static bool SelectFile(const std::string &path, std::string &selected, const std::vector<std::string> &ext={}) {
bool ret = false;
if(ofFile(path).isDirectory()) {
if(TreeNode(ofFilePath::getBaseName(path).c_str())) {
ofDirectory dir;
if(!ext.empty()) {
dir.allowExt("");
for(auto &&e : ext) {
dir.allowExt(e);
}
}
dir.listDir(path);
for(auto &f : dir) {
ret |= SelectFile(f.path(), selected, ext);
}
TreePop();
}
}
else if(Button(ofFilePath::getFileName(path).c_str())) {
selected = path;
ret = true;
}
return ret;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment