After using the file, the process should close the file using close call, which takes the file descriptor of the file to be closed. Some filesystems include a disposition to permit releasing the file.
Some computer languages include run-time libraries which include additional functionality for particular filesystems. The open (or some auxiliary routine) may include specifications for key size, record size, connection speed. Some open routines include specification of the program code to be executed in the event of an error.
for example:
Perl also uses the tie function of the Tie::File module to associate an array with a file.1 The tie::AnyDBM_File function associates a hash with a file.2
The open call is standardized by the POSIX specification for C language:
The value returned is a file descriptor which is a reference to a process specific structure which contains, among other things, a position pointer that indicates which place in the file will be acted upon by the next operation.
Open may return −1 indicating a failure with errno detailing the error.
The file system also updates a global table of all open files which is used for determining if a file is currently in use by any process.
The name of the file to open. It includes the file path defining where, in which file system, the file is found (or should be created).
openat expects a relative path.
This argument formed by OR'ing together optional parameters and (from <fcntl.h>) one of:
Option parameters include:
Additional flags and errors are defined in open call.
creat() is implemented as:
fopen uses string flags such as r, w, a and + and returns a file pointer used with fgets, fputs and fclose.
Optional and relevant only when creating a new file, defines the file permissions. These include read, write or execute the file by the owner, group or all users. The mode is masked by the calling process's umask: bits set in the umask are cleared in the mode.
"Tie::File". perldoc.perl.org. Retrieved 2011-08-07. http://perldoc.perl.org/Tie/File.html ↩
"AnyDBM_File". perldoc.perl.org. Retrieved 2011-08-07. http://perldoc.perl.org/AnyDBM_File.html ↩