36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/memfs/io.rb', line 36
def self.write(path, string, offset = 0, open_args = nil)
open_args ||= [File::WRONLY, encoding: nil]
offset = 0 if offset.nil?
unless offset.respond_to?(:to_int)
fail TypeError, "no implicit conversion from #{offset.class}"
end
offset = offset.to_int
if offset > 0
fail NotImplementedError,
'MemFs::IO.write with offset not yet supported.'
end
file = open(path, *open_args)
file.seek(offset)
file.write(string)
ensure
file.close if file
end
|