Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File.write does not respect binary file mode options in jruby 1.7.4 on Windows #855

Closed
iaddict opened this issue Jul 4, 2013 · 1 comment

Comments

@iaddict
Copy link
Contributor

iaddict commented Jul 4, 2013

File.write may be called with a mode option 'wb' that prevents the default behavior of changing \n to \r\n on Windows. This behaviour does not work with jruby. A normal File.open with mode 'wb' does work. Please have a look at the following example irb session.

=> "jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) Client VM 1.6.0_21-b07 [Windows 7-x86]"
irb(main):017:0> File.open('test1.txt', mode: 'wb') {|f| f.write("\n")}
=> 1
irb(main):018:0> File.write('test1.txt', "\n", mode: 'wb') # writes two bytes instead of one
=> 2
@lolindrath
Copy link

I believe this is fixed in JRuby 1.7.12 on Windows 7 x64, I think this can be closed.

Here's my jirb session:

C:\Users\Lolindrath\Downloads>jirb
irb(main):001:0> File.open('test1.txt', mode: 'wb') {|f| f.write("\n")}
=> 1
irb(main):002:0> File.write('test1.txt', "\n", mode: 'wb') # writes two bytes instead of one
=> 1

@kares kares closed this as completed Apr 8, 2016
@kares kares added this to the JRuby 1.7.12 milestone Apr 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants