import streams template debug*(x: varargs[untyped]) = if not defined(release): echo(x) template error*(x: varargs[untyped]) = echo(x) quit(1) # These are shim functions to make a Stream usable like an AyncFile # This is so we can use the multisync macro proc read*(stream: Stream, length: int): string = return stream.readStr(length) proc getFilePos*(stream: Stream): int64 = return int64(stream.getPosition()) proc setFilePos*(stream: Stream, position: int64) = stream.setPosition(int(position)) proc readBuffer*(stream: Stream, buffer: pointer, length: int): int = return stream.readData(buffer, length)