module: cat rcs-header: $Header: /afs/cs/project/gwydion/dylan/src/demos/cat/RCS/cat.dylan,v 1.6 97/05/31 01:20:15 ram Exp $ // This demo demonstrates the streams library by duplicating the unix // ``cat'' utility. // define method main (argv0 :: , #rest names) if (empty?(names)) spew(*standard-input*); else for (name in names) let stream = if (name = "-") make(, fd: 0); else make(, locator: name); end; spew(stream); close(stream); end; end if; force-output(*standard-output*); end method; define method spew (stream :: ) let buf :: false-or() = get-input-buffer(stream); while (buf) write(*standard-output*, buf, start: buf.buffer-next, end: buf.buffer-end); buf.buffer-next := buf.buffer-end; buf := next-input-buffer(stream); end while; release-input-buffer(stream); end;