add Pathname.write_binary
This commit is contained in:
parent
90762c2f18
commit
10e5fea01d
@ -93,6 +93,12 @@ class Pathname
|
|||||||
open("w", *open_args) { |f| f.write(content) }
|
open("w", *open_args) { |f| f.write(content) }
|
||||||
end
|
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
|
# NOTE always overwrites
|
||||||
def atomic_write content
|
def atomic_write content
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user