Go to the first, previous, next, last section, table of contents.


Creating File Objects

Function: open file-name mode-string &optional file-object
This function opens the file called file-name (see section File Names) and returns the file's object.

The mode-string argument is a string defining the access modes used to open the file with; this string is passed as-is to the C library's fopen() function. Usually one of the following strings is used,

`r'
Open an existing file for reading only.
`w'
Open the file for writing only, if the file exists it is truncated to zero length. Otherwise a new file is created.
`a'
Open the file for appending to, i.e. writing to the end of the file. If the file doesn't exist it is created.

Other options exist; consult a C library manual for details.

When the file-object argument is defined it should be a file object, the file it points to will be closed and the new file will be opened on this object.


Go to the first, previous, next, last section, table of contents.