Use getFileStatus instead of Path::isDirectory().