Implement asyncfile.readToStream.
This commit is contained in:
parent
f2ca6021dc
commit
0cad2896ae
1 changed files with 10 additions and 0 deletions
|
|
@ -489,3 +489,13 @@ proc writeFromStream*(f: AsyncFile, fs: FutureStream[string]) {.async.} =
|
||||||
await f.write(value)
|
await f.write(value)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
proc readToStream*(f: AsyncFile, fs: FutureStream[string]) {.async.} =
|
||||||
|
## Writes data to the specified future stream as the file is read.
|
||||||
|
while true:
|
||||||
|
let data = await read(f, 4000)
|
||||||
|
if data.len == 0:
|
||||||
|
break
|
||||||
|
await fs.write(data)
|
||||||
|
|
||||||
|
fs.complete()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue