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