Eio file and directory monitoring API

- Main Page
- Related Pages
- Modules
- Data Structures
- Files
- Examples

Data Structures | Typedefs | Functions | Variables
Eio file and directory monitoring API
Eio

These function monitor changes in directories and files. More...

## Data Structures
struct | _Eio_Monitor_Error
struct | _Eio_Monitor_Event

## Typedefs
typedef struct _Eio_Monitor | Eio_Monitor
typedef struct _Eio_Monitor_Error | Eio_Monitor_Error
typedef struct _Eio_Monitor_Event | Eio_Monitor_Event

## Functions
EIO_API Eio_Monitor * | eio_monitor_add (const char *path)
| Adds a file/directory to monitor (inotify mechanism)
EIO_API Eio_Monitor * | eio_monitor_stringshared_add (const char *path)
| Adds a file/directory to monitor.
EIO_API void | eio_monitor_del (Eio_Monitor *monitor)
| Deletes a path from the “watched” list.
EIO_API const char * | eio_monitor_path_get (Eio_Monitor *monitor)
| returns the path being watched by the given Eio_Monitor.
EIO_API Eina_Bool | eio_monitor_fallback_check (const Eio_Monitor *monitor)
| Check whether a monitor is using the fallback backend.
EIO_API Eina_Bool | eio_monitor_has_context (const Eio_Monitor *monitor, const char *path)
| Check if a monitor has the context about a file or not.

## Variables
EIO_API int | EIO_MONITOR_FILE_CREATED
| A new file was created in a watched directory.
EIO_API int | EIO_MONITOR_FILE_DELETED
| A watched file was deleted, or a file in a watched directory was deleted.
EIO_API int | EIO_MONITOR_FILE_MODIFIED
| A file was modified in a watched directory.
EIO_API int | EIO_MONITOR_FILE_CLOSED
| A file was closed in a watched directory.
EIO_API int | EIO_MONITOR_DIRECTORY_CREATED
| A new directory was created in a watched directory.
EIO_API int | EIO_MONITOR_DIRECTORY_DELETED
| A directory has been deleted: this can be either a watched directory or one of its subdirectories.
EIO_API int | EIO_MONITOR_DIRECTORY_MODIFIED
| A directory has been modified in a watched directory.
EIO_API int | EIO_MONITOR_DIRECTORY_CLOSED
| A directory has been closed in a watched directory.
EIO_API int | EIO_MONITOR_SELF_RENAME
| The monitored path has been renamed, an error could happen just after if the renamed path doesn't exist.
EIO_API int | EIO_MONITOR_SELF_DELETED
| The monitored path has been removed.
EIO_API int | EIO_MONITOR_ERROR
| During operation the monitor failed and will no longer work.

## Detailed Description

These function monitor changes in directories and files.

These functions use the best available method to monitor changes on a specified directory or file. They send ecore events when changes occur, and they maintain internal refcounts to reduce resource consumption on duplicate monitor targets.

## Function Documentation

## ◆ eio_monitor_add()

EIO_API Eio_Monitor * eio_monitor_add | ( | const char * | path | ) |

Adds a file/directory to monitor (inotify mechanism)

Parameters

  path | file/directory to monitor

Returns
  NULL in case of a failure or a pointer to the monitor in case of success.

This function will add the given path to its internal list of files to monitor. It utilizes the inotify mechanism introduced in kernel 2.6.13 for passive monitoring.

References EINA_SAFETY_ON_NULL_RETURN_VAL, eina_stringshare_add(), eina_stringshare_del(), and eio_monitor_stringshared_add().

## ◆ eio_monitor_stringshared_add()

EIO_API Eio_Monitor * eio_monitor_stringshared_add | ( | const char * | path | ) |

Adds a file/directory to monitor.

Parameters

  path | file/directory to monitor

Returns
  NULL in case of a failure or a pointer to the monitor in case of success.

