# Method System.Inotify._Instance()->add_watch()

Method add_watch

  `int add_watch(string file, int mask)`

Description

  Add a watch for a certain file or directory and specific events. Adding more than one watch for one file will overwrite the previous watch unless System.Inotify.IN_MASK_ADD is contained in the mask.

Parameter `path`

  Path of the file or directory.

Parameter `mask`

  Integer mask specifying the event type. This can be a combination of different event types using bitwise OR. See the inotify manpage for possible values and their description. The values defined by the inotify header file are exported by System.Inotify as constants using the same names (e.g. System.Inotify.IN_CREATE).

Returns

  Returns a watch descriptor.

Note

  Subdirectories are not watched. If you want to watch subdirectories as well, you need to add watches for them individually.

See also

  rm_watch(), parse_event()