Specify open flags

The mi_file_open() function takes as its second argument the open flags with which to open the operating-system file.

The open flags value provides two pieces of information:
  • A masked flag value that specifies information such as access mode (read/write, read-only, write-only)

    The mi_file_open() function passes these open flags directly to the underlying operating-system call that opens a file, so you must use flag values that your operating system supports. Also, you must include the operating-system header file (such as fcntl.h) that defines the open-flag constants you use.

  • A file-mode flag to indicate on which computer the file to open is

    The DataBlade® API file-access functions support access to a file on either the server or client computer. By default, the mi_file_open() function opens a file on the server computer. To open a server file, you can omit the file-mode flag or specify the MI_O_SERVER_FILE file-mode flag. To open a client file, you must include the MI_O_CLIENT_FILE file-mode flag as part of the open flags.

For example, the mi_file_open() call in Sample call to open an operating-system file masks the following open flag constants for the file to open.
O_WRONLY
Open the file write-only.
O_APPEND
Append new data to the end of the file.
O_CREAT
If the file does not exist, create it.
The example in Sample call to open an operating-system file is based on the following assumptions:
  • The operating-system open call supports the O_WRONLY, O_APPEND, and O_CREAT flags.
  • The code that executes this mi_file_open() call includes the header file that defines O_WRONLY, O_APPEND, and O_CREAT.
  • The file is on the server computer.