io: make io.cp use chunks (#9877)
parent
7acb48df83
commit
f5ce9388de
|
@ -1,15 +1,16 @@
|
|||
module io
|
||||
|
||||
const (
|
||||
buf_max_len = 5 * 1024
|
||||
buf_max_len = 1024
|
||||
)
|
||||
|
||||
pub fn cp(dst Writer, src Reader) ? {
|
||||
mut buf := read_all(reader: src) or {
|
||||
mut buf := []byte{len: buf_max_len}
|
||||
for {
|
||||
len := src.read(mut buf) or { break }
|
||||
dst.write(buf[..len]) or {
|
||||
return err
|
||||
}
|
||||
dst.write(buf) or {
|
||||
return
|
||||
}
|
||||
unsafe {
|
||||
buf.free()
|
||||
|
|
Loading…
Reference in New Issue