Warning
  Do NOT pass non-stringshared strings to this function! If you don't know what this means, use eio_monitor_add().

This function is just like eio_monitor_add(), however the string passed by argument must be created using eina_stringshare_add().

References EINA_FALSE, eina_hash_del(), eina_hash_direct_add(), eina_hash_find(), EINA_REFCOUNT_INIT, EINA_REFCOUNT_REF, EINA_SAFETY_ON_NULL_RETURN_VAL, eina_stringshare_del(), eina_stringshare_ref(), and EINA_TRUE.

Referenced by eio_monitor_add().

## ◆ eio_monitor_del()

EIO_API void eio_monitor_del | ( | Eio_Monitor * | monitor | ) |

Deletes a path from the “watched” list.

Parameters

  monitor | The Eio_Monitor you want to stop watching. It can only be an Eio_Monitor returned to you from calling eio_monitor_add() or eio_monitor_stringshared_add()

References EINA_REFCOUNT_UNREF.

## ◆ eio_monitor_path_get()

EIO_API const char * eio_monitor_path_get | ( | Eio_Monitor * | monitor | ) |

returns the path being watched by the given Eio_Monitor.

Parameters

  monitor | Eio_Monitor to return the path of

Returns
  The stringshared path belonging to `monitor`

References EINA_SAFETY_ON_NULL_RETURN_VAL.

## ◆ eio_monitor_fallback_check()

EIO_API Eina_Bool eio_monitor_fallback_check | ( | const Eio_Monitor * | monitor | ) |

Check whether a monitor is using the fallback backend.

Parameters

  monitor | The Eio_Monitor to check

Returns
  EINA_TRUE only if the monitor is valid and is using the fallback monitoring mechanism

Fallback monitors are unable to provide the CLOSED or RENAME events. It's important to check whether a monitor is a fallback monitor before relying on these events.

Since
  1.21

References EINA_FALSE, and EINA_SAFETY_ON_NULL_RETURN_VAL.

## ◆ eio_monitor_has_context()

EIO_API Eina_Bool eio_monitor_has_context | ( | const Eio_Monitor * | monitor,
|  | const char * | path
| ) |  |

Check if a monitor has the context about a file or not.

Parameters

  monitor | The Eio_Monitor to check
  path | The path to check

Returns
  EINA_TRUE if there is context, EINA_FALSE otherwise.

There are Monitors that need context about a file before they can monitor the file correctly. As an example: If you publish a file in your API before the monitor has this file in his context, and the file gets deleted as a reaction to this, the monitor will not be able to emit the correct DELETE event even if the file is in the monitors path.

In case the monitor does not yet have context, you can be sure that the monitor will bring up an FILE_ADD event about that file.

Since
  1.23

## Variable Documentation

## ◆ EIO_MONITOR_FILE_CLOSED

EIO_API int EIO_MONITOR_FILE_CLOSED
| extern

A file was closed in a watched directory.

This event is never sent on Windows and OSX, or for non-fallback monitors

## ◆ EIO_MONITOR_DIRECTORY_CLOSED

EIO_API int EIO_MONITOR_DIRECTORY_CLOSED
| extern

A directory has been closed in a watched directory.

This event is never sent on Windows and OSX, or for non-fallback monitors

## ◆ EIO_MONITOR_SELF_RENAME

EIO_API int EIO_MONITOR_SELF_RENAME
| extern

The monitored path has been renamed, an error could happen just after if the renamed path doesn't exist.

This event is never sent on OSX, or for non-fallback monitors

## ◆ EIO_MONITOR_SELF_DELETED

EIO_API int EIO_MONITOR_SELF_DELETED
| extern

The monitored path has been removed.

This event is never sent on OSX

## ◆ EIO_MONITOR_ERROR

EIO_API int EIO_MONITOR_ERROR
| extern

During operation the monitor failed and will no longer work.

eio_monitor_del must be called on it.