> File.length should be undefined for files and defined for directories,
while fileSize should be only available for regular files.

refer your commit log, I think your logic is opposite, am I wrong?