This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Description
Hello,
I'm new to libuv, and experimenting it with uv_fs_event ( using uvw if matters ).
There are only two predefined fs events in uv_fs_event. I wrote simple code ( just prints event.filename and event.flags when received fs event) to test it
$ touch a # printed `a: 1`
$ echo 1 >> a # printed `a: 1`
$ echo 2 >> a # printed `a: 1`
$ vim a # I appended new line to the file a. Sometimes printed `a: 2`, sometimes `a: 1 a: 1`, sometimes `a: 2 a: 2`
$ rm a # printed `a: 1`
Question: What does the enum UV_RENAME mean? Why appending lines to a file generates UV_RENAME? Why vim a generates different events each time ( seems randomly ).
I think the document should be enriched. It's not very friendly to the newcomers.
Also found a bug when doing quick code searching: https://github.com/libuv/libuv/blob/b01de7341f40e1f30d78178442b0b87a46b3b7a7/test/test-fs-event.c#L202 ( events == UV_CHANGE || UV_RENAME is always true )
The code I was using:
int main() {
auto loop = uvw::Loop::getDefault();
auto fsEventHandle = loop->resource<uvw::FsEventHandle>();
fsEventHandle->start("/Users/Carter/test");
fsEventHandle->on<uvw::FsEventEvent>([](uvw::FsEventEvent& event, uvw::FsEventHandle& handle) {
std::printf("%s: %d\n", event.filename, (int)event.flags);
});
fsEventHandle->on<uvw::ErrorEvent>([](uvw::ErrorEvent& event, uvw::FsEventHandle& handle) {
std::printf("ERROR: %d\n", event.code());
});
loop->run();
}
Thanks in advance