{"id":21401709,"url":"https://github.com/septag/dmon","last_synced_at":"2025-04-12T15:39:59.011Z","repository":{"id":35542915,"uuid":"216779019","full_name":"septag/dmon","owner":"septag","description":"Single header C99 portable library for monitoring filesystem changes. (Windows/Linux/MacOS)","archived":false,"fork":false,"pushed_at":"2025-03-18T20:54:29.000Z","size":185,"stargazers_count":251,"open_issues_count":1,"forks_count":22,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-05T13:01:38.223Z","etag":null,"topics":["c","directory-monitoring","filesystem","monitor","monitoring","multiplatform","os","single-header-lib"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/septag.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":"2019-10-22T09:49:55.000Z","updated_at":"2025-04-04T09:57:36.000Z","dependencies_parsed_at":"2022-08-08T09:15:22.441Z","dependency_job_id":"7b1dbe6c-cabc-41e7-8108-a1815f8198ce","html_url":"https://github.com/septag/dmon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/septag%2Fdmon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/septag%2Fdmon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/septag%2Fdmon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/septag%2Fdmon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/septag","download_url":"https://codeload.github.com/septag/dmon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248590714,"owners_count":21129877,"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":["c","directory-monitoring","filesystem","monitor","monitoring","multiplatform","os","single-header-lib"],"created_at":"2024-11-22T15:29:05.886Z","updated_at":"2025-04-12T15:39:58.982Z","avatar_url":"https://github.com/septag.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## dmon\n[@septag](https://twitter.com/septagh)  \n\n_dmon_ is a tiny C library that monitors changes in a directory.\nIt provides a unified solution to multiple system APIs that exist for each OS. It can also monitor directories recursively. \n\n### Platforms\n- Windows: `ReadDirectoryChangesW` backend. Tested with Windows10 SDK + Visual Studio 2019\n- Linux: `inotify` backend. Tested with gcc-7.4/clang-6, ubuntu 18.04 LTS\n- MacOS: `FSEvents` backend. Tested with MacOS-10.14 clang 10\n\n### Usage\n\nYou just have to include the file and use it's functions. It is also compatible with C++ code.\nBackslashes in Windows paths are also converted to '/' for portability.\n\n```c\n#define DMON_IMPL\n#include \"dmon.h\"\n\nstatic void watch_callback(dmon_watch_id watch_id, dmon_action action, const char* rootdir,\n                           const char* filepath, const char* oldfilepath, void* user)\n{\n    // receive change events. type of event is stored in 'action' variable\n}\n\nint main() \n{\n    dmon_init();\n    dmon_watch(\"/path/to/directory\", watch_callback, DMON_WATCHFLAGS_RECURSIVE, NULL); \n    // wait ...\n    dmon_deinit();\n\treturn 0;\n}\n```\n\nFor more information and how to customize functionality, see [dmon.h](dmon.h)\n\n# Build Example\n- Windows: ```cl test.c```\n- Linux: ```gcc test.c -lpthread -o test```\n- MacOS: ```clang test.c -framework CoreFoundation -framework CoreServices -lpthread -o test```\n\n### Linux Extras\nThere is this other file `dmon_extra.h` that you can include optionally after `dmon.h` for linux backend. \nThere are two APIs that are introduced in that header, `dmon_watch_add` and `dmon_watch_rm` in which you can add/remove \nsub-directories to currently watched directory. This can be useful in cases where there are large set of changes happening \non linux backend and you won't get all the events, because of some drawbacks of the `inotify` backend. So, by disabling `DMON_WATCHFLAGS_RECURSIVE` and using these functions to manually handle directory recursion, you can workaround those issues.\n\n\n[License (BSD 2-clause)](https://github.com/septag/dmon/blob/master/LICENSE)\n--------------------------------------------------------------------------\n\n\u003ca href=\"http://opensource.org/licenses/BSD-2-Clause\" target=\"_blank\"\u003e\n\u003cimg align=\"right\" src=\"http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png\"\u003e\n\u003c/a\u003e\n\n\tCopyright 2019 Sepehr Taghdisian. All rights reserved.\n\t\n\thttps://github.com/septag/dmon\n\t\n\tRedistribution and use in source and binary forms, with or without\n\tmodification, are permitted provided that the following conditions are met:\n\t\n\t   1. Redistributions of source code must retain the above copyright notice,\n\t      this list of conditions and the following disclaimer.\n\t\n\t   2. Redistributions in binary form must reproduce the above copyright notice,\n\t      this list of conditions and the following disclaimer in the documentation\n\t      and/or other materials provided with the distribution.\n\t\n\tTHIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR\n\tIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n\tMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n\tEVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n\tINDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n\tBUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\tDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\tLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n\tOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n\tADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseptag%2Fdmon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseptag%2Fdmon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseptag%2Fdmon/lists"}