Skip to content
Snippets Groups Projects
Commit 5af3d319 authored by Adam Vandenberg's avatar Adam Vandenberg
Browse files

backport binwrite from Ruby 2.1+

parent 8e96ce0a
No related branches found
No related tags found
No related merge requests found
......@@ -93,12 +93,9 @@ class Pathname
open("w", *open_args) { |f| f.write(content) }
end
# Note: Ruby 2.1+ has Pathname#write and Pathname#binwrite
def binwrite binary_content
raise "Will not overwrite #{to_s}" if exist?
dirname.mkpath
File.open(self, 'wb') {|f| f.write binary_content }
end
def binwrite(contents, *open_args)
open("wb", *open_args) { |f| f.write(contents) }
end unless method_defined?(:binwrite)
# NOTE always overwrites
def atomic_write content
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment