Check if a file is a dir in a cross platform manner

I noticed this bug only when I was working with Nikola on a Windows machine. The below patch should fix this.