Results 1 to 4 of 4

Thread: File system utility with more functions than QDir

  1. #1
    Join Date
    Mar 2006
    Location
    shenzhen
    Posts
    16
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default File system utility with more functions than QDir

    Hi,

    I need a file system utility with more functions than QDir,especially functionality similiar to rm and mv in Linux coreutils package.
    The utility should be portable on all platform Qt supports,and should be C++ class or functions to be used directly(I don't want to use an external program in QProcess,such as a utility like Unix shell).
    The mv function seems a little hard to implement by QDir,and to be robust,even rm needs some work(i need the -f -r etc switch functions to work).
    Do you have ever written such an utility?And if so,will you share with me?

  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: File system utility with more functions than QDir

    Quote Originally Posted by izico View Post
    The mv function seems a little hard to implement by QDir,
    What is wrong with QDir::rename()?
    and to be robust,even rm needs some work(i need the -f -r etc switch functions to work).
    Sure it does. QFile::exists(), QDir::entryList() and QDir::entryInfoList() are your friends. Together with QDir::remove() they will allow you to obtain the functionality you seek.

  3. #3
    Join Date
    Mar 2006
    Location
    shenzhen
    Posts
    16
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: File system utility with more functions than QDir

    What is wrong with QDir::rename()?

    when newName and oldName are in different partions,QDir::rename(oldname, newName) will hang(at least on one of my system). So I can't use simple if (!rename()) { copy(); remove()};(this works in Posix rename(),as it returns error quickly) I must find a portable way to know if the two are in different partitions,and I find no portable way to do this by now.
    Any good idea about this?

  4. #4
    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: File system utility with more functions than QDir

    You could use a dir model, but there is no guarantee if you symlink directories. Maybe the problem with rename() is a problem with your system and not the actual rename?

    I just checked Qt sources and it looks like Qt simply performs a copy and delete of the file in question. So the only slowdowns could be caused by performing the copy or finding filepaths.

Similar Threads

  1. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21

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.