Use stat() and realpath() to improve handling of file parameters.