open

(open filename io_mode)

The open function opens a file, specified by filename, to read or write.

The argument io_mode specifies :

IO Mode Meaning
"r" Opens for reading. If the file does not exist or cannot be found, it returns nil.
"w" Opens an empty file for writing. If the given file exists, its contents are destroyed.
"a" Opens for writing at the end of the file (appending); creates the file first if it does not exist.
Return Value

The function returns a file descriptor to be used by other I/O functions.

Examples

: (setq d (open "test.txt" "w"))

: (setq d (open "test.txt" "r"))

: (setq d (open "test.txt" "a"))