简体   繁体   English

替代inotify以检测何时在文件夹下创建新文件

[英]Alternatives to inotify to detect when a new file is created under a folder

I am developing my program on Linux, is there a programmatic way to detect when another application creates/copies a file under/to a specific folder. 我正在Linux上开发我的程序,是否有一种编程方式来检测另一个应用程序何时在/在特定文件夹下创建/复制文件。 I want to detect the new file as fast as it is created and I would like to process the file. 我想尽可能快地检测新文件,我想处理该文件。

As far as I researched I can accomplish this using inotify. 据我研究,我可以使用inotify完成此任务。 Are there any better alternatives? 还有更好的选择吗?

inotify is the proper API provided by the Linux kernel. inotify是Linux内核提供的正确API。 Your toolkit may have convenience on top of it, eg KDirWatch from libkdecore, but that uses inotify internally. 你的工具包可能在它的上面,如方便KDirWatch从libkdecore,但在内部使用的inotify。

Using API from a toolkit is a good idea when your program is cross-platform. 当您的程序是跨平台的时,使用工具包中的API是个好主意。

http://www.highscore.de/boost/dir_monitor.zip on http://en.highscore.de/cpp/boost/asio.html is a cross-platform C++ Boost solution, though I haven't tried it yet. http://www.highscore.de/boost/dir_monitor.ziphttp://en.highscore.de/cpp/boost/asio.html是一个跨平台的C ++升压解决方案,虽然我还没有尝试过呢。

http://boost.2283326.n4.nabble.com/ASIO-file-monitoring-help-td4645105.html has code using it that is wrong, the fix looks to be to make a few more objects the author assumed could be temporary permanent instead. http://boost.2283326.n4.nabble.com/ASIO-file-monitoring-help-td4645105.html有使用它的代码是错误的,该修复程序看起来是为了使作者认为可能是临时的一些对象永久性的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM