JRuby

(patch) File.dirname('C:\\') returns incorrect results

Details

  • Patch Submitted:
    Yes
  • Number of attachments :
    1

Description

File.dirname('C:\Temp') returns 'C:' when it should return 'C:
'

Patch corrects this (and also returns a path with the slashes pointing the original direction per MRI)

Issue Links

Activity

Hide
Charles Oliver Nutter added a comment -

This is a tricky area for us. C Ruby changes its behavior to support windows in ways that would break code on other platforms. In order for us to provide a single binary that runs everywhere, we need to be able to recognize that we're on a Windows platform and provide different behavior. This appear to be one of those cases:

~/NetBeansProjects/jruby-1_0 $ ruby -e "p File.dirname('C:\Temp')"
"."
~/NetBeansProjects/jruby-1_0 $ ruby -e "p File.dirname('C:/Temp')"
"C:"

Can you look into a way to do this conditionally depending on whether we're on Windows or not?

Show
Charles Oliver Nutter added a comment - This is a tricky area for us. C Ruby changes its behavior to support windows in ways that would break code on other platforms. In order for us to provide a single binary that runs everywhere, we need to be able to recognize that we're on a Windows platform and provide different behavior. This appear to be one of those cases:
~/NetBeansProjects/jruby-1_0 $ ruby -e "p File.dirname('C:\Temp')"
"."
~/NetBeansProjects/jruby-1_0 $ ruby -e "p File.dirname('C:/Temp')"
"C:"
Can you look into a way to do this conditionally depending on whether we're on Windows or not?
Hide
Peter Brant added a comment -

Updated patch. Windows specific code only executes on Windows. A couple of additional corner cases have also been addressed.

Show
Peter Brant added a comment - Updated patch. Windows specific code only executes on Windows. A couple of additional corner cases have also been addressed.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: