Handle backslashes in File.dirname and File.expand_path on Windows