This function opens a file
mco_file_h mco_open_file(
/* IN */ char const* file_path,
/* IN */ int flags,
/* IN */ mco_db_params_t* db_params,
/* IN */ mco_db_h con
);
MCO_FILE_OPEN_DEFAULTMCO_FILE_OPEN_READ_ONLYMCO_FILE_OPEN_TRUNCATEMCO_FILE_OPEN_NO_BUFFERINGMCO_FILE_OPEN_EXISTINGMCO_FILE_OPEN_TEMPORARYMCO_FILE_OPEN_FSYNC_FIXMCO_FILE_OPEN_SUBPARTITIONMCO_FILE_OPEN_FSYNC_AIO_BARRIERMCO_FILE_OPEN_COMPRESSEDMCO_FILE_OPEN_LOCKMCO_FILE_OPEN_NO_READ_BUFFERINGMCO_FILE_OPEN_NO_WRITE_BUFFERINGOpens a file with the specified path. The behavior is controlled by a set of bitwise flags that define options such as read-only access, truncation, buffering, compression, and file locking. This function returns a file handle that can be used in subsequent I/O operations.
On success, returns a non-NULL mco_file_h handle representing the opened file. On failure (e.g., file not found, permission denied), returns NULL.
...
/* Open a file for writing, truncating it if it exists */
mco_file_h f = mco_open_file(file_path, MCO_FILE_OPEN_TRUNCATE, 0, 0);
if (f == NULL) {
return (MCO_RET)MCO_E_DISK_OPEN;
}
...
/* ... use the file handle ... */
...
if (f->close(f) != 0 && ret == MCO_S_OK) {
ret = (MCO_RET)MCO_E_DISK_CLOSE;
}
eXtremeDB/rt defines a macro with the same name that calls the function mco_open_file_rt()