Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我刚刚开始编程,想用 C 从头开始实现一个文件监控系统。
我在 java 中使用过 Watch Service API,但我想学习如何从头开始构建一个。我真的很感激一些帮助和指导。
谢谢。
你可以:
要么依赖现有的系统调用,这些调用将向您推送有关文件系统修改的通知(例如:inotify)
实现你自己的内核模块,它将拦截文件系统修改并通知你(如果你真的想重新实现轮子)
使用轮询方法,在内存中重建文件系统树并每隔一秒左右比较一次。这将非常消耗 cpu/io/内存,但它可能具有指导意义。