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
|
|
|
)
|
|
|
|
|
2021-10-11 14:41:31 +02:00
|
|
|
pub fn cp(mut src Reader, mut dst Writer) ? {
|
2022-04-15 14:35:35 +02:00
|
|
|
mut buf := []u8{len: io.buf_max_len}
|
2021-04-26 08:59:23 +02:00
|
|
|
for {
|
|
|
|
len := src.read(mut buf) or { break }
|
2021-05-08 12:32:29 +02:00
|
|
|
dst.write(buf[..len]) or { return err }
|
2021-04-25 20:22:33 +02:00
|
|
|
}
|
|
|
|
unsafe {
|
|
|
|
buf.free()
|
|
|
|
}
|
|
|
|
}
|