getbinaryfile(remotefile, localfile = File.basename(remotefile), blocksize = DEFAULT_BLOCKSIZE)
public
Retrieves remotefile in binary mode, storing the result in
localfile. If a block is supplied, it is passed the retrieved data
in blocksize chunks.
Show source
def getbinaryfile(remotefile, localfile = File.basename(remotefile),
blocksize = DEFAULT_BLOCKSIZE, &block)
if @resume
rest_offset = File.size?(localfile)
f = open(localfile, "a")
else
rest_offset = nil
f = open(localfile, "w")
end
begin
f.binmode
retrbinary("RETR " + remotefile, blocksize, rest_offset) do |data|
f.write(data)
yield(data) if block
end
ensure
f.close
end
end