
Untitled
By: a guest on
Jun 13th, 2012 | syntax:
None | size: 0.73 KB | hits: 12 | expires: Never
Check folder path
bool directory_exists( 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;
}
}
// if any condition fails
return false;
}
bool file_exists( const std::string &filename )
{
if( !filename.empty() )
{
if( access(filename.c_str(), 0) == 0 )
{
struct stat status;
stat( filename.c_str(), &status );
if( !(status.st_mode & S_IFDIR) )
return true;
}
}
// if any condition fails
return false;
}