November 1999
Intermediate to advanced
832 pages
19h 28m
English
The following sections describe how to open, read, and write files. The basic model is that you open a file, read or write it, then close the file. Network sockets also use the commands described here. Socket programming is discussed in Chapter 17, and more advanced event-driven I/O is described in Chapter 16. Table 9-5 lists the basic commands associated with file I/O:
| open what ?access? ?permissions? | Returns channel ID for a file or pipeline. |
| puts ?-nonewline? ?channel? string | Writes a string. |
| gets channel ?varname? | Reads a line. |
| read channel ?numBytes? | Reads numBytes bytes, or all data. |
| read -nonewline channel | Reads all bytes and discard the last \n. |
| tell channel | Returns the seek ... |
Read now
Unlock full access