open - Maple Help

open

opens a file for unbuffered reading or writing

 Calling Sequence open(name, mode)

Parameters

 name - name of the file to be opened mode - one of READ or WRITE

Description

 • The open function opens the file with the specified name for unbuffered reading or writing (as specified by mode) and returns a file descriptor (a small integer).
 • RAW file I/O is always done with a file type of BINARY.
 • The special file names 'default' and 'terminal', referring to the current and top-level input or output streams, cannot be used with open.
 • If the file is being opened for reading and does not exist, open generates an error.
 • If the file is being opened for writing and does not exist, it is created if possible; otherwise, open generates an error.
 • If the file is already open, open generates an error.
 • If the limit for the maximum number of simultaneously open files has been reached, open generates an error.

Examples

 > $\mathrm{fd}≔\mathrm{open}\left(\mathrm{testFile},\mathrm{WRITE}\right)$
 ${\mathrm{fd}}{≔}{0}$ (1)
 > $\mathrm{fprintf}\left(\mathrm{fd},"This is a test\n"\right)$
 ${15}$ (2)
 > $\mathrm{close}\left(\mathrm{fd}\right)$