HP C/iX Library Reference Manual (30026-90004)

Chapter 5 265
HP C/iX Library Function Descriptions
open
open
Opens a file for reading or writing.
Syntax
#include <fcntl.h>
int open (char *
path
, int
oflag [
,int
mode [
,char
mpe_opts]]
);
Parameters
path
A pointer to a path name naming a file.
oflag
An integer containing open mode bit flags.
mode
An unused integer parameter provided for compatibility with other
systems.
mpe_opts
A pointer to a string containing file attributes and options.
Return Values
x Upon successful completion, the integer file descriptor is returned.
1 Unsuccessful completion. In addition, errno is set to the indicated value if
one of the following conditions is true:
ENOENT The
fname
is null, or the named file does not exist and you
did not use
oflag
to request that it be created.
EACCES The
oflag
permission is denied for the named file.
EMFILE The maximum number of file descriptors allowed are
currently open.
EINVAL The
oflag
specifies incompatible read/write access flags.
ESYSERR A call to a system intrinsic failed.
Description
The open function opens the file descriptor described in
fname
. It uses the value of
oflag
to determine how to open the file.
Opening a file in read mode fails if the file does not exist or cannot be read.
The
oflag
parameter values are constructed by OR-ing flags from the list below. Notice
that exactly one of the first three flags below must be used.
O_RDONLY Open for reading only.
O_WRONLY Open for writing only.
O_RDWR Open for reading and writing.
O_APPEND If set, the file pointer is set to the end of the file prior to each write.