# Module fsmonitor

This module allows you to monitor files or directories for changes using asyncio.

Windows support is not yet implemented.

Note: This module uses `inotify` on Linux (Other Unixes are not yet supported). `inotify` was merged into the 2.6.13 Linux kernel, this module will therefore not work with any Linux kernel prior to that, unless it has been patched to support inotify.

# Imports

posix, inotify, os, asyncio, tables

# Types

    PFSMonitor = ref TFSMonitor

    TMonitorEventType = enum
      MonitorAccess,              ## File was accessed.
      MonitorAttrib,              ## Metadata changed.
      MonitorCloseWrite,          ## Writtable file was closed.
      MonitorCloseNoWrite,        ## Unwrittable file closed.
      MonitorCreate,              ## Subfile was created.
      MonitorDelete,              ## Subfile was deleted.
      MonitorDeleteSelf,          ## Watched file/directory was itself deleted.
      MonitorModify,              ## File was modified.
      MonitorMoveSelf,            ## Self was moved.
      MonitorMoved,               ## File was moved.
      MonitorOpen,                ## File was opened.
      MonitorAll                  ## Filter for all event types.

  Monitor event type

    TMonitorEvent = object
      case kind*: TMonitorEventType
      of MonitorMoveSelf, MonitorMoved:
          oldPath*: string        ## Old absolute location
          newPath*: string        ## New absolute location

      else:
          fullname*: string       ## Absolute filename of the file/directory affected.

      name*: string               ## Non absolute filepath of the file/directory
                                  ## affected relative to the directory watched.
                                  ## "" if this event refers to the file/directory
                                  ## watched.
      wd*: cint                   ## Watch descriptor.

  Type of the event.

# Procs

    proc newMonitor(): PFSMonitor {.raises: [EOS], tags: [].}

  Creates a new file system monitor.

    proc add(monitor: PFSMonitor; target: string; filters = {MonitorAll}): cint {.
        discardable, raises: [EOS], tags: [].}

  Adds `target` which may be a directory or a file to the list of watched paths of `monitor`. You can specify the events to report using the `filters` parameter.

    proc del(monitor: PFSMonitor; wd: cint) {.raises: [EOS], tags: [].}

  Removes watched directory or file as specified by `wd` from `monitor`.

  If `wd` is not a part of `monitor` an EOS error is raised.

    proc register(d: PDispatcher; monitor: PFSMonitor;
                  handleEvent: proc (m: PFSMonitor; ev: TMonitorEvent) {.closure.}) {.
        raises: [], tags: [].}

  Registers `monitor` with dispatcher `d`.

Generated: 2013-05-21 09:55:16 UTC