From: Run Paint Run Run Date: 2010-03-06T05:32:09+09:00 Subject: [ruby-core:28517] Re: [Feature #1081] add File::write() convenience method >> Is it intended that the length of the leading nulls are not included >> in the return value? I assumed the second line in the example below >> would return 3. >> >> ��>> File.delete('/tmp/glark') #=> 1 >> ��>> File.write('/tmp/glark','s',2) #=> 1 >> ��>> File.read('/tmp/glark') #=> "\u0000\u0000s" > > > Intended. ��It currently returns the length actually written. ��The > \u0000s are padded by seek, not write. OK, just wanted to check. As for #binwrite, I'm also assuming that, at least on Linux, it's intentionally ignoring the offset, treating it instead as merely a cue to append. >> File.delete('/tmp/offset') #=> 1 >> File.write('/tmp/offset','ruby') #=> 4 >> File.write('/tmp/offset','ruby',2) #=> 4 >> File.size('/tmp/offset') #=> 6 >> File.delete('/tmp/offset') #=> 1 >> File.binwrite('/tmp/offset','ruby') #=> 4 >> File.binwrite('/tmp/offset','ruby',2) #=> 4 >> File.size('/tmp/offset') #=> 8