/usr/share/freemat/help/text/fopen.mdc is in freemat-help 4.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | FOPEN FOPEN File Open Function
Usage
Opens a file and returns a handle which can be used for subsequent
file manipulations. The general syntax for its use is
fp = fopen(fname,mode,byteorder)
Here fname is a string containing the name of the file to be
opened. mode is the mode string for the file open command.
The first character of the mode string is one of the following:
- 'r' Open file for reading. The file pointer is placed at
the beginning of the file. The file can be read from, but
not written to.
- 'r+' Open for reading and writing. The file pointer is
placed at the beginning of the file. The file can be read
from and written to, but must exist at the outset.
- 'w' Open file for writing. If the file already exists, it is
truncated to zero length. Otherwise, a new file is
created. The file pointer is placed at the beginning of
the file.
- 'w+' Open for reading and writing. The file is created if
it does not exist, otherwise it is truncated to zero
length. The file pointer placed at the beginning of the file.
- 'a' Open for appending (writing at end of file). The file is
created if it does not exist. The file pointer is placed at
the end of the file.
- 'a+' Open for reading and appending (writing at end of file). The
file is created if it does not exist. The file pointer is
placed at the end of the file.
Starting with FreeMat 4, all files are treated as binary files by default.
To invoke the operating systems 'CR/LF <-> CR' translation (on Win32)
add a 't' to the mode string, as in 'rt+'.
Also, you can supply a second argument to fopen to retrieve error
messages if the fopen fails.
[fp,messages] = fopen(fname,mode,byteorder)
Finally, FreeMat has the ability to read and write files of any
byte-sex (endian). The third (optional) input indicates the
byte-endianness of the file. If it is omitted, the native endian-ness
of the machine running FreeMat is used. Otherwise, the third
argument should be one of the following strings:
- 'le','ieee-le','little-endian','littleEndian','little','l','ieee-le.l64','s'
- 'be','ieee-be','big-endian','bigEndian','big','b','ieee-be.l64','a'
If the file cannot be opened, or the file mode is illegal, then
an error occurs. Otherwise, a file handle is returned (which is
an integer). This file handle can then be used with fread,
fwrite, or fclose for file access.
Note that three handles are assigned at initialization time:
- Handle 0 - is assigned to standard input
- Handle 1 - is assigned to standard output
- Handle 2 - is assigned to standard error
These handles cannot be closed, so that user created file handles start at 3.
|