Skip to content

Add onEventWatchFile or onEventWatchPathRecursively to NotifierBuilder #43

@erikzenker

Description

@erikzenker

It is a common pattern to add a watch to files or folders which were created. Currently, it is possible to watch these files by a bit complicated code shown in a test case. To simplify the code one could add the following method to the NotifierBuilder:

    auto notifier = BuildNotifier()
            .watchPathRecursively(testDirectory_)
            .onEventWatchPathRecursively(Event::create | Event::isDir);
            .onEventWatchFile(Event::create);

or maybe with predefined actions. It would keep the API more clean. But overloading the method is not good practice. So give it a new name e.g.: onEventDoPredefinedAction ? (to long IMHO)

    auto notifier = BuildNotifier()
            .watchPathRecursively(testDirectory_)
            .onEvent(Event::create, Action::watchFile);
            .onEvent(Event::create | Event::isDir, Action::watchPath); // same as watchFile but more convenient
            .onEvent(Event::create | Event::isDir, Action::watchPathRecursively);
});

Metadata

Metadata

Assignees

Labels

APIIssues related to the inotify-cpp APIenhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions