bool file_exists(const std::string& name)
{
struct stat info;
return (stat(name.c_str(), &info) == 0);
}
bool dir_exists(const std::string& path)
{
struct stat info;
if(stat(path.c_str(), &info) != 0)
return false; // cannot access
if(info.st_mode & S_IFDIR)
return true;
return false;
}