Results 1 to 5 of 5

Thread: Using QFileSystemWatcher to detect which type of file changes happened

  1. #1
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Using QFileSystemWatcher to detect which type of file changes happened

    Hello you all,
    Here I've totally understood why qfilesystemwatcher does not provide a new file added informations when some folder monitored changes.
    So, I want write a cross platform process/daemon/win32 service that do this task.
    I thinked to write a class that contains a qfilesystemwatcher that monitor some folders and signals every changement. I want to save a list of all files of every folder, and compare it with a second "image" of directory files. The differences can lead me to detect which kind of modification happened to the folder watched.

    Here is the main loop as I intend it:
    1) start monitoring a folder, take the snapshot of the files presents into the folder.
    2) when signal is raised, take second snapshot of files list, and do the comparison, determining which files are modified, deleted and added since the first snapshot.
    3) moving the second snapshot to the first, and wait for next signal, then repeat to the point 2

    Is this the correct QT way to do this in cross platform manner?
    Or could you suggest me a better solution?
    Which QT classes should I use to do the folder comparison, QDir?

    I know that this solution will not perform much, but I don't mind of performances.
    I need a simple solution to capture everz new files added to a folder with low changements in the timespawn.

  2. #2
    Join Date
    Jul 2010
    Posts
    53
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using QFileSystemWatcher to detect which type of file changes happened

    Which QT classes should I use to do the folder comparison, QDir?
    you should create tree for each root folder, and save here checksums(qChecksum()) for each file in root and it's subdirectories and so on, then compare it i think.

  3. #3
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using QFileSystemWatcher to detect which type of file changes happened

    you can save QFileInfo list and when QFileSystemWatcher says, that something changed, compare only timestamp of files in monitored dir. And yes, use QDir for your task, bat aware a situation, when QDir monitors network shared folders, because it has very poor performance.

  4. #4
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using QFileSystemWatcher to detect which type of file changes happened

    @borisbn
    Thankyou for the suggestion, I will take care about performances of QfilesytemWatcher network monitoring.

  5. #5
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using QFileSystemWatcher to detect which type of file changes happened

    I've found this qt project: http://blog.giowisys.com/?p=51 that seems good. I'lltake a look at the sources.
    bye

Similar Threads

  1. How to get file type Icon ?
    By wirasto in forum Qt Programming
    Replies: 4
    Last Post: 12th July 2010, 12:18
  2. How to know file type
    By nrabara in forum Newbie
    Replies: 2
    Last Post: 16th December 2009, 13:30
  3. Replies: 3
    Last Post: 21st August 2009, 11:39
  4. How to detect if a file is being used?
    By richardander in forum Qt Programming
    Replies: 3
    Last Post: 11th June 2009, 19:30
  5. Associating icon with a file type
    By munna in forum Qt Programming
    Replies: 3
    Last Post: 6th June 2006, 16:57

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.