Results 1 to 3 of 3

Thread: Linux: Delete file problem if one happens to be in use. any DeleteLater function?

  1. #1
    Join Date
    Mar 2007
    Posts
    59
    Thanks
    7

    Default Linux: Delete file problem if one happens to be in use. any DeleteLater function?

    Hey all, i have an application suite where it needs to manage a queue of files between two applications. The player is playing all the files in a directory, while the updater may add or remove files to it based on a CRON Schedule...

    the problem becomes when coincidentally, i need to delete a file while the player is using it. Of course i need to wait till the player is done, but there is no DeleteLater... One thought was to just add the file names that fail to remove to another Queue, to go back and try them again, but before i go though all that i wanted to see if there was another reason.


    Here is the simple function i am using... Pseudo-code.

    Qt Code:
    1. if (dir.exists(mediafile)) {
    2.  
    3. // TODO: How to handle if the file is in use.
    4.  
    5. if(dir.remove(mediafile))
    6. {
    7. // "file removed";
    8.  
    9. } else {
    10.  
    11. // "unable to remove the file";
    12. }
    13.  
    14. } else {
    15.  
    16. // "In path:" << dir.path();
    17. // "unable to find the mediafile: " << mediafile;
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Linux: Delete file problem if one happens to be in use. any DeleteLater function?

    No, there is no "DeleteLater" functionality. File handling is very dependent on the underlying filesystem. It could be that some filesystems contain ioctl() calls that provide services similar to what you seek but there is no general solution to the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Linux: Delete file problem if one happens to be in use. any DeleteLater function?

    You can delete a file that is currently being used by another process without any problem. The entry in the directory is being removed but all handles to the file stay valid.

    So basically Linux (and most other Unix-like systems) already implement a "delete later" behavior by default.

    Cheers,
    _

Similar Threads

  1. Qt deleteLater() force to delete
    By axe in forum Qt Programming
    Replies: 28
    Last Post: 19th August 2011, 12:04
  2. QNetworkReply::deleteLater problem
    By TorAn in forum Qt Programming
    Replies: 5
    Last Post: 29th August 2010, 22:17
  3. Let QThread delete itself with deleteLater();
    By Lodorot in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2010, 16:48
  4. Replies: 4
    Last Post: 19th February 2009, 11:10
  5. Delete Function
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2007, 12:17

Tags for this Thread

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.