Fix exists() handling of directory prefix check.