Fix mkdir error checking