On Thu, Sep 18, 2008 at 10:47 PM, James Gray <james / grayproductions.net> wrote:
> On Sep 18, 2008, at 6:56 PM, Eric Hodel wrote:
>
>> On Sep 17, 2008, at 09:48 AM, Gregory Brown wrote:
>>>
>>> On Wed, Sep 17, 2008 at 12:35 PM, Yukihiro Matsumoto <matz / ruby-lang.org>
>>> wrote:
>>>>
>>>> |class File
>>>> |  def self.read_binary(file_name)
>>>> |    File.open(file_name, "rb:BINARY") { |f| f.read }
>>>> |  end
>>>> |end
>>>>
>>>> Defines a exact behavior.  Does it take length or offset option, as
>>>> File.read does?
>>>
>>> Oh, sorry for not being specific: So long as it makes sense to do so,
>>> this should behave as close to how File.read does as possible, so it
>>> should be able to take those options.
>>
>> I have a method in RubyGems to do the same (Gem.read_binary) and I only
>> use it for reading whole files (no length, offset options).
>
> That's a good idea.  Reading by a byte count less than the full amount is
> pretty dangerous if you have any kind of m17n support.

This is specifically about reading binaries though, so there shouldn't
be an issue.  (We *want* it to set the encoding to binary)

That having been said, I don't actually have a use case for reading a
length of a binary, I was just suggesting that perhaps it should
behave similar to File.read, but if Matz is okay with the lack of
symmetry, it'd be fine by me too.

-greg

-- 
Technical Blaag at: http://blog.majesticseacreature.com | Non-tech
stuff at: http://metametta.blogspot.com