Is there a way to somehow block a file on Windows XP by Qt function? I mean to prevent from modification by other program/device until my program unlocks it.
Is there a way to somehow block a file on Windows XP by Qt function? I mean to prevent from modification by other program/device until my program unlocks it.
"My programs don't have bugs. They just provide random features."
just try renaming the file to a temp name and revert it back when done...
A workaround could be to open the file in QIODevice::ReadWrite mode, it should prevent it from being written elsewhere.
In addition see this link about file locking.
Last edited by Talei; 20th June 2011 at 21:47. Reason: updated contents
In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
The advance of computerization however, has not yet wiped out nations and ethnic groups.
Thanks for your help. I have decided to change the filename each time I want to block it and after that delete it. I will explain why:
My app has to present picture which is loaded in loop by camera over FTP. When picture is ready to read (loaded on disk) camera sends signal over GPIO port to my app, but still there is no guarantee that when I start reading it camera won't start loading next picture. There is no physical way to synchonize my thread and device, because all pins are busy. The problem is that from time to time my app loads half of an old image and half of a new one. This solution IMHO will work, because right after signal detection I will change the filename and even if camera starts loading another picture, it will create new file on disk. When I finish my job i simply delete file and wait for another signal.
"My programs don't have bugs. They just provide random features."
Bookmarks