fix bug with deciding a file/dir, thanks to Jason