2021-04-25 20:22:33 +02:00
|
|
|
module io
|
|
|
|
|
|
|
|
const (
|
2021-04-26 08:59:23 +02:00
|
|
|
buf_max_len = 1024
|
2021-04-25 20:22:33 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
pub fn cp(dst Writer, src Reader) ? {
|
2021-04-26 08:59:23 +02:00
|
|
|
mut buf := []byte{len: buf_max_len}
|
|
|
|
for {
|
|
|
|
len := src.read(mut buf) or { break }
|
|
|
|
dst.write(buf[..len]) or {
|
|
|
|
return err
|
|
|
|
}
|
2021-04-25 20:22:33 +02:00
|
|
|
}
|
|
|
|
unsafe {
|
|
|
|
buf.free()
|
|
|
|
}
|
|
|
|
}
|