EOpenMode

The enumerated type EOpenMode defines alternative options for opening a resource such as a file:


$enum+ EOpenMode
{
    OM_CREATE_NEW,
    OM_CREATE_ALWAYS,
    OM_OPEN_EXISTING,
    OM_OPEN_EXISTING_READ_ONLY,
    OM_OPEN_EXISTING_SHARED_READ,
    OM_OPEN_ALWAYS,
    OM_DELETE_EXISTING,
};

If the resource already exists then there are three options : The function can either fail, open the existing resource, or delete the old resource and create a new empty one.

If the resource doesn't exist then the options are either to create an empty resource or else to fail.

This leads to 3x2 = 6 different modes, only 5 of which are actually useful.

Mode Resource already exists Resource doesn't already exist
(not useful) fail fail
OM_CREATE_NEW fail create + open
OM_DELETE_EXISTING delete + create + open fail
OM_CREATE_ALWAYS delete + create + open create + open
OM_OPEN_EXISTING open fail
OM_OPEN_ALWAYS open create + open

In addition, OM_OPEN_EXISTING can be split into 3 different versions depending on the kind of access:

Mode Access
OM_OPEN_EXISTING exclusive read and write access
OM_OPEN_EXISTING_READ_ONLY exclusive read access
OM_OPEN_EXISTING_SHARED_READ shared read access