2

I've a daemon (obexpushd) that writes some files in a directory. In my Qt application, I listen to changes in this directory thanks to QFileSystemWatcher. Yet, the directoryChanged signal is emitted when obexpushd creates the file, not when it has finished to write it.

So, I've to wait for obexpush to finish writing the file before processing it. What is the best strategy ?

Check the size remains the same for a fixed amount of time ? Call lsof at fixed interval ? Any better solution ?

3 Answers 3

2

Is obexpushd a program that you can change? If so, the easiest thing to do would probably be have obexpushd write to temporary file, then rename the file when it's done writing. That would be something you could monitor in your Qt program. A more robust and elegant way would be to have obexpushd communicate with your Qt program, maybe via dbus, to explicitly say when it's done.

If obexpushd isn't under your control, then one of the strategies you've listed is probably your best bet.

2
  • Modifying Obexpushd seems a good solution, but unfortunately it is less maintenable (and even less in an embedded environment !).
    – Tangui
    Commented Sep 10, 2010 at 6:34
  • I'll try this solution anyway.
    – Tangui
    Commented Sep 10, 2010 at 6:34
0

You could watch for file timestamps to change. QFileInfo makes that possible.

0

There seems to be an open bug on this issue http://bugreports.qt-project.org/browse/QTBUG-3576. If you know the filenames of the files you are waiting on, perhaps you can use QFileSystemWatcher::fileChanged().

1
  • Yes but the file is continuously modified while the obex server is receiving and saving the file. And there's no way to know what event triggered this signal.
    – Tangui
    Commented Sep 10, 2010 at 6:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.