Results 1 to 4 of 4

Thread: File operations

  1. #1
    Join Date
    Jun 2010
    Posts
    142
    Thanks
    11
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default File operations

    Why do you always have to have a QDir object to add/remove files and dirs? Wouldn't it be far easier to use when file operations were static methods and the QDir object would only be for holding the items, name, info, etc.?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: File operations

    QDir::remove() uses QFile::remove() which is static, but it creates a local QFile, so you won't gain anything. Why they are not static is probably because they need the functionality of QDir/QFile to run some tests before deleting and do the deleting stuff itself. And if the Trolls could have made them static, they surely would have...

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: File operations

    It's probably because the trolls wanted to keep file i/o stuff in the relevent File Engine, making it easier for things like QDir to work on totally different platforms without having to change the actual implementation.

  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 operations

    I'd say one could treat the relevant api from QDir as an overload of the same api from QFile with that difference that it is meant to operate on relative file names. If one has QFile::remove() that is static, there is no point in having the same static operation in another class.
    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.


Similar Threads

  1. Replies: 0
    Last Post: 20th July 2010, 14:55
  2. Bit operations
    By Lykurg in forum General Programming
    Replies: 1
    Last Post: 8th April 2010, 11:11
  3. Editing the file using the seek operations
    By grsandeep85 in forum Qt Programming
    Replies: 4
    Last Post: 24th March 2010, 04:30
  4. Article about asynchronous operations
    By skrzypu in forum Qt Programming
    Replies: 0
    Last Post: 10th March 2010, 11:43
  5. Graphics operations - Qt 4.1
    By hoborg in forum Newbie
    Replies: 1
    Last Post: 18th February 2006, 14:09

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.