Fixed an edge case for dirname.