Fix dirname/basename edge cases on Windows