Use a more direct check for finding out the file type.

No functionality change.