Skip to content

Instantly share code, notes, and snippets.

@take-cheeze
Created October 20, 2012 12:54
Show Gist options
  • Select an option

  • Save take-cheeze/3923196 to your computer and use it in GitHub Desktop.

Select an option

Save take-cheeze/3923196 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cstdlib>
#include <boost/filesystem.hpp>
#include <boost/regex.hpp>
namespace fs = boost::filesystem;
bool is_rpg2k_project(fs::path const& p)
{
if(! fs::is_directory(p)) { return false; }
bool has_ldb = false, has_lmt = false;
static boost::regex const
LDB_MATCHER("RPG_RT.ldb", boost::regex::icase),
LMT_MATCHER("RPG_RT.lmt", boost::regex::icase);
fs::directory_iterator i(p), end;
for(; i != end; ++i) {
if(boost::regex_match(i->path().filename().c_str(), LDB_MATCHER)) { has_ldb = true; }
if(boost::regex_match(i->path().filename().c_str(), LMT_MATCHER)) { has_lmt = true; }
}
return has_lmt && has_ldb;
}
int main()
{
fs::directory_iterator i(fs::current_path()), end;
for(; i != end; ++i) {
std::cout << i->path().filename() << ":"
<< is_rpg2k_project(i->path().filename()) << std::endl;
}
return EXIT_SUCCESS;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment