check if path is a directory or not