mirror of
https://github.com/hamidb80/watch_for_files
synced 2026-01-14 20:11:33 +00:00
No description
| src | ||
| tests | ||
| .gitignore | ||
| readme.md | ||
| watch_for_files.nimble | ||
About
this is a cross-platform file watcher with database it means you can save into DB the lastest files modification times this special feature allows you to avoid unnecessary operations
How To use
let's take a look at the defination of the main proc goWatch
proc goWatch*(
folder: string,
tunnel: ptr Channel[ChangeFeed],
active: ptr bool,
timeInterval: int,
dbPath: string = "",
save: bool = false
)
folder: path to folder you wanna watch files changes, the program will watch file changes in any depths in that foldertunnel: a ptr to channel: changes will be sent to this channelactive: a ptr to a bool: determines whether the worker [the file watcher] should continue to work or nottimeInterval: the delay between every checkdbPath: the database pathsave: a boolean that indicates whether the files modifications state should be saved after every check or not
Note: if you specify dbPath and the file exists there, the saved state is going to be restored before the first check
the changes that will be sent to the channel are tuples of path & change_kind
ChangeFeedVariants* = enum
CFCreate, CFEdit, CFDelete
ChangeFeed* = tuple
path: string
kind: ChangeFeedVariants
you can find the example of usage in tests/test.nim