Fix dirname for MacOSX.