Seems like a dirty way of testing for a directory, and could be incorrect for a zero byte file (which we use for locks, etc). Is there no cleaner way?