The %open() function opens the host OS file specified by str and sets the file status flags according to the value of oflag.
Syntax
file.descriptor = %open(str, oflag , pmode) |
Parameter(s)
str |
Specifies the file name to open or create. |
|
oflag |
Specifies the status of the file. Valid values are defined in the include file: fcntl.h. Multiple flags can be specified in the syntax. |
|
O$APPEND |
Moves the file pointer to the end of the file. |
|
O$BINARY |
Opens in binary mode. |
|
O$CREAT |
Creates a new file with the name specified in str. Owner-ID and group-ID are set and the mode of the file is set according to the value of mode modified as follows: all bits in the file mode creation mask of the process are cleared and the sticky bit is cleared. If mode is not specified, the file is opened with read and write permissions. |
|
O$EXCL |
If O$EXCL and O$CREAT are set, open fails if the file exists. |
|
O$NDELAY |
Nonblocking I/O. The effect of this flag varies depending on the type of the file. See host OS system documentation. |
|
O$RDONLY |
Opens for reading only. |
|
O$RDWR |
Opens for reading and writing. |
|
O$SYNC |
Synchronized writes. |
|
O$TEXT |
Opens in text mode and translates text (default). For example, ^Z is assumed to be an end of line. |
|
O$TRUNC |
If the file exists, its length is set to 0. |
|
O$WRONLY |
Opens for writing only. |
|
pmode |
Specifies the read-write permissions for newly created files opened with the O$CREAT flag. Valid values are defined in the include file: mode.h. If no value is specified, the file is opened with read and write permissions. |
|
S$IRUSR |
Opens a new file with read only permissions. (UNIX) |
|
S$IWUSR |
Opens a new file with write only permissions. (UNIX) |
|
S$IREAD |
Opens a new file with read only permissions. (Windows) |
|
S$IWRITE |
Opens a new file with write only permissions. (Windows) |
Description
Files opened by %open() are closed automatically when the FlashBASIC program terminates.
The file descriptor is returned as a number or -1 if an error occurred. system(0) contains the error number.
NOTE |
|
Example(s)
include dm,bp,unix.h fcntl.h fd=%open(’fname’, o$wronly+o$append) if fd<0 then crt ’Cannot open. errno=’:system(0) end |
See Also