This is an appendix to
Programming written for people interested in Ada programming on POSIX
For example, code to read from a magnetic tape could look like this:
declare Tape : File_Descriptor; Position : IO_Offset; Buffer : IO_Buffer (1 .. 1024); Bytes_Read : IO_Count; begin Tape := Open (Name => "/dev/tape", Mode => Read_Only); Seek (File => Tape, Offset => 4096, Result => Position); Read (File => Tape, Buffer => Buffer, Last => Bytes_Read); Close (File => Tape); end;
Write, but not
Seek. Why is that?
This simple version of
write does not send the
from ... introduction and requires the filename for the terminal (the
ttyname), not the username of the other person: write0.adb
declare Mode : File_Mode; Options : Open_Option_Set; begin Get_File_Control (File => File, Mode => Mode, Options => Options); Options := Options + File_Synchronized; Set_File_Control (File => File, Options => Options); end;
Go to next chapter.
Understanding Unix/Linux Programming, Bruce Molay, ISBN 0-13-008396-8.