Try chdir() even if the file is not a directory.

This change allows navigation through symbolic links to directories.