Fix directory reading on OSX.