4

I'm looking for a cross platform library to detect when files in a directory are added or modified.
I know there are OS specific way to do this (inotify for Linux, FindFirstChangeNotification for windows, etc...).

But is there a platform independent library that works specifically in C? (Like the QFileSystemWatcher in C++)

cydan
  • 615
  • 5
  • 17

3 Answers3

2

It's now 2021 so maybe septag/dmon is your cup of tea.

From the description:

Single header C99 portable library for monitoring directory changes

... or maybe the more beefy fswatch ?

Larpon
  • 812
  • 6
  • 19
1

inotify is Linux specific, if you want some UNIX portable features you are pobably looking for something like libfam. it is name of library. Full package name is fileschanged.

fileschanged is a GNU/Linux command-line utility that reports when files have been altered.

Sumit Gemini
  • 1,836
  • 1
  • 15
  • 19
  • Cool! I didn't know that library. But what I'm searching specifically is, something that will work for Windows and for Linux – cydan Dec 06 '16 at 09:02
  • 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. – Sumit Gemini Dec 06 '16 at 09:06
-6

Sounds like a good use case for golang. Simply change $GOOS and/or $GOARCH and run go build.

Boom - trivial cross-platform development.