{"id":17693380,"url":"https://github.com/ttytm/vvatch","last_synced_at":"2025-04-02T16:18:57.516Z","repository":{"id":229843437,"uuid":"748375358","full_name":"ttytm/vvatch","owner":"ttytm","description":"vvatch is cross-platform V module to monitor changes in directories. It utilizes the dmon C99 library.","archived":false,"fork":false,"pushed_at":"2024-06-05T22:10:13.000Z","size":4,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T19:11:50.784Z","etag":null,"topics":["bindings","c","cross-platform","filesystem","library","v","watcher"],"latest_commit_sha":null,"homepage":"","language":"V","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ttytm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-25T20:53:06.000Z","updated_at":"2024-11-16T00:03:47.000Z","dependencies_parsed_at":"2024-05-20T10:30:34.977Z","dependency_job_id":"695ec2ac-5a7d-4d64-bee9-1e3b1d7a2e8f","html_url":"https://github.com/ttytm/vvatch","commit_stats":null,"previous_names":["ttytm/vvatch"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fvvatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fvvatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fvvatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fvvatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttytm","download_url":"https://codeload.github.com/ttytm/vvatch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246847137,"owners_count":20843444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bindings","c","cross-platform","filesystem","library","v","watcher"],"created_at":"2024-10-24T13:44:53.213Z","updated_at":"2025-04-02T16:18:57.498Z","avatar_url":"https://github.com/ttytm.png","language":"V","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vvatch\n\nvvatch is cross-platform V module to monitor changes in directories. It utilizes the [dmon](https://github.com/septag/dmon?tab=readme-ov-file) C99 library.\n\n\u003e [!NOTE]\\\n\u003e [vmon](https://github.com/Larpon/vmon) is an already available module.\n\u003e It is the first mover in terms of being a dmon wrapper and served as an inspiration.\n\n\u003cblockquote\u003e\n\u003csub\u003e\nvvatch is a rewrite that I'm using for a client project that makes opinionated changes. It takes a different approach on the internals to allow a clean working surface. It aims to leverage the C library, increase robustness, and allows to compile programs that use the module in strict mode and with the Clang compiler.\n\u003c/sub\u003e\n\u003c/blockquote\u003e\n\n## Installation\n\n```bash\nv install ttytm.vvatch\n```\n\n## Usage\n\n```v\n// watch starts to watch the specified directory.\n// It receives the directory path, a callback that is executed on directory actions,\n// watch flags and a voidptr for additional user arguments.\npub fn watch(path string, cb fn (watch_id WatchID, action Action, root_dir string, file_path string, old_file_path string, args voidptr), flags WatchFlags, user_args voidptr) !WatchID\n\n// unwatch stops to watch the specified directory path.\npub fn (id WatchID) unwatch()\n```\n\n_Ref.:_ [`src/lib.v`](https://github.com/ttytm/vvatch/blob/main/src/lib.v)\n\n## Simple Example\n\n```v\nimport ttytm.vvatch as w\nimport time\nimport os\n\nstruct App {\nmut:\n\ttriggered bool\n}\n\nfn watch_cb(watch_id w.WatchID, action w.Action, root_path string, file_path string, old_file_path string, mut app App) {\n\tmatch action {\n\t\t.create { println('created `${file_path}`') }\n\t\t.delete { println('delated `${file_path}`') }\n\t\t.modify { println('modified `${file_path}`') }\n\t\t.move { println('moved `${old_file_path}` to `${file_path}`') }\n\t}\n\tapp.triggered = true\n}\n\nfn main() {\n\tmut app := App{}\n\n\twatcher := w.watch(os.join_path(os.home_dir(), 'Downloads'), watch_cb, w.WatchFlag.recursive,\n\t\tapp)!\n\n\t// Wait until an external event is triggered in the monitored directory.\n\tfor {\n\t\tif app.triggered {\n\t\t\tbreak\n\t\t}\n\t\t// Slow down the loop interval to reduce load.\n\t\ttime.sleep(100 * time.millisecond)\n\t}\n\n\twatcher.unwatch()\n\tw.clean()\n}\n```\n\n_Ref.:_ [`examples/simple.v`](https://github.com/ttytm/vvatch/blob/main/examples/simple.v)\n\n```\nv run examples/simple.v\n\n# Run with additional debug information\nv -g run examples/simple.v\n```\n\n## License\n\nJust as with vmon, the V code written for vvatch is licensed under MIT.\nThe utilized [dmon](https://github.com/septag/dmon) C library is licensed under the BSD 2-clause.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttytm%2Fvvatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttytm%2Fvvatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttytm%2Fvvatch/lists"}