Gio.File.monitor_dir
Description: Reference for Gio.File.monitor_dir

### Virtual Method

# Gio Filemonitor_dir

#### Declaration

    GFileMonitor*
    monitor_dir (
      GFile* file,
      GFileMonitorFlags flags,
      GCancellable* cancellable,
      GError** error
    )

#### Description

Obtains a directory monitor for the given file. This may fail if directory monitoring is not supported.

If `cancellable` is not `NULL`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error `G_IO_ERROR_CANCELLED` will be returned.

It does not make sense for `flags` to contain `G_FILE_MONITOR_WATCH_HARD_LINKS`, since hard links can not be made to directories. It is not possible to monitor all the files in a directory for changes made via hard links; if you want to do this then you must register individual watches with g_file_monitor().

#### Parameters

`flags`

  Type: `GFileMonitorFlags`

  A set of `GFileMonitorFlags`.

`cancellable`

  Type: `GCancellable`

  Optional `GCancellable` object, `NULL` to ignore.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the virtual function if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `GFileMonitor`

A `GFileMonitor` for the given `file`, or `NULL` on error. Free the returned object with g_object_unref().

The caller of the function takes ownership of the data, and is responsible for freeing it.