OS-independent API to monitor file system?

后端 未结 2 1520
野趣味
野趣味 2021-02-15 22:14

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 d

相关标签:
2条回答
  • 2021-02-15 22:27

    The APIs are totally different for Windows, Linux, Mac OS X, and any other Unix you can name, it seems. I don't know of any cross-platform library that handles this in a consistent way.

    0 讨论(0)
  • 2021-02-15 22:50

    A bonified answer, albeit one that requires a largish library dependency (well-worth it IMO)!

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

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

    Notes

    • 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).
    0 讨论(0)
提交回复
热议问题