If I'm copying from an existing file I could do something like this
file = tree.open_file(filename: file, write: true, disposition: RubySMB::Dispositions::FILE_OVERWRITE_IF)
data = File.read(source_file)
result = file.write(data: data)
puts result.to_s
file.close
Is there perhaps a better way to simply copy an existing file (and overwrite on the destination) without having to read the source file into memory? I'm looking to copy over a file with tens of thousands of lines.
Maybe something like this?
file = tree.open_file(filename: file, write: true, disposition: RubySMB::Dispositions::FILE_OVERWRITE_IF)
line_num = 0
data = File.foreach(source_file) do |line|
if line_num.zero?
file.write data: line
else
file.append data: line
end
line_num += 1
end
puts "Wrote #{line_num} lines"
file.close
I see in the write_file example we can write some data to a file.
If I'm copying from an existing file I could do something like this
Is there perhaps a better way to simply copy an existing file (and overwrite on the destination) without having to read the source file into memory? I'm looking to copy over a file with tens of thousands of lines.
Maybe something like this?