Fix for #1223

This is still broke.
What happens if you pass it a filename (not a directory), and that filename happens to be a symbolic link?