Is there any way to know if a particular file is open/in use/locked by another application/process?
-
I want to know if a file is in use in another application. I tried to look around QFile, QProcess but there seems no way to find out. I am trying to do some text file manipulation which is used constantly by many applications. Before doing anything I would like to know if it's in use/open/locked by other app.
-
Do you want to lock the file before using it?
In this case you can use http://doc.qt.io/qt-5/qlockfile.html -
will work
Such a strong word ... it depends on the advisory locking mechanism used and most linux-es will support more than one. As duly noted in the documentation it's only guaranteed to work if the same scheme is used across all processes:
Serialization is only guaranteed if all processes that access the shared resource use QLockFile, with the same file path.