How do I check if a directory exists? “is_dir”, “file_exists” or both?

Both would return true on Unix systems – in Unix everything is a file, including directories. But to test if that name is taken, you should check both. There might be a regular file named ‘foo’, which would prevent you from creating a directory name ‘foo’.

Leave a Comment