[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Channel concept instead of simple Files
> From: Sander van der Wal <svdwal@xs4all.nl>
> Date: Fri, 12 Jan 1996 11:54:44 +0100
>
> ...
> There is another factor to take into account, there is a difference
> between for instance a disk file and the keyboard.
> When I read from a disk file I know I can reread it because all
> the bytes in the file will stay there. Essentially a disk file is
> persistent. The keyboard on the other hand is not persistent, as
> soon as I read a byte the keyboard has lost it.
> On both keyboard and disk file I can open a Reader, but the Reader
> on the keyboard cannot be repositioned, while a Reader on a disk file
> can be meaningfully repositioned and reread.
>
Unix, and AFAIK AmigaOS, simply spend the file descriptor (stream,
channel, or whatever) additional attributes and/or prevent a function
that needs a specific feature from being used. For example the Unix
pipes and FIFOs don't allow lseek() and make it return with an error
code. A simple solution to this problem is to add an "is
positionable" flag to the channel, similar to the "is readable" and
"is writable" flags.
There is another difference: when reading from a file you can say how
long the file is, and how much bytes you can read from it. Reading
from keyboard only allows you to detect how many bytes are currently
available (or if the channel has been closed).
-- mva