# emcrisostomo/fswatch

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/emcrisostomo-fswatch).**

5,558 stars · 346 forks · C++ · GPL-3.0

## Links

- GitHub: https://github.com/emcrisostomo/fswatch
- Homepage: https://emcrisostomo.github.io/fswatch/
- awesome-repositories: https://awesome-repositories.com/repository/emcrisostomo-fswatch.md

## Topics

`c` `c-plus-plus` `change-monitor` `event-notifications` `fswatch` `inotify` `kqueue` `solaris` `windows`

## Description

fswatch is a cross-platform file change monitor that watches files and directories for modifications using the native event API of each operating system. It functions as a multi-backend file watcher library that selects from platform-specific backends such as inotify, kqueue, and FSEvents, with a polling fallback when no native API is available. The tool groups multiple file changes into a single event batch and triggers one command per batch, while also executing user-specified commands each time monitored files or directories are modified.

The project applies include, exclude, event-type, and traversal filters to reduce noise before triggering actions, and it outputs file paths as they change with optional null-delimited output for safe piping into shell scripts. It provides C language bindings that expose file monitoring functionality to any language supporting a C foreign function interface, with thread-safe session management that maintains per-thread state so concurrent watchers operate independently. The monitor uses a callback-driven event delivery model, a conjunctive filter pipeline, and a factory pattern to instantiate the correct platform monitor implementation.

Additional capabilities include latency tuning, recursive directory watching, event type filtering, and configurable output formats with event flags and timestamps. The project supports path filtering through include/exclude patterns, extension matching, and traversal pruning to reduce noise from unwanted directories. It can be installed via package managers, built from source archives, or compiled from a repository clone using the GNU Build System or CMake.

## Tags

### Software Engineering & Architecture

- [File Change Batch Processors](https://awesome-repositories.com/f/software-engineering-architecture/batch-event-processors/file-change-batch-processors.md) — Groups multiple file changes into a single event batch and triggers one command per batch.
- [Batch Event Processors](https://awesome-repositories.com/f/software-engineering-architecture/batch-event-processors.md) — Groups multiple file change notifications into a single batch for optimized downstream processing.
- [Platform Monitor Factories](https://awesome-repositories.com/f/software-engineering-architecture/dependency-injection-providers/factory-based-instantiation/platform-monitor-factories.md) — Instantiates the correct platform-specific filesystem monitor using a factory method. ([source](https://emcrisostomo.github.io/fswatch/doc/libfswatch/1.21.0/cpp-api.html))
- [Event-Driven Callbacks](https://awesome-repositories.com/f/software-engineering-architecture/event-driven-callbacks.md) — Delivers file change events to user-defined callback functions during monitoring sessions.
- [Recursive Directory Watchers](https://awesome-repositories.com/f/software-engineering-architecture/recursive-validation-engines/recursive-tree-traversers/file-system-traversers/recursive-directory-traversers/recursive-directory-watchers.md) — Monitors a directory tree recursively and captures changes to files created after the watcher starts. ([source](https://emcrisostomo.github.io/fswatch/usage.html))
- [Traversal Pruning and Event Filters](https://awesome-repositories.com/f/software-engineering-architecture/recursive-validation-engines/recursive-tree-traversers/file-system-traversers/recursive-directory-traversers/traversal-pruning-and-event-filters.md) — Prevents descent into noisy directories and emits only events matching application source patterns. ([source](https://emcrisostomo.github.io/fswatch/usage.html))
- [Per-Thread Monitoring Sessions](https://awesome-repositories.com/f/software-engineering-architecture/background-thread-dispatchers/thread-safe-dispatchers/thread-safe-state-transitions/per-thread-monitoring-sessions.md) — Maintains per-thread monitoring state so concurrent watchers operate independently.
- [Factory Method Patterns](https://awesome-repositories.com/f/software-engineering-architecture/creational-design-patterns/factory-method-patterns.md) — Uses a factory method to instantiate the correct platform-specific file monitor implementation.

### System Administration & Monitoring

- [Cross-Platform File Change Monitors](https://awesome-repositories.com/f/system-administration-monitoring/file-system-monitors/file-system-monitors/cross-platform-file-change-monitors.md) — Watches files and directories for modifications across macOS, Linux, BSD, Solaris, and Windows using native event APIs.
- [File Event Filters](https://awesome-repositories.com/f/system-administration-monitoring/audit-log-filters/log-event-filters/file-event-filters.md) — Applies include, exclude, event-type, and traversal filters to suppress irrelevant file changes. ([source](https://emcrisostomo.github.io/fswatch/))
- [File System Monitors](https://awesome-repositories.com/f/system-administration-monitoring/file-system-monitors.md) — Watches files and directories for modifications using the native event API of the host operating system. ([source](https://emcrisostomo.github.io/fswatch/))
- [File System Watchers](https://awesome-repositories.com/f/system-administration-monitoring/file-system-watchers.md) — Uses the native event API of each operating system to report file and directory modifications.
- [Thread-Safe Monitoring Sessions](https://awesome-repositories.com/f/system-administration-monitoring/monitoring-and-observability/observability-platforms/metric-performance-monitors/virtual-thread-monitors/thread-activity-monitors/thread-safe-monitoring-sessions.md) — Maintains per-thread state so concurrent file watchers operate independently without interference. ([source](https://emcrisostomo.github.io/fswatch/doc/libfswatch/1.21.0/c-api.html))
- [Filesystem Event Type Filters](https://awesome-repositories.com/f/system-administration-monitoring/activity-change-notifications/incremental-change-notifications/asset-change-notifications/event-type-notification-filters/filesystem-event-type-filters.md) — Filters change notifications based on the type of filesystem event, such as creation, modification, or deletion. ([source](https://emcrisostomo.github.io/fswatch/doc/libfswatch/1.21.0/cpp-api.html))
- [File Monitoring Sessions](https://awesome-repositories.com/f/system-administration-monitoring/activity-monitors/user-session-monitors/file-monitoring-sessions.md) — Starts a file system monitor that gathers change events and delivers them to a callback until the session is stopped. ([source](https://emcrisostomo.github.io/fswatch/doc/libfswatch/1.21.0/index.html))

### Data & Databases

- [File System Monitor](https://awesome-repositories.com/f/data-databases/collective-communication-operations/backend-selection/file-system-monitor.md) — Chooses from multiple platform-specific file change notification APIs or a polling fallback. ([source](https://cdn.jsdelivr.net/gh/emcrisostomo/fswatch@master/README.md))

### Development Tools & Productivity

- [File-Change-Triggered Commands](https://awesome-repositories.com/f/development-tools-productivity/custom-command-execution/file-change-triggered-commands.md) — Executes a user-specified command each time monitored files or directories are modified.
- [Event-Filtering](https://awesome-repositories.com/f/development-tools-productivity/file-watchers/event-filtering.md) — Applies include, exclude, event-type, and traversal filters to reduce noise before triggering actions.
- [Multi-Backend](https://awesome-repositories.com/f/development-tools-productivity/file-watchers/multi-backend.md) — Selects from platform-specific backends such as inotify, kqueue, and FSEvents to monitor file changes.
- [Live Changed File Streams](https://awesome-repositories.com/f/development-tools-productivity/changed-file-identification/live-changed-file-streams.md) — Prints file paths as they change with null-delimited output for safe shell pipeline consumption. ([source](https://emcrisostomo.github.io/fswatch/))
- [Change-Based Path Filtering](https://awesome-repositories.com/f/development-tools-productivity/commit-management/path-based-filtering-rules/change-based-path-filtering.md) — Prints file paths as they change with optional null-delimited output for safe piping into shell scripts. ([source](https://emcrisostomo.github.io/fswatch/index.html))
- [Filesystem Event Filters](https://awesome-repositories.com/f/development-tools-productivity/file-ignore-patterns/linting-file-filters/hook-file-filters/linting-file-filters/filesystem-event-filters.md) — Applies include, exclude, event-type, and traversal filters to reduce noise before triggering automated actions.

### Programming Languages & Runtimes

- [File Monitoring Bindings](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/native-c-interoperability/c-function-bindings/file-monitoring-bindings.md) — Provides C bindings that expose file monitoring to any language with a C FFI. ([source](https://emcrisostomo.github.io/fswatch/doc/libfswatch/1.21.0/index.html))
- [File Monitoring C Bindings](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/native-c-interoperability/c-function-bindings/file-monitoring-c-bindings.md) — Provides C language bindings that expose file monitoring functionality to any language supporting a C foreign function interface.

### Security & Cryptography

- [File Event Filter Pipelines](https://awesome-repositories.com/f/security-cryptography/content-filtering/pipeline-filters/file-event-filter-pipelines.md) — Applies include, exclude, event-type, and traversal filters to reduce file change noise.
- [Path-Based View Filtering](https://awesome-repositories.com/f/security-cryptography/path-based-view-filtering.md) — Includes or excludes files and directories from monitoring using path-based patterns. ([source](https://emcrisostomo.github.io/fswatch/doc/libfswatch/1.21.0/cpp-api.html))

### User Interface & Experience

- [File System Backend Abstractions](https://awesome-repositories.com/f/user-interface-experience/cross-platform-ui-abstractions/plugin-based-backend-abstractions/file-system-backend-abstractions.md) — Selects the optimal native file system event API for each operating system through a unified interface.

### Web Development

- [File Change Batching](https://awesome-repositories.com/f/web-development/batch-processing/file-change-batching.md) — Groups multiple file changes into a single event batch to reduce overhead for rebuilds or test reruns.

### Networking & Communication

- [File System Polling Fallbacks](https://awesome-repositories.com/f/networking-communication/xhr-polling-fallbacks/file-system-polling-fallbacks.md) — Provides a polling fallback using stat() calls when no native file system event API is available.

### Operating Systems & Systems Programming

- [Null-Delimited File Path Streams](https://awesome-repositories.com/f/operating-systems-systems-programming/null-terminated-stream-handling/null-delimited-file-path-streams.md) — Outputs file paths with null delimiters for safe shell pipeline consumption.
