mmioClose
Appearance
The mmioClose function closes a file that was previously opened using the mmioOpen function.
Syntax
#define INCL_MMIOOS2 #include <os2.h> USHORT mmioClose(HMMIO hmmio, USHORT usFlags);
Parameters
- usFlags (USHORT) - input
- Specifies options for closing the file. Supported flags include:
- MMIO_FHOPEN: Instructs the I/O procedure not to close the underlying DOS file handle (of type `FOURCC_DOS`). This is useful when an `HMMIO` instance was created using a pre-existing DOS file handle, allowing the `HMMIO` wrapper to be closed while keeping the raw file handle open for other uses.
Return Values
- rc (USHORT)
- Returns a code indicating the result of the operation:
- MMIO_SUCCESS: The function succeeded (0).
- MMIOERR_INVALID_HANDLE: The handle passed was not valid.
- MMIOERR_CANNOTWRITE: The I/O buffer could not be flushed to disk due to insufficient disk space.
- MMIOERR_WRITE_FAILED: Unable to write the buffer to disk, possibly due to a hardware problem.
- MMIO_WARNING: The file was closed, but the I/O Procedure (IOProc) may have expected more data.
Remarks
If the file was opened with an I/O buffer, mmioClose automatically flushes (empties) the buffer to disk before closing the file. You do not need to call mmioFlush explicitly before closing unless you need to ensure the data is written at a specific point prior to the close operation.
Example Code
The following code demonstrates how to close an open MMIO file:
HMMIO hmmio1;
USHORT usFlags;
USHORT rc;
/* ... file operations ... */
usFlags = 0;
rc = mmioClose(hmmio1, usFlags);
if (rc != MMIO_SUCCESS) {
/* Error handling: Check for MMIOERR_CANNOTWRITE, etc. */
} else {
/* File closed successfully */
}