# 2.6.1.4 Locking

enum ZixFileLockMode

  A mode for locking files.

  The same mode should be used for the lock and the corresponding unlock.

  enumerator ZIX_FILE_LOCK_BLOCK

    Block until the operation succeeds.

  enumerator ZIX_FILE_LOCK_TRY

    Fail if the operation would block.

ZixStatus zix_file_lock(FILE *file, ZixFileLockMode mode)

  Set an advisory exclusive lock on `file`.

  Parameters:

    - file – Handle for open file to lock.

    - mode – Lock mode.

  Returns:

    `ZixStatus.ZIX_STATUS_SUCCESS` if the file was locked, or an error.

ZixStatus zix_file_unlock(FILE *file, ZixFileLockMode mode)

  Remove an advisory exclusive lock on `file`.

  Parameters:

    - file – Handle for open file to lock.

    - mode – Lock mode.

  Returns:

    `ZixStatus.ZIX_STATUS_SUCCESS` if the file was unlocked, or an error.