REFACTORING: supporting flag about receiving an offset or not. #722

merged 1 commit into from May 10, 2013


None yet

3 participants


This is important so we can fix all the specs related to write/binwrite. I've tried to make the change in a lot of ways but all of them look very ugly. So I decided to ask feedback from you that know more the code base. @hedius @enebo

PS: write/binwrite specs need this because ruby doens't truncate the file an offset is given


Misspelled "hasOffset".

@headius headius merged commit d9a1e1d into jruby:master May 10, 2013

1 check failed

default The Travis CI build could not complete due to an error
headius commented May 10, 2013

I'll fix the misspelling. Thanks!

@josedonizetti josedonizetti deleted the josedonizetti:supporting_offset branch May 10, 2013

So if I am reading this correctly this says:

If the last parameter to or is a boolean then it has an offset.

But when I look at the ruby docs: I don't see any mention of this.

This seems to break the following rubyspecs:

because they pass in a boolean to or which doesn't really have anything to do with having an offset.

atambo commented May 11, 2013

So I think what you are trying to do is satisfy the following sentence from the docs of IO.binwrite (

If offset is not given, the file is truncated. Otherwise, it is not truncated.

You don't need to inject a boolean as a flag into all of these methods. The way this should be done is just add:

file.openFile.setMode(file.openFile.getMode() | ModeFlags.TRUNC);

inside of the IO.binwrite method in the right spot and the ChannelDescriptor will just handle the truncation for you.

I think we should just revert this commit and retry using the approach above.

atambo commented May 11, 2013

So what I said above totally wasn't necessary it was as simple as changing the mode from "wb" to "r+w". See #726.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment