Results 1 to 5 of 5

Thread: Blocking file access

  1. #1
    Join Date
    Dec 2010
    Location
    Warsaw, Poland
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Blocking file access

    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."

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Blocking file access

    just try renaming the file to a temp name and revert it back when done...

  3. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Blocking file access

    A workaround could be to open the file in QIODevice::ReadWrite mode, it should prevent it from being written elsewhere.

  4. #4
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Blocking file access

    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.

  5. #5
    Join Date
    Dec 2010
    Location
    Warsaw, Poland
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Blocking file access

    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."

Similar Threads

  1. Can we access .mdb file from Qt creator
    By revathisuma in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2011, 02:46
  2. Access an object from another file.
    By cbarmpar in forum General Programming
    Replies: 1
    Last Post: 6th September 2008, 22:17
  3. Obtaining File Access Rights
    By arbi in forum General Programming
    Replies: 1
    Last Post: 4th September 2008, 12:09
  4. How to create a access file .mdb
    By aiikcmo in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 10:06
  5. Access MS .mdb file on Linux
    By iGoo in forum Qt Programming
    Replies: 3
    Last Post: 15th June 2006, 09:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.