I'm using C and sometimes I have to handle paths like
Is there a way to check if a given path is a directory or a given path is a file?
stat() will tell you this.
struct stat s;
if( stat(path,&s) == 0 )
{
if( s.st_mode & S_IFDIR )
{
//it's a directory
}
else if( s.st_mode & S_IFREG )
{
//it's a file
}
else
{
//something else
}
}
else
{
//error
}