FsNotify.Event (FsNotify v0.1.2)

Copy Markdown View Source

A filesystem event delivered by a watcher as {:fs_notify_event, %FsNotify.Event{}}, mirroring notify-rs's event: one struct per event, carrying all affected paths (a reconciled rename carries [from, to]).

kind is the top-level category; detail faithfully mirrors notify-rs's nested EventKind sub-kinds — a bare atom or a {group, sub} tuple. For example :create+:file, :modify+{:name, :both}, :access+{:open, :write}.

Note: notify reports different event kinds per platform, so do not rely on a specific kind/detail for the same operation across OSes. A rename, for example, may arrive as a reconciled {:name, :both} with [from, to], or as a separate :remove + :create, depending on the backend and debouncing.

Summary

Types

Access mode for :access open/close events.

Data change for :modify {:data, _} events.

Sub-kind under kind/0, mirroring notify-rs

Top-level event category. This is the most important classification; the finer detail/0 may or may not be available depending on the backend.

Metadata change for :modify {:metadata, _} events.

Rename mode for :modify {:name, _} events.

t()

Types

access_mode()

@type access_mode() :: :any | :execute | :read | :write | :other

Access mode for :access open/close events.

  • :any — unknown/catch-all
  • :execute — the file was executed, or the folder opened
  • :read — opened for reading
  • :write — opened for writing
  • :other — known but not otherwise representable

data_change()

@type data_change() :: :any | :size | :content | :other

Data change for :modify {:data, _} events.

  • :any — unknown/catch-all
  • :size — the data size changed
  • :content — the data content changed
  • :other — known but not otherwise representable

detail()

@type detail() ::
  :any
  | :other
  | :file
  | :folder
  | :read
  | {:open, access_mode()}
  | {:close, access_mode()}
  | {:data, data_change()}
  | {:metadata, metadata_kind()}
  | {:name, rename_mode()}

Sub-kind under kind/0, mirroring notify-rs:

  • :any / :other — catch-all under any kind
  • :file / :folder — a :create/:remove of a file or directory
  • :read — an :access read
  • {:open, t:access_mode/0} / {:close, t:access_mode/0}:access open/close
  • {:data, t:data_change/0} — a :modify of file content
  • {:metadata, t:metadata_kind/0} — a :modify of metadata
  • {:name, t:rename_mode/0} — a :modify rename

kind()

@type kind() :: :any | :access | :create | :modify | :remove | :other

Top-level event category. This is the most important classification; the finer detail/0 may or may not be available depending on the backend.

metadata_kind()

@type metadata_kind() ::
  :any
  | :access_time
  | :write_time
  | :permissions
  | :ownership
  | :extended
  | :other

Metadata change for :modify {:metadata, _} events.

  • :any — unknown/catch-all
  • :access_time — access time changed
  • :write_time — write/modify time changed
  • :permissions — permissions changed
  • :ownership — ownership changed
  • :extended — an extended attribute changed
  • :other — known but not otherwise representable

rename_mode()

@type rename_mode() :: :any | :to | :from | :both | :other

Rename mode for :modify {:name, _} events.

  • :any — unknown/catch-all
  • :to — the path resulting from a rename
  • :from — the path that was renamed away
  • :both — a single event carrying both from and to paths
  • :other — known but not otherwise representable

t()

@type t() :: %FsNotify.Event{detail: detail(), kind: kind(), paths: [String.t()]}