Skip to content

Instantly share code, notes, and snippets.

@ruabmbua
Created January 8, 2015 13:46
Show Gist options
  • Save ruabmbua/f9eaa38c2f7c8fbb6a6d to your computer and use it in GitHub Desktop.
Save ruabmbua/f9eaa38c2f7c8fbb6a6d to your computer and use it in GitHub Desktop.
Cross platform directory exists check
bool directoryExists(const std::string &directory)
{
if(!directory.empty())
{
if(access(directory.c_str(), 0) == 0)
{
struct stat status;
stat(directory.c_str(), &status);
if(status.st_mode & S_IFDIR)
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment