HomePhorge

(#11955) Refactor to use IO.binread
f56a09addd08Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(#11955) Refactor to use IO.binread

Previously, I had created a utility method Puppet::Util.binread,
since IO.binread was added in ruby 1.9. This commit monkey patches
the method, if it's not defined, to make the transition to ruby 1.9
seamless. And while I was at it, I add the corresponding IO.binwrite
method.

The motivation for these methods is that, in general, we should always
be using binary mode when performing file I/O. However, text mode is
the default on Windows, and using text mode can corrupt binary data,
e.g. executables. So use binary mode, unless you know what text mode
is and why you need to use it.

Conflicts:

spec/unit/file_serving/content_spec.rb

Details

Provenance
Josh Cooper <josh@puppetlabs.com>Authored on
Jeff McCune <jeff@puppetlabs.com>Committed on Jan 23 2012, 6:41 PM
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU8202729ede07: (#11955) Monkey patch IO.binread and IO.binwrite
Branches
Unknown
Tags
Unknown

Event Timeline

Jeff McCune <jeff@puppetlabs.com> committed rPUf56a09addd08: (#11955) Refactor to use IO.binread (authored by Josh Cooper <josh@puppetlabs.com>).Jan 23 2012, 6:41 PM