独立于操作系统的API来监视文件系统? [英] OS-independent API to monitor file system?

查看:106
本文介绍了独立于操作系统的API来监视文件系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试一下有关分布式文件同步/复制的想法.为了在用户工作时提高效率,我想实现某种守护程序来监视某些目录中的更改(例如/home/user/dirToBeMonitored或c:\ docs和setts \ user \ dirToBeMonitored).因此,我可以知道每次(或在合理的间隔内)添加/更改/删除了哪个文件名.

I would like to experiment with ideas about distributed file synchronization/replication. To make it efficient when the user is working, I would like to implement some kind of daemon to monitor changes in some directory (e.g. /home/user/dirToBeMonitored or c:\docs and setts\user\dirToBeMonitored). So, I could be able to know which filename was added/changed/deleted at every time (or within a reasonable interval).

任何高级语言都可以吗?您是否知道一些API(以及使用哪种语言?)?

Is this possible with any high-medium level language?. Do you know some API (and in which language?) to do this?

谢谢.

推荐答案

一个附加的答案,尽管它需要较大的库依赖关系(值得IMO)!

QT提供了 QFileSystemwatcher 类,该类使用基础平台的本机机制. .

QT provides the QFileSystemwatcher class, which uses the native mechanism of the underlying platform.

更好的是,您可以将QT语言绑定用于Python或Ruby. 此处是一个简单的PyQT4使用 QFileSystemWatcher 的应用程序.

Even better, you can use the QT language bindings for Python or Ruby. Here is a simple PyQT4 application which uses QFileSystemWatcher.

注释

  • A good reference on on creating deployable PyQT4 apps, especially on OSX but should work for Windows also.
  • Same solution previously posted here.
  • Other cross-platform toolkits may also do the trick (for example Gnome's GIO has GFileMonitor, although it is UNIX only and doesn't support OSX's FSEvents mechanism afaik).

这篇关于独立于操作系统的API来监视文件系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