Name | wtr-watcher JSON |
Version |
0.13.2
JSON |
| download |
home_page | None |
Summary | Filesystem watcher. Works anywhere. Simple, efficient, and friendly. |
upload_time | 2024-10-28 01:27:08 |
maintainer | None |
docs_url | None |
author | Will |
requires_python | None |
license | Copyright 2022 github.com/e-dant MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
watcher
filesystem
events
async
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Watcher
[![Conan Center](https://img.shields.io/conan/v/watcher)](https://conan.io/center/recipes/watcher)
[![Rust/Cargo Crate](https://img.shields.io/crates/v/wtr-watcher.svg)](https://crates.io/crates/wtr-watcher)
[![PyPI/Pip Package](https://badge.fury.io/py/wtr-watcher.svg)](https://badge.fury.io/py/wtr-watcher)
[![Builds and Publishing for Distribution](https://github.com/e-dant/watcher/actions/workflows/dist.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/dist.yml)
[![CodeQL Tests](https://github.com/e-dant/watcher/actions/workflows/codeql.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/codeql.yml)
[![Linux Tests](https://github.com/e-dant/watcher/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/ubuntu.yml)
[![macOS Tests](https://github.com/e-dant/watcher/actions/workflows/macos.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/macos.yml)
[![Android Compilation Tests](https://github.com/e-dant/watcher/actions/workflows/android.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/android.yml)
[![Windows Tests](https://github.com/e-dant/watcher/actions/workflows/windows.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/windows.yml)
## Quick Start
<details>
<summary>C++</summary>
```cpp
#include "wtr/watcher.hpp"
#include <iostream>
#include <string>
using namespace std;
using namespace wtr;
// The event type, and every field within it, has
// string conversions and stream operators. All
// kinds of strings -- Narrow, wide and weird ones.
// If we don't want particular formatting, we can
// json-serialize and show the event like this:
// some_stream << event
// Here, we'll apply our own formatting.
auto show(event e) {
cout << to<string>(e.effect_type) + ' '
+ to<string>(e.path_type) + ' '
+ to<string>(e.path_name)
+ (e.associated ? " -> " + to<string>(e.associated->path_name) : "")
<< endl;
}
auto main() -> int {
// Watch the current directory asynchronously,
// calling the provided function on each event.
auto watcher = watch(".", show);
// Do some work. (We'll just wait for a newline.)
getchar();
// The watcher would close itself around here,
// though we can check and close it ourselves.
return watcher.close() ? 0 : 1;
}
```
```sh
# Sigh
PLATFORM_EXTRAS=$(test "$(uname)" = Darwin && echo '-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -framework CoreFoundation -framework CoreServices')
# Build
eval c++ -std=c++17 -Iinclude src/wtr/tiny_watcher/main.cpp -o watcher $PLATFORM_EXTRAS
# Run
./watcher
```
</details>
<details>
<summary>C</summary>
```c
#include "wtr/watcher-c.h"
#include <stdio.h>
void callback(struct wtr_watcher_event event, void* _ctx) {
printf(
"path name: %s, effect type: %d path type: %d, effect time: %lld, associated path name: %s\n",
event.path_name,
event.effect_type,
event.path_type,
event.effect_time,
event.associated_path_name ? event.associated_path_name : ""
);
}
int main() {
void* watcher = wtr_watcher_open(".", callback, NULL);
getchar();
return ! wtr_watcher_close(watcher);
}
```
</details>
<details>
<summary>Python</summary>
```sh
pip install wtr-watcher
```
```python
from watcher import Watch
with Watch(".", print):
input()
```
</details>
<details>
<summary>Rust</summary>
```sh
cargo add wtr-watcher tokio futures
```
```rust
use futures::StreamExt;
use wtr_watcher::Watch;
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let show = |e| async move { println!("{e:?}") };
let events = Watch::try_new(".")?;
events.for_each(show).await;
Ok(())
}
```
</details>
<details>
<summary>Node.js</summary>
```javascript
import * as watcher from 'watcher';
var w = watcher.watch('.', (event) => {
console.log(event);
});
process.stdin.on('data', () => {
w.close();
process.exit();
});
```
</details>
The output of each above will be something this, depending on the format:
```
modify file /home/e-dant/dev/watcher/.git/refs/heads/next.lock
rename file /home/e-dant/dev/watcher/.git/refs/heads/next.lock -> /home/e-dant/dev/watcher/.git/refs/heads/next
create file /home/e-dant/dev/watcher/.git/HEAD.lock
```
Enjoy!
---
## Tell Me More
A filesystem event watcher which is
1. Friendly
> I try to keep the [1579](https://github.com/e-dant/watcher/blob/release/tool/sl)
lines that make up the runtime of *Watcher* [relatively simple](https://github.com/e-dant/watcher/blob/release/include/wtr/watcher.hpp)
and the API practical:
```cpp
auto w = watch(path, [](event ev) { cout << ev; });
```
```sh
wtr.watcher ~
```
2. Modular
> *Watcher* may be used as **a library, a program, or both**.
If you aren't looking to create something with the library, no worries.
Just use ours and you've got yourself a filesystem watcher which prints
filesystem events as JSON. Neat. Here's how:
```bash
# The main branch is the (latest) release branch.
git clone https://github.com/e-dant/watcher.git && cd watcher
# Via Nix
nix run | grep -oE 'cmake-is-tough'
# With the build script
tool/build --no-build-test --no-run && cd out/this/Release # Build the release version for the host platform.
./wtr.watcher | grep -oE 'needle-in-a-haystack/.+"' # Use it, pipe it, whatever. (This is an .exe on Windows.)
```
3. Efficient
> You can watch an *entire filesystem* with this project.
In [almost all cases](https://github.com/e-dant/watcher/tree/release#exceptions-to-efficient-scanning),
we use a near-zero amount of resources and make
[efficient use of the cache](https://github.com/e-dant/watcher/tree/release#cache-efficiency).
We regularly test that the overhead of detecting and sending an event to the user is
an order of magnitude less than the filesystem operations being measured.
4. Well Tested
> We run this project through
[unit tests against all available sanitiziers](https://github.com/e-dant/watcher/actions).
This code tries hard to be thread, memory, bounds, type and resource-safe. What we lack
from the language, we try to make up for with testing. For some practical definition of safety,
this project probably fits.
5. Dependency Minimal
> *Watcher* depends on the C++ Standard Library. For efficiency,
we [leverage the OS](https://github.com/e-dant/watcher/tree/release#os-apis-used)
when possible on Linux, Darwin and Windows. For testing and
debugging, we use [Snitch](https://github.com/cschreib/snitch) and
[Sanitizers](https://clang.llvm.org/docs/index.html).
6. Portable
> *Watcher* is runnable almost anywhere. The only requirement
is a filesystem.
---
## Usage
### Project Content
The important pieces are the (header-only) library and the (optional) CLI program.
- C++ Header-Only Library: `include/wtr/watcher.hpp`.
Include this to use *Watcher* in your C++ project. Copying this into your project, and
including it as `#include "wtr/watcher.hpp"` (or similar) is sufficient to get up and
running in this language. Some extra documentation and high-level library internals can
be found in the [event](https://github.com/e-dant/watcher/blob/release/devel/include/wtr/watcher-/event.hpp)
and [watch](https://github.com/e-dant/watcher/blob/release/devel/include/wtr/watcher-/watch.hpp) headers.
- C Library: `watcher-c`.
Build this to use *Watcher* from C or through an FFI in other languages.
- Full CLI Program: `src/wtr/watcher/main.cpp`.
Build this to use *Watcher* from the command line. The output is an exhaustive JSON stream.
- Minimal CLI Program: `src/wtr/tiny_watcher/main.cpp`.
A very minimal, more human-readable, CLI program. The source for this is almost identical
to the example usage for C++.
A directory tree is [in the notes below](https://github.com/e-dant/watcher/tree/release#namespaces-and-the-directory-tree).
### The Library
The two fundamental building blocks here are:
- The `watch` function or class (depending on the language)
- The `event` object (or similarly named, again depending on the language)
`watch` takes a path, which is a string-like thing, and a
callback, with is a function-like thing. For example, passing
`watch` a character array and a closure would work well in C++.
Examples for a variety of languages can be found in the [Quick Start](https://github.com/e-dant/watcher/tree/release#quick-start).
The API is relatively consistent across languages.
The watcher will happily continue watching until you stop
it or it hits an unrecoverable error.
The `event` object is used to pass information about
filesystem events to the callback given (by you) to `watch`.
The `event` object will contain:
- `path_name`, which is an absolute path to the event.
- `path_type`, the type of path. One of:
- `dir`
- `file`
- `hard_link`
- `sym_link`
- `watcher`
- `other`
- `effect_type`, "what happened". One of:
- `rename`
- `modify`
- `create`
- `destroy`
- `owner`
- `other`
- `effect_time`, the time of the event in nanoseconds since epoch.
- `associated` (an event, C++) or `associated_path_name` (all other implementations, a single path name):
- For the C++ implementation, this is a recursive structure. Another event, associated with "this" one, is stored here.
The only events stored here, currently, are the renamed-to part of rename events.
- For all other implementations, this field represents the path name of an associated event.
- The implementation in C++, a recursive structure, was chosen to future-proof the library in the event that
we need to support other associated events.
(Note that, for JavaScript, we use the camel-case, to be consistent with that language's ecosystem.)
#### State Changes and Special Events
The `watcher` type is special.
Events with this type will include messages from
the watcher. You may recieve error messages or
important status updates.
This format was chosen to support asynchronous messages
from the watcher in a generic, portable format.
Two of the most important "watcher" events are the
initial "live" event and the final "die" event.
The message appears prepended to the watched base path.
For example, after opening a watcher at `/a/path`, you may receive these
messages from the watcher:
- `s/self/live@/a/path`
- `e/self/die@/a/path`
The messages always begin with either an `s`, indicating a
successful operation, a `w`, indicating a non-fatal warning,
or an `e`, indicating a fatal error.
Importantly, closing the watcher will always produce an error if
- The `self/live` message has not yet been sent; or, in other words,
if the watcher has not fully started. In this case, the watcher
will immediately close after fully opening and report an error
in all calls to close.
- Any repeated calls to close the watcher. In other words, it is
considered an error to close a watcher which has already been
closed, or which does not exist. For the C API, this is also true
for passing a null object to close.
The last event will always be a `destroy` event from the watcher.
You can parse it like this, for some event `ev`:
```cpp
ev.path_type == path_type::watcher && ev.effect_type == effect_type::destroy;
```
Happy hacking.
### Your Project
This project tries to make it easy for you to work with
filesystem events. I think good tools are easy to use. If
this project is not ergonomic, file an issue.
Here is a snapshot of the output taken while preparing this
commit, right before writing this paragraph.
```json
{
"1666393024210001000": {
"path_name": "/home/edant/dev/watcher/.git/logs/HEAD",
"effect_type": "modify",
"path_type": "file"
},
"1666393024210026000": {
"path_name": "/home/edant/dev/watcher/.git/logs/refs/heads/next",
"effect_type": "modify",
"path_type": "file"
},
"1666393024210032000": {
"path_name": "/home/edant/dev/watcher/.git/refs/heads/next.lock",
"effect_type": "create",
"path_type": "other"
}
}
```
Which is pretty cool.
A capable program is [here](https://github.com/e-dant/watcher/blob/release/src/wtr/watcher/main.cpp).
## Consume
This project is accessible through:
- Conan: Includes the C++ header/library
- Nix: Provides isolation, determinism, includes header, cli, test and benchmark targets
- Bazel: Provides isolation, includes the C++ header/library and cli targets
- `tool/build`: Includes the C++ header/library, cli, test and benchmark targets
- `tool/cross`: Includes the `watcher-c` shared library and header, cross-compiled for many platforms
- CMake: Includes the single-header C++ library, the `watcher-c` library (static and shared), cli, test and benchmark targets
- Just copying the header file
<details>
<summary>Conan</summary>
See the [package here](https://conan.io/center/recipes/watcher).
</details>
<details>
<summary>Nix</summary>
```sh
nix build # To just build
nix run # Build the default target, then run without arguments
nix run . -- / | jq # Build and run, watch the root directory, pipe it to jq
nix develop # Enter an isolated development shell with everything needed to explore this project
```
</details>
<details>
<summary>Bazel</summary>
```sh
bazel build cli # Build, but don't run, the cli
bazel build hdr # Ditto, for the single-header
bazel run cli # Run the cli program without arguments
```
</details>
<details>
<summary>`tool/build`</summary>
```sh
tool/build
cd out/this/Release
# watches the current directory forever
./wtr.watcher
# watches some path for 10 seconds
./wtr.watcher 'your/favorite/path' -s 10
```
This will take care of some platform-specifics, building the
release, debug, and sanitizer variants, and running some tests.
</details>
<details>
<summary>CMake</summary>
```sh
cmake -S . -B out
cmake --build out --config Release
cd out
# watches the current directory forever
./wtr.watcher
# watches some path for 10 seconds
./wtr.watcher 'your/favorite/path' -s 10
```
</details>
## Bugs & Limitations
<details>
<summary>"Access" events are ignored</summary>
Watchers on all platforms intentionally ignore
modification events which only change the acess
time on a file or directory.
The utility of those events was questionable.
It seemed more harmful than good. Other watchers,
like Microsoft's C# watcher, ignore them by default.
Some user applications rely on modification events
to know when themselves to reload a file.
Better, more complete solutions exist, and these
defaults might again change.
Providing a way to ignore events from a process-id,
a shorthand from "this" process, and a way to specify
which kinds of event sources we are interested in
are good candidates for more complete solutions.
</details>
<details>
<summary>Safety and C++</summary>
I was comfortable with C++ when I first wrote
this. I later rewrote this project in Rust as
an experiment. There are benefits and drawbacks
to Rust. Some things were a bit safer to express,
other things were definitely not. The necessity
of doing pointer math on some variably-sized
opaque types from the kernel, for example, is not
safer to express in Rust. Other things are safer,
but this project doesn't benefit much from them.
Rust really shines in usability and expression.
That might be enough of a reason to use it.
Among other things, we could work with async
traits and algebraic types for great good.
I'm not sure if there is a language that can
"just" make the majority of the code in this
project safe by definition.
The guts of this project, the adapters, talk
to the kernel. They are bound to use unsafe,
ill-typed, caveat-rich system-level interfaces.
The public API is just around 100 lines, is
well-typed, well-tested, and human-verifiable.
Not much happens there.
Creating an FFI by exposing the adapters with
a C ABI might be worthwhile. Most languages
should be able to hook into that.
The safety of the platform adapters necessarily
depends on each platform's documentation for
their interfaces. Like with all system-level
interfaces, as long as we ensure the correct
pre-and-post-conditions, and those conditions
are well-defined, we should be fine.
</details>
<details>
<summary>Platform-specific adapter selection</summary>
Among the platform-specific [implementations](https://github.com/e-dant/watcher/tree/release/devel/include/detail/wtr/watcher/adapter),
the `FSEvents` API is used on Darwin and the
`ReadDirectoryChanges` API is used on Windows.
There is some extra work we do to select the best
adapter on Linux. The `fanotify` adapter is used
when the kernel version is greater than 5.9, the
containing process has root priveleges, and the
necessary system calls are otherwise allowed.
The system calls associated with `fanotify` may
be disallowed when inside a container or cgroup,
despite the necessary priviledges and kernel
version. The `inotify` adapter is used otherwise.
You can find the selection code for Linux [here](https://github.com/e-dant/watcher/blob/next/devel/include/detail/wtr/watcher/adapter/linux/watch.hpp).
The namespaces for our [adapters](https://github.com/e-dant/watcher/tree/release/devel/include/detail/wtr/watcher/adapter)
are inline. When the (internal) `detail::...::watch()`
function is [invoked](https://github.com/e-dant/watcher/blob/release/devel/include/wtr/watcher-/watch.hpp#L65),
it resolves to one (and only one) platform-specifc
implementation of the `watch()` function. One symbol,
many platforms, where the platforms are inline
namespaces.
</details>
<details>
<summary>Exceptions to Efficient Scanning</summary>
Efficiency takes a hit when we bring out the `warthog`,
our platform-independent adapter. This adapter is used
on platforms that lack better alternatives, such as (not
Darwin) BSD and Solaris (because `warthog` beats `kqueue`).
*Watcher* is still relatively efficient when it has no
alternative better than `warthog`. As a thumb-rule,
scanning more than one-hundred-thousand paths with `warthog`
might stutter.
I'll keep my eyes open for better kernel APIs on BSD.
</details>
<details>
<summary>Ready State</summary>
There is no reliable way to communicate when a
watcher is ready to send events to the callback.
For a few thousand paths, this may take a few
milliseconds. For tens-of-thousands of paths,
consider waiting a few seconds.
</details>
<details>
<summary>Unsupported events</summary>
None of the platform-specific implementations provide
information on what attributes were changed from.
This makes supporting those events dependant on storing
this information ourselves. Storing maps of paths to
`stat` structures, diffing them on attribute changes,
is a non-insignificant memory commitment.
The owner and attribute events are unsupported because
I'm not sure how to support those events efficienty.
</details>
<details>
<summary>Unsupported filesystems</summary>
Special filesystems, including `/proc` and `/sys`,
cannot be watched with `inotify`, `fanotify` or the
`warthog`. Future work may involve dispatching ebpf
programs for the kernel to use. This would allow us
to monitor for `modify` events on some of those
special filesystem.
</details>
<details>
<summary>Resource limitations</summary>
The number of watched files is limited when `inotify`
is used.
</details>
## Relevant OS APIs Used
<details>
<summary>Linux</summary>
- `inotify`
- `fanotify`
- `epoll`
- `eventfd`
</details>
<details>
<summary>Darwin</summary>
- `FSEvents`
- `dispatch`
</details>
<details>
<summary>Windows</summary>
- `ReadDirectoryChangesW`
- `IoCompletionPort`
</details>
## Minimum C++ Version
For the header-only library and the tiny-watcher,
C++17 and up should be fine.
We might use C++20 coroutines someday.
## Cache Efficiency
```sh
$ tool/gen-event/dir &
$ tool/gen-event/file &
$ valgrind --tool=cachegrind wtr.watcher ~ -s 30
```
```txt
I refs: 797,368,564
I1 misses: 6,807
LLi misses: 2,799
I1 miss rate: 0.00%
LLi miss rate: 0.00%
D refs: 338,544,669 (224,680,988 rd + 113,863,681 wr)
D1 misses: 35,331 ( 24,823 rd + 10,508 wr)
LLd misses: 11,884 ( 8,121 rd + 3,763 wr)
D1 miss rate: 0.0% ( 0.0% + 0.0% )
LLd miss rate: 0.0% ( 0.0% + 0.0% )
LL refs: 42,138 ( 31,630 rd + 10,508 wr)
LL misses: 14,683 ( 10,920 rd + 3,763 wr)
LL miss rate: 0.0% ( 0.0% + 0.0% )
```
## Namespaces and the Directory Tree
Namespaces and symbols closely follow the directories in the `devel/include` folder.
Inline namespaces are in directories with the `-` affix.
For example, `wtr::watch` is inside the file `devel/include/wtr/watcher-/watch.hpp`.
The namespace `watcher` in `wtr::watcher::watch` is anonymous by this convention.
More in depth: the function `::detail::wtr::watcher::adapter::watch()` is defined inside
one (and only one!) of the files `devel/include/detail/wtr/watcher/adapter/*/watch.hpp`,
where `*` is decided at compile-time (depending on the host's operating system).
All of the headers in `devel/include` are amalgamated into `include/wtr/watcher.hpp`
and an include guard is added to the top. The include guard doesn't change with the
release version. In the future, it might.
```
watcher
├── src
│ └── wtr
│ ├── watcher
│ │ └── main.cpp
│ └── tiny_watcher
│ └── main.cpp
├── out
├── include
│ └── wtr
│ └── watcher.hpp
└── devel
├── src
│ └── wtr
└── include
├── wtr
│ ├── watcher.hpp
│ └── watcher-
│ ├── watch.hpp
│ └── event.hpp
└── detail
└── wtr
└── watcher
├── semabin.hpp
└── adapter
├── windows
│ └── watch.hpp
├── warthog
│ └── watch.hpp
├── linux
│ ├── watch.hpp
│ ├── sysres.hpp
│ ├── inotify
│ │ └── watch.hpp
│ └── fanotify
│ └── watch.hpp
└── darwin
└── watch.hpp
```
> You can run [`tool/tree`](https://github.com/e-dant/watcher/blob/release/tool/tree) to view this tree locally.
<details>
<summary>Comparison with Similar Projects</summary>
```yml
https://github.com/notify-rs/notify:
lines of code: 2799
lines of tests: 475
lines of docs: 1071
implementation languages: rust
interface languages: rust
supported platforms: linux, windows, darwin, bsd
kernel apis: inotify, readdirectorychanges, fsevents, kqueue
non-blocking: yes
dependencies: none
tests: yes
static analysis: yes (borrow checked, memory and concurrency safe language)
https://github.com/e-dant/watcher:
lines of code: 1579
lines of tests: 881
lines of docs: 1977
implementation languages: cpp
interface languages: cpp, shells
supported platforms: linux, darwin, windows, bsd
kernel apis: inotify, fanotify, fsevents, readdirectorychanges
non-blocking: yes
dependencies: none
tests: yes
static analysis: yes
https://github.com/facebook/watchman.git:
lines of code: 37435
lines of tests: unknown
lines of docs: unknown
implementation languages: cpp, c
interface languages: cpp, js, java, python, ruby, rust, shells
supported platforms: linux, darwin, windows, maybe bsd
kernel apis: inotify, fsevents, readdirectorychanges
non-blocking: yes
dependencies: none
tests: yes (many)
static analysis: yes (all available)
https://github.com/p-ranav/fswatch:
lines of code: 245
lines of tests: 19
lines of docs: 114
implementation languages: cpp
interface languages: cpp, shells
supported platforms: linux, darwin, windows, bsd
kernel apis: inotify
non-blocking: maybe
dependencies: none
tests: some
static analysis: none
https://github.com/tywkeene/go-fsevents:
lines of code: 413
lines of tests: 401
lines of docs: 384
implementation languages: go
interface languages: go
supported platforms: linux
kernel apis: inotify
non-blocking: yes
dependencies: yes
tests: yes
static analysis: none (gc language)
https://github.com/radovskyb/watcher:
lines of code: 552
lines of tests: 767
lines of docs: 399
implementation languages: go
interface languages: go
supported platforms: linux, darwin, windows
kernel apis: none
non-blocking: no
dependencies: none
tests: yes
static analysis: none
https://github.com/parcel-bundler/watcher:
lines of code: 2862
lines of tests: 474
lines of docs: 791
implementation languages: cpp
interface languages: js
supported platforms: linux, darwin, windows, maybe bsd
kernel apis: fsevents, inotify, readdirectorychanges
non-blocking: yes
dependencies: none
tests: some (js bindings)
static analysis: none (interpreted language)
https://github.com/atom/watcher:
lines of code: 7789
lines of tests: 1864
lines of docs: 1334
implementation languages: cpp
interface languages: js
supported platforms: linux, darwin, windows, maybe bsd
kernel apis: inotify, fsevents, readdirectorychanges
non-blocking: yes
dependencies: none
tests: some (js bindings)
static analysis: none
https://github.com/paulmillr/chokidar:
lines of code: 1544
lines of tests: 1823
lines of docs: 1377
implementation languages: js
interface languages: js
supported platforms: linux, darwin, windows, bsd
kernel apis: fsevents
non-blocking: maybe
dependencies: yes
tests: yes (many)
static analysis: none (interpreted language)
https://github.com/Axosoft/nsfw:
lines of code: 2536
lines of tests: 1085
lines of docs: 148
implementation languages: cpp
interface languages: js
supported platforms: linux, darwin, windows, maybe bsd
kernel apis: fsevents
non-blocking: maybe
dependencies: yes (many)
tests: yes (js bindings)
static analysis: none
https://github.com/canton7/SyncTrayzor:
lines of code: 17102
lines of tests: 0
lines of docs: 2303
implementation languages: c#
interface languages: c#
supported platforms: windows
kernel apis: unknown
non-blocking: yes
dependencies: unknown
tests: none
static analysis: none (managed language)
https://github.com/g0t4/Rx-FileSystemWatcher:
lines of code: 360
lines of tests: 0
lines of docs: 46
implementation languages: c#
interface languages: c#
supported platforms: windows
kernel apis: unknown
non-blocking: yes
dependencies: unknown
tests: yes
static analysis: none (managed language)
```
</details>
Raw data
{
"_id": null,
"home_page": null,
"name": "wtr-watcher",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "watcher, filesystem, events, async",
"author": "Will",
"author_email": null,
"download_url": null,
"platform": null,
"description": "# Watcher\n\n[![Conan Center](https://img.shields.io/conan/v/watcher)](https://conan.io/center/recipes/watcher)\n[![Rust/Cargo Crate](https://img.shields.io/crates/v/wtr-watcher.svg)](https://crates.io/crates/wtr-watcher)\n[![PyPI/Pip Package](https://badge.fury.io/py/wtr-watcher.svg)](https://badge.fury.io/py/wtr-watcher)\n[![Builds and Publishing for Distribution](https://github.com/e-dant/watcher/actions/workflows/dist.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/dist.yml)\n[![CodeQL Tests](https://github.com/e-dant/watcher/actions/workflows/codeql.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/codeql.yml)\n[![Linux Tests](https://github.com/e-dant/watcher/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/ubuntu.yml)\n[![macOS Tests](https://github.com/e-dant/watcher/actions/workflows/macos.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/macos.yml)\n[![Android Compilation Tests](https://github.com/e-dant/watcher/actions/workflows/android.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/android.yml)\n[![Windows Tests](https://github.com/e-dant/watcher/actions/workflows/windows.yml/badge.svg)](https://github.com/e-dant/watcher/actions/workflows/windows.yml)\n\n## Quick Start\n\n<details>\n<summary>C++</summary>\n\n```cpp\n#include \"wtr/watcher.hpp\"\n#include <iostream>\n#include <string>\n\nusing namespace std;\nusing namespace wtr;\n\n// The event type, and every field within it, has\n// string conversions and stream operators. All\n// kinds of strings -- Narrow, wide and weird ones.\n// If we don't want particular formatting, we can\n// json-serialize and show the event like this:\n// some_stream << event\n// Here, we'll apply our own formatting.\nauto show(event e) {\n cout << to<string>(e.effect_type) + ' '\n + to<string>(e.path_type) + ' '\n + to<string>(e.path_name)\n + (e.associated ? \" -> \" + to<string>(e.associated->path_name) : \"\")\n << endl;\n}\n\nauto main() -> int {\n // Watch the current directory asynchronously,\n // calling the provided function on each event.\n auto watcher = watch(\".\", show);\n\n // Do some work. (We'll just wait for a newline.)\n getchar();\n\n // The watcher would close itself around here,\n // though we can check and close it ourselves.\n return watcher.close() ? 0 : 1;\n}\n```\n\n```sh\n# Sigh\nPLATFORM_EXTRAS=$(test \"$(uname)\" = Darwin && echo '-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -framework CoreFoundation -framework CoreServices')\n# Build\neval c++ -std=c++17 -Iinclude src/wtr/tiny_watcher/main.cpp -o watcher $PLATFORM_EXTRAS\n# Run\n./watcher\n```\n</details>\n\n<details>\n<summary>C</summary>\n\n```c\n#include \"wtr/watcher-c.h\"\n#include <stdio.h>\n\nvoid callback(struct wtr_watcher_event event, void* _ctx) {\n printf(\n \"path name: %s, effect type: %d path type: %d, effect time: %lld, associated path name: %s\\n\",\n event.path_name,\n event.effect_type,\n event.path_type,\n event.effect_time,\n event.associated_path_name ? event.associated_path_name : \"\"\n );\n}\n\nint main() {\n void* watcher = wtr_watcher_open(\".\", callback, NULL);\n getchar();\n return ! wtr_watcher_close(watcher);\n}\n```\n</details>\n\n<details>\n<summary>Python</summary>\n\n```sh\npip install wtr-watcher\n```\n\n```python\nfrom watcher import Watch\n\nwith Watch(\".\", print):\n input()\n```\n</details>\n\n<details>\n<summary>Rust</summary>\n\n```sh\ncargo add wtr-watcher tokio futures\n```\n\n```rust\nuse futures::StreamExt;\nuse wtr_watcher::Watch;\n\n#[tokio::main(flavor = \"current_thread\")]\nasync fn main() -> Result<(), Box<dyn std::error::Error>> {\n let show = |e| async move { println!(\"{e:?}\") };\n let events = Watch::try_new(\".\")?;\n events.for_each(show).await;\n Ok(())\n}\n```\n</details>\n\n<details>\n<summary>Node.js</summary>\n\n```javascript\nimport * as watcher from 'watcher';\n\nvar w = watcher.watch('.', (event) => {\n console.log(event);\n});\n\nprocess.stdin.on('data', () => {\n w.close();\n process.exit();\n});\n```\n</details>\n\nThe output of each above will be something this, depending on the format:\n\n```\nmodify file /home/e-dant/dev/watcher/.git/refs/heads/next.lock\nrename file /home/e-dant/dev/watcher/.git/refs/heads/next.lock -> /home/e-dant/dev/watcher/.git/refs/heads/next\ncreate file /home/e-dant/dev/watcher/.git/HEAD.lock\n```\n\nEnjoy!\n\n---\n\n## Tell Me More\n\nA filesystem event watcher which is\n\n1. Friendly\n> I try to keep the [1579](https://github.com/e-dant/watcher/blob/release/tool/sl)\nlines that make up the runtime of *Watcher* [relatively simple](https://github.com/e-dant/watcher/blob/release/include/wtr/watcher.hpp)\nand the API practical:\n```cpp\nauto w = watch(path, [](event ev) { cout << ev; });\n```\n```sh\nwtr.watcher ~\n```\n\n2. Modular\n> *Watcher* may be used as **a library, a program, or both**.\nIf you aren't looking to create something with the library, no worries.\nJust use ours and you've got yourself a filesystem watcher which prints\nfilesystem events as JSON. Neat. Here's how:\n```bash\n# The main branch is the (latest) release branch.\ngit clone https://github.com/e-dant/watcher.git && cd watcher\n# Via Nix\nnix run | grep -oE 'cmake-is-tough'\n# With the build script\ntool/build --no-build-test --no-run && cd out/this/Release # Build the release version for the host platform.\n./wtr.watcher | grep -oE 'needle-in-a-haystack/.+\"' # Use it, pipe it, whatever. (This is an .exe on Windows.)\n```\n\n3. Efficient\n> You can watch an *entire filesystem* with this project.\nIn [almost all cases](https://github.com/e-dant/watcher/tree/release#exceptions-to-efficient-scanning),\nwe use a near-zero amount of resources and make\n[efficient use of the cache](https://github.com/e-dant/watcher/tree/release#cache-efficiency).\nWe regularly test that the overhead of detecting and sending an event to the user is\nan order of magnitude less than the filesystem operations being measured.\n\n4. Well Tested\n> We run this project through\n[unit tests against all available sanitiziers](https://github.com/e-dant/watcher/actions).\nThis code tries hard to be thread, memory, bounds, type and resource-safe. What we lack\nfrom the language, we try to make up for with testing. For some practical definition of safety,\nthis project probably fits.\n\n5. Dependency Minimal\n> *Watcher* depends on the C++ Standard Library. For efficiency,\nwe [leverage the OS](https://github.com/e-dant/watcher/tree/release#os-apis-used)\nwhen possible on Linux, Darwin and Windows. For testing and\ndebugging, we use [Snitch](https://github.com/cschreib/snitch) and\n[Sanitizers](https://clang.llvm.org/docs/index.html).\n\n6. Portable\n> *Watcher* is runnable almost anywhere. The only requirement\nis a filesystem.\n\n---\n\n## Usage\n\n### Project Content\n\nThe important pieces are the (header-only) library and the (optional) CLI program.\n\n- C++ Header-Only Library: `include/wtr/watcher.hpp`.\n Include this to use *Watcher* in your C++ project. Copying this into your project, and\n including it as `#include \"wtr/watcher.hpp\"` (or similar) is sufficient to get up and\n running in this language. Some extra documentation and high-level library internals can\n be found in the [event](https://github.com/e-dant/watcher/blob/release/devel/include/wtr/watcher-/event.hpp)\n and [watch](https://github.com/e-dant/watcher/blob/release/devel/include/wtr/watcher-/watch.hpp) headers.\n- C Library: `watcher-c`.\n Build this to use *Watcher* from C or through an FFI in other languages.\n- Full CLI Program: `src/wtr/watcher/main.cpp`.\n Build this to use *Watcher* from the command line. The output is an exhaustive JSON stream.\n- Minimal CLI Program: `src/wtr/tiny_watcher/main.cpp`.\n A very minimal, more human-readable, CLI program. The source for this is almost identical\n to the example usage for C++.\n\nA directory tree is [in the notes below](https://github.com/e-dant/watcher/tree/release#namespaces-and-the-directory-tree).\n\n### The Library\n\nThe two fundamental building blocks here are:\n - The `watch` function or class (depending on the language)\n - The `event` object (or similarly named, again depending on the language)\n\n`watch` takes a path, which is a string-like thing, and a\ncallback, with is a function-like thing. For example, passing\n`watch` a character array and a closure would work well in C++.\n\nExamples for a variety of languages can be found in the [Quick Start](https://github.com/e-dant/watcher/tree/release#quick-start).\nThe API is relatively consistent across languages.\n\nThe watcher will happily continue watching until you stop\nit or it hits an unrecoverable error.\n\nThe `event` object is used to pass information about\nfilesystem events to the callback given (by you) to `watch`.\n\nThe `event` object will contain:\n - `path_name`, which is an absolute path to the event.\n - `path_type`, the type of path. One of:\n - `dir`\n - `file`\n - `hard_link`\n - `sym_link`\n - `watcher`\n - `other`\n - `effect_type`, \"what happened\". One of:\n - `rename`\n - `modify`\n - `create`\n - `destroy`\n - `owner`\n - `other`\n - `effect_time`, the time of the event in nanoseconds since epoch.\n - `associated` (an event, C++) or `associated_path_name` (all other implementations, a single path name):\n - For the C++ implementation, this is a recursive structure. Another event, associated with \"this\" one, is stored here.\n The only events stored here, currently, are the renamed-to part of rename events.\n - For all other implementations, this field represents the path name of an associated event.\n - The implementation in C++, a recursive structure, was chosen to future-proof the library in the event that\n we need to support other associated events.\n\n(Note that, for JavaScript, we use the camel-case, to be consistent with that language's ecosystem.)\n\n#### State Changes and Special Events\n\nThe `watcher` type is special.\n\nEvents with this type will include messages from\nthe watcher. You may recieve error messages or\nimportant status updates.\n\nThis format was chosen to support asynchronous messages\nfrom the watcher in a generic, portable format.\n\nTwo of the most important \"watcher\" events are the\ninitial \"live\" event and the final \"die\" event.\n\nThe message appears prepended to the watched base path.\n\nFor example, after opening a watcher at `/a/path`, you may receive these\nmessages from the watcher:\n- `s/self/live@/a/path`\n- `e/self/die@/a/path`\n\nThe messages always begin with either an `s`, indicating a\nsuccessful operation, a `w`, indicating a non-fatal warning,\nor an `e`, indicating a fatal error.\n\nImportantly, closing the watcher will always produce an error if\n- The `self/live` message has not yet been sent; or, in other words,\n if the watcher has not fully started. In this case, the watcher\n will immediately close after fully opening and report an error\n in all calls to close.\n- Any repeated calls to close the watcher. In other words, it is\n considered an error to close a watcher which has already been\n closed, or which does not exist. For the C API, this is also true\n for passing a null object to close.\n\nThe last event will always be a `destroy` event from the watcher.\nYou can parse it like this, for some event `ev`:\n\n```cpp\nev.path_type == path_type::watcher && ev.effect_type == effect_type::destroy;\n```\n\nHappy hacking.\n\n### Your Project\n\nThis project tries to make it easy for you to work with\nfilesystem events. I think good tools are easy to use. If\nthis project is not ergonomic, file an issue.\n\nHere is a snapshot of the output taken while preparing this\ncommit, right before writing this paragraph.\n\n```json\n{\n \"1666393024210001000\": {\n \"path_name\": \"/home/edant/dev/watcher/.git/logs/HEAD\",\n \"effect_type\": \"modify\",\n \"path_type\": \"file\"\n },\n \"1666393024210026000\": {\n \"path_name\": \"/home/edant/dev/watcher/.git/logs/refs/heads/next\",\n \"effect_type\": \"modify\",\n \"path_type\": \"file\"\n },\n \"1666393024210032000\": {\n \"path_name\": \"/home/edant/dev/watcher/.git/refs/heads/next.lock\",\n \"effect_type\": \"create\",\n \"path_type\": \"other\"\n }\n}\n```\n\nWhich is pretty cool.\n\nA capable program is [here](https://github.com/e-dant/watcher/blob/release/src/wtr/watcher/main.cpp).\n\n## Consume\n\nThis project is accessible through:\n- Conan: Includes the C++ header/library\n- Nix: Provides isolation, determinism, includes header, cli, test and benchmark targets\n- Bazel: Provides isolation, includes the C++ header/library and cli targets\n- `tool/build`: Includes the C++ header/library, cli, test and benchmark targets\n- `tool/cross`: Includes the `watcher-c` shared library and header, cross-compiled for many platforms\n- CMake: Includes the single-header C++ library, the `watcher-c` library (static and shared), cli, test and benchmark targets\n- Just copying the header file\n\n<details>\n<summary>Conan</summary>\n\nSee the [package here](https://conan.io/center/recipes/watcher).\n</details>\n\n<details>\n<summary>Nix</summary>\n\n```sh\nnix build # To just build\nnix run # Build the default target, then run without arguments\nnix run . -- / | jq # Build and run, watch the root directory, pipe it to jq\nnix develop # Enter an isolated development shell with everything needed to explore this project\n```\n</details>\n\n<details>\n<summary>Bazel</summary>\n\n```sh\nbazel build cli # Build, but don't run, the cli\nbazel build hdr # Ditto, for the single-header\nbazel run cli # Run the cli program without arguments\n```\n</details>\n\n<details>\n<summary>`tool/build`</summary>\n\n```sh\ntool/build\ncd out/this/Release\n\n# watches the current directory forever\n./wtr.watcher\n# watches some path for 10 seconds\n./wtr.watcher 'your/favorite/path' -s 10\n```\n\nThis will take care of some platform-specifics, building the\nrelease, debug, and sanitizer variants, and running some tests.\n</details>\n\n<details>\n<summary>CMake</summary>\n\n```sh\ncmake -S . -B out\ncmake --build out --config Release\ncd out\n\n# watches the current directory forever\n./wtr.watcher\n# watches some path for 10 seconds\n./wtr.watcher 'your/favorite/path' -s 10\n```\n</details>\n\n## Bugs & Limitations\n\n<details>\n<summary>\"Access\" events are ignored</summary>\n\nWatchers on all platforms intentionally ignore\nmodification events which only change the acess\ntime on a file or directory.\n\nThe utility of those events was questionable.\n\nIt seemed more harmful than good. Other watchers,\nlike Microsoft's C# watcher, ignore them by default.\nSome user applications rely on modification events\nto know when themselves to reload a file.\n\nBetter, more complete solutions exist, and these\ndefaults might again change.\n\nProviding a way to ignore events from a process-id,\na shorthand from \"this\" process, and a way to specify\nwhich kinds of event sources we are interested in\nare good candidates for more complete solutions.\n</details>\n\n<details>\n<summary>Safety and C++</summary>\n\nI was comfortable with C++ when I first wrote\nthis. I later rewrote this project in Rust as\nan experiment. There are benefits and drawbacks\nto Rust. Some things were a bit safer to express,\nother things were definitely not. The necessity\nof doing pointer math on some variably-sized\nopaque types from the kernel, for example, is not\nsafer to express in Rust. Other things are safer,\nbut this project doesn't benefit much from them.\n\nRust really shines in usability and expression.\nThat might be enough of a reason to use it.\nAmong other things, we could work with async\ntraits and algebraic types for great good.\n\nI'm not sure if there is a language that can\n\"just\" make the majority of the code in this\nproject safe by definition.\n\nThe guts of this project, the adapters, talk\nto the kernel. They are bound to use unsafe,\nill-typed, caveat-rich system-level interfaces.\n\nThe public API is just around 100 lines, is\nwell-typed, well-tested, and human-verifiable.\nNot much happens there.\n\nCreating an FFI by exposing the adapters with\na C ABI might be worthwhile. Most languages\nshould be able to hook into that.\n\nThe safety of the platform adapters necessarily\ndepends on each platform's documentation for\ntheir interfaces. Like with all system-level\ninterfaces, as long as we ensure the correct\npre-and-post-conditions, and those conditions\nare well-defined, we should be fine.\n</details>\n\n<details>\n<summary>Platform-specific adapter selection</summary>\n\nAmong the platform-specific [implementations](https://github.com/e-dant/watcher/tree/release/devel/include/detail/wtr/watcher/adapter),\nthe `FSEvents` API is used on Darwin and the\n`ReadDirectoryChanges` API is used on Windows.\nThere is some extra work we do to select the best\nadapter on Linux. The `fanotify` adapter is used\nwhen the kernel version is greater than 5.9, the\ncontaining process has root priveleges, and the\nnecessary system calls are otherwise allowed.\nThe system calls associated with `fanotify` may\nbe disallowed when inside a container or cgroup,\ndespite the necessary priviledges and kernel\nversion. The `inotify` adapter is used otherwise.\nYou can find the selection code for Linux [here](https://github.com/e-dant/watcher/blob/next/devel/include/detail/wtr/watcher/adapter/linux/watch.hpp).\n\nThe namespaces for our [adapters](https://github.com/e-dant/watcher/tree/release/devel/include/detail/wtr/watcher/adapter)\nare inline. When the (internal) `detail::...::watch()`\nfunction is [invoked](https://github.com/e-dant/watcher/blob/release/devel/include/wtr/watcher-/watch.hpp#L65),\nit resolves to one (and only one) platform-specifc\nimplementation of the `watch()` function. One symbol,\nmany platforms, where the platforms are inline\nnamespaces.\n</details>\n\n<details>\n<summary>Exceptions to Efficient Scanning</summary>\n\nEfficiency takes a hit when we bring out the `warthog`,\nour platform-independent adapter. This adapter is used\non platforms that lack better alternatives, such as (not\nDarwin) BSD and Solaris (because `warthog` beats `kqueue`).\n\n*Watcher* is still relatively efficient when it has no\nalternative better than `warthog`. As a thumb-rule,\nscanning more than one-hundred-thousand paths with `warthog`\nmight stutter.\n\nI'll keep my eyes open for better kernel APIs on BSD.\n</details>\n\n<details>\n<summary>Ready State</summary>\n\nThere is no reliable way to communicate when a\nwatcher is ready to send events to the callback.\n\nFor a few thousand paths, this may take a few\nmilliseconds. For tens-of-thousands of paths,\nconsider waiting a few seconds.\n</details>\n\n<details>\n<summary>Unsupported events</summary>\n\nNone of the platform-specific implementations provide\ninformation on what attributes were changed from.\nThis makes supporting those events dependant on storing\nthis information ourselves. Storing maps of paths to\n`stat` structures, diffing them on attribute changes,\nis a non-insignificant memory commitment.\n\nThe owner and attribute events are unsupported because\nI'm not sure how to support those events efficienty.\n</details>\n\n<details>\n<summary>Unsupported filesystems</summary>\n\nSpecial filesystems, including `/proc` and `/sys`,\ncannot be watched with `inotify`, `fanotify` or the\n`warthog`. Future work may involve dispatching ebpf\nprograms for the kernel to use. This would allow us\nto monitor for `modify` events on some of those\nspecial filesystem.\n</details>\n\n<details>\n<summary>Resource limitations</summary>\n\nThe number of watched files is limited when `inotify`\nis used.\n</details>\n\n## Relevant OS APIs Used\n\n<details>\n<summary>Linux</summary>\n- `inotify`\n- `fanotify`\n- `epoll`\n- `eventfd`\n</details>\n<details>\n<summary>Darwin</summary>\n- `FSEvents`\n- `dispatch`\n</details>\n<details>\n<summary>Windows</summary>\n- `ReadDirectoryChangesW`\n- `IoCompletionPort`\n</details>\n\n## Minimum C++ Version\n\nFor the header-only library and the tiny-watcher,\nC++17 and up should be fine.\n\nWe might use C++20 coroutines someday.\n\n## Cache Efficiency\n\n```sh\n$ tool/gen-event/dir &\n$ tool/gen-event/file &\n$ valgrind --tool=cachegrind wtr.watcher ~ -s 30\n```\n\n```txt\nI refs: 797,368,564\nI1 misses: 6,807\nLLi misses: 2,799\nI1 miss rate: 0.00%\nLLi miss rate: 0.00%\n\nD refs: 338,544,669 (224,680,988 rd + 113,863,681 wr)\nD1 misses: 35,331 ( 24,823 rd + 10,508 wr)\nLLd misses: 11,884 ( 8,121 rd + 3,763 wr)\nD1 miss rate: 0.0% ( 0.0% + 0.0% )\n\nLLd miss rate: 0.0% ( 0.0% + 0.0% )\nLL refs: 42,138 ( 31,630 rd + 10,508 wr)\nLL misses: 14,683 ( 10,920 rd + 3,763 wr)\nLL miss rate: 0.0% ( 0.0% + 0.0% )\n```\n\n## Namespaces and the Directory Tree\n\nNamespaces and symbols closely follow the directories in the `devel/include` folder.\nInline namespaces are in directories with the `-` affix.\n\nFor example, `wtr::watch` is inside the file `devel/include/wtr/watcher-/watch.hpp`.\nThe namespace `watcher` in `wtr::watcher::watch` is anonymous by this convention.\n\nMore in depth: the function `::detail::wtr::watcher::adapter::watch()` is defined inside\none (and only one!) of the files `devel/include/detail/wtr/watcher/adapter/*/watch.hpp`,\nwhere `*` is decided at compile-time (depending on the host's operating system).\n\nAll of the headers in `devel/include` are amalgamated into `include/wtr/watcher.hpp`\nand an include guard is added to the top. The include guard doesn't change with the\nrelease version. In the future, it might.\n\n\n```\nwatcher\n\u251c\u2500\u2500 src\n\u2502 \u2514\u2500\u2500 wtr\n\u2502 \u251c\u2500\u2500 watcher\n\u2502 \u2502 \u2514\u2500\u2500 main.cpp\n\u2502 \u2514\u2500\u2500 tiny_watcher\n\u2502 \u2514\u2500\u2500 main.cpp\n\u251c\u2500\u2500 out\n\u251c\u2500\u2500 include\n\u2502 \u2514\u2500\u2500 wtr\n\u2502 \u2514\u2500\u2500 watcher.hpp\n\u2514\u2500\u2500 devel\n \u251c\u2500\u2500 src\n \u2502 \u2514\u2500\u2500 wtr\n \u2514\u2500\u2500 include\n \u251c\u2500\u2500 wtr\n \u2502 \u251c\u2500\u2500 watcher.hpp\n \u2502 \u2514\u2500\u2500 watcher-\n \u2502 \u251c\u2500\u2500 watch.hpp\n \u2502 \u2514\u2500\u2500 event.hpp\n \u2514\u2500\u2500 detail\n \u2514\u2500\u2500 wtr\n \u2514\u2500\u2500 watcher\n \u251c\u2500\u2500 semabin.hpp\n \u2514\u2500\u2500 adapter\n \u251c\u2500\u2500 windows\n \u2502 \u2514\u2500\u2500 watch.hpp\n \u251c\u2500\u2500 warthog\n \u2502 \u2514\u2500\u2500 watch.hpp\n \u251c\u2500\u2500 linux\n \u2502 \u251c\u2500\u2500 watch.hpp\n \u2502 \u251c\u2500\u2500 sysres.hpp\n \u2502 \u251c\u2500\u2500 inotify\n \u2502 \u2502 \u2514\u2500\u2500 watch.hpp\n \u2502 \u2514\u2500\u2500 fanotify\n \u2502 \u2514\u2500\u2500 watch.hpp\n \u2514\u2500\u2500 darwin\n \u2514\u2500\u2500 watch.hpp\n```\n\n> You can run [`tool/tree`](https://github.com/e-dant/watcher/blob/release/tool/tree) to view this tree locally.\n\n<details>\n<summary>Comparison with Similar Projects</summary>\n\n```yml\nhttps://github.com/notify-rs/notify:\n lines of code: 2799\n lines of tests: 475\n lines of docs: 1071\n implementation languages: rust\n interface languages: rust\n supported platforms: linux, windows, darwin, bsd\n kernel apis: inotify, readdirectorychanges, fsevents, kqueue\n non-blocking: yes\n dependencies: none\n tests: yes\n static analysis: yes (borrow checked, memory and concurrency safe language)\n\nhttps://github.com/e-dant/watcher:\n lines of code: 1579\n lines of tests: 881\n lines of docs: 1977\n implementation languages: cpp\n interface languages: cpp, shells\n supported platforms: linux, darwin, windows, bsd\n kernel apis: inotify, fanotify, fsevents, readdirectorychanges\n non-blocking: yes\n dependencies: none\n tests: yes\n static analysis: yes\n\nhttps://github.com/facebook/watchman.git:\n lines of code: 37435\n lines of tests: unknown\n lines of docs: unknown\n implementation languages: cpp, c\n interface languages: cpp, js, java, python, ruby, rust, shells\n supported platforms: linux, darwin, windows, maybe bsd\n kernel apis: inotify, fsevents, readdirectorychanges\n non-blocking: yes\n dependencies: none\n tests: yes (many)\n static analysis: yes (all available)\n\nhttps://github.com/p-ranav/fswatch:\n lines of code: 245\n lines of tests: 19\n lines of docs: 114\n implementation languages: cpp\n interface languages: cpp, shells\n supported platforms: linux, darwin, windows, bsd\n kernel apis: inotify\n non-blocking: maybe\n dependencies: none\n tests: some\n static analysis: none\n\nhttps://github.com/tywkeene/go-fsevents:\n lines of code: 413\n lines of tests: 401\n lines of docs: 384\n implementation languages: go\n interface languages: go\n supported platforms: linux\n kernel apis: inotify\n non-blocking: yes\n dependencies: yes\n tests: yes\n static analysis: none (gc language)\n\nhttps://github.com/radovskyb/watcher:\n lines of code: 552\n lines of tests: 767\n lines of docs: 399\n implementation languages: go\n interface languages: go\n supported platforms: linux, darwin, windows\n kernel apis: none\n non-blocking: no\n dependencies: none\n tests: yes\n static analysis: none\n\nhttps://github.com/parcel-bundler/watcher:\n lines of code: 2862\n lines of tests: 474\n lines of docs: 791\n implementation languages: cpp\n interface languages: js\n supported platforms: linux, darwin, windows, maybe bsd\n kernel apis: fsevents, inotify, readdirectorychanges\n non-blocking: yes\n dependencies: none\n tests: some (js bindings)\n static analysis: none (interpreted language)\n\nhttps://github.com/atom/watcher:\n lines of code: 7789\n lines of tests: 1864\n lines of docs: 1334\n implementation languages: cpp\n interface languages: js\n supported platforms: linux, darwin, windows, maybe bsd\n kernel apis: inotify, fsevents, readdirectorychanges\n non-blocking: yes\n dependencies: none\n tests: some (js bindings)\n static analysis: none\n\nhttps://github.com/paulmillr/chokidar:\n lines of code: 1544\n lines of tests: 1823\n lines of docs: 1377\n implementation languages: js\n interface languages: js\n supported platforms: linux, darwin, windows, bsd\n kernel apis: fsevents\n non-blocking: maybe\n dependencies: yes\n tests: yes (many)\n static analysis: none (interpreted language)\n\nhttps://github.com/Axosoft/nsfw:\n lines of code: 2536\n lines of tests: 1085\n lines of docs: 148\n implementation languages: cpp\n interface languages: js\n supported platforms: linux, darwin, windows, maybe bsd\n kernel apis: fsevents\n non-blocking: maybe\n dependencies: yes (many)\n tests: yes (js bindings)\n static analysis: none\n\nhttps://github.com/canton7/SyncTrayzor:\n lines of code: 17102\n lines of tests: 0\n lines of docs: 2303\n implementation languages: c#\n interface languages: c#\n supported platforms: windows\n kernel apis: unknown\n non-blocking: yes\n dependencies: unknown\n tests: none\n static analysis: none (managed language)\n\nhttps://github.com/g0t4/Rx-FileSystemWatcher:\n lines of code: 360\n lines of tests: 0\n lines of docs: 46\n implementation languages: c#\n interface languages: c#\n supported platforms: windows\n kernel apis: unknown\n non-blocking: yes\n dependencies: unknown\n tests: yes\n static analysis: none (managed language)\n\n```\n</details>\n",
"bugtrack_url": null,
"license": "Copyright 2022 github.com/e-dant MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Filesystem watcher. Works anywhere. Simple, efficient, and friendly.",
"version": "0.13.2",
"project_urls": null,
"split_keywords": [
"watcher",
" filesystem",
" events",
" async"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4686bd091346c46678baf9ea7dc8de7615a819a5706f500aec2b38d7997a0faa",
"md5": "f20029ad69f3e5122afb8410625ca8f9",
"sha256": "70c3b2f3ba177306e03d9becf23fd4366d2fe813f0e7bac178b160495d68dbc9"
},
"downloads": -1,
"filename": "wtr_watcher-0.13.2-py3-none-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "f20029ad69f3e5122afb8410625ca8f9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 33111,
"upload_time": "2024-10-28T01:27:08",
"upload_time_iso_8601": "2024-10-28T01:27:08.877482Z",
"url": "https://files.pythonhosted.org/packages/46/86/bd091346c46678baf9ea7dc8de7615a819a5706f500aec2b38d7997a0faa/wtr_watcher-0.13.2-py3-none-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8d38d719b6783ad43c6fbe8d450a322a7baf580722bb9d0de621a4e22f01aebd",
"md5": "bb4c9531ec3426e97d9758d5b85fb516",
"sha256": "40ad1b3e5b0fe539dd4f7ca28d9c19b972c56c5efc4adb1d616088fc111a9ce7"
},
"downloads": -1,
"filename": "wtr_watcher-0.13.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "bb4c9531ec3426e97d9758d5b85fb516",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 216438,
"upload_time": "2024-10-28T01:27:10",
"upload_time_iso_8601": "2024-10-28T01:27:10.662736Z",
"url": "https://files.pythonhosted.org/packages/8d/38/d719b6783ad43c6fbe8d450a322a7baf580722bb9d0de621a4e22f01aebd/wtr_watcher-0.13.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6ce469e80debfeb52ce99a9c987dbf069ab90af26a553b1dd56ef96699583644",
"md5": "fe80dabe212dbd49ccf745a2c1f1504c",
"sha256": "70d34f01a4ad52209e2ff4ab008d340f4c4de59bed5890e09c9e846738f91639"
},
"downloads": -1,
"filename": "wtr_watcher-0.13.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "fe80dabe212dbd49ccf745a2c1f1504c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 220650,
"upload_time": "2024-10-28T01:27:12",
"upload_time_iso_8601": "2024-10-28T01:27:12.389446Z",
"url": "https://files.pythonhosted.org/packages/6c/e4/69e80debfeb52ce99a9c987dbf069ab90af26a553b1dd56ef96699583644/wtr_watcher-0.13.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aadd7942ba9b1ebad69477cd5827019ed598129bc055701fd9a66b1d77e9ab6c",
"md5": "f780dd1ce4fc4244f17d73db84d31903",
"sha256": "fcf3900d15498369ae06b6657cbbea74eac3214378e0d795632a21af762bf394"
},
"downloads": -1,
"filename": "wtr_watcher-0.13.2-py3-none-musllinux_1_2_aarch64.whl",
"has_sig": false,
"md5_digest": "f780dd1ce4fc4244f17d73db84d31903",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 1002309,
"upload_time": "2024-10-28T01:27:14",
"upload_time_iso_8601": "2024-10-28T01:27:14.286226Z",
"url": "https://files.pythonhosted.org/packages/aa/dd/7942ba9b1ebad69477cd5827019ed598129bc055701fd9a66b1d77e9ab6c/wtr_watcher-0.13.2-py3-none-musllinux_1_2_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "89ad5e9ae41223d476f955391e6e12d02997b3e67ec2d8537a977eaf749eda7e",
"md5": "cddc5e3c16c24f0b6dbd2b3d30ac69c2",
"sha256": "b3fc227026a4bb3ca239daf4728220394ae1d3a3855801576525eb78bea08232"
},
"downloads": -1,
"filename": "wtr_watcher-0.13.2-py3-none-musllinux_1_2_x86_64.whl",
"has_sig": false,
"md5_digest": "cddc5e3c16c24f0b6dbd2b3d30ac69c2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 1047805,
"upload_time": "2024-10-28T01:27:16",
"upload_time_iso_8601": "2024-10-28T01:27:16.191887Z",
"url": "https://files.pythonhosted.org/packages/89/ad/5e9ae41223d476f955391e6e12d02997b3e67ec2d8537a977eaf749eda7e/wtr_watcher-0.13.2-py3-none-musllinux_1_2_x86_64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-28 01:27:08",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "wtr-watcher"
}