check whether a file or directory from path