aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend
diff options
context:
space:
mode:
authorAdam Vandenberg2014-07-27 10:34:14 -0700
committerAdam Vandenberg2014-07-27 11:14:51 -0700
commit79e815be467cdb425d728c2b16f832ebaedc956c (patch)
tree639e9bd5880c57e8992477983457bd66a499b3e4 /Library/Homebrew/extend
parentb415dda113bb2ee3948cb693efb9682a0232e9a2 (diff)
downloadhomebrew-79e815be467cdb425d728c2b16f832ebaedc956c.tar.bz2
add Pathname.write_binary
Diffstat (limited to 'Library/Homebrew/extend')
-rw-r--r--Library/Homebrew/extend/pathname.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 4ba5b7803..382dc5a71 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -93,6 +93,12 @@ class Pathname
open("w", *open_args) { |f| f.write(content) }
end
+ def write_binary binary_content
+ raise "Will not overwrite #{to_s}" if exist?
+ dirname.mkpath
+ File.open(self, 'wb') {|f| f.write binary_content }
+ end
+
# NOTE always overwrites
def atomic_write content
require "tempfile"