Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
File.open with open mode a+ do not work #4348
jruby 126.96.36.199 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit Server VM 25.40-b25 on 1.8.0_40-b26 +jit [mswin32-x86_64]
In version 188.8.131.52 of Jruby when i use the a+ mode for opening and writing to a file the pointer is at the begining of the file.
The expected behaviour is to position at the end of the file for appending.
date_now = Time.now
Is this a windows-only bug?
I just tested this on debian/jessie:
@limmet can you tell me if you just happened to be playing with a+ and noticed this or you had a real use case which needs a+? I have been trying to figure out what people use a+ for and would love a real world use case for it. I tried searching online and I got either: a) how does a+ work b) your impl does not support a+ properly c) I am using a+ and it does this weird thing.
So quick note on this one. We did not support a+ when native was disabled OR on windows where we still use pure-Java code for this. The behavior is new to me and I used to do C a gazillion years ago. In a+ mode, you can seek and read all you want but if you write then because O_APPEND is set it will write to the end of the file. Even if you seeked away from the end at some point.