Results 1 to 4 of 4

Thread: copies file doesn't work well

  1. #1
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question copies file doesn't work well

    HI.
    I have to copy a file, from a directory to another(changing the name).

    I use the static function
    Qt Code:
    1. QFile::copy(source,dest)
    To copy to clipboard, switch view to plain text mode 

    ...but, often, it doesn't make the copy(it makes the copy very late). I also remove the dest file, if one with that name exists and use the flush() function to write the buffered data.

    How can i obtain a fast written on the filesystem???
    I use linux with ext3.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: copies file doesn't work well

    QFile::copy() performs the copy in userspace, which is slow. If you are after speed, it's best to use dedicated methods. Linux has a very fast function for it called sendfile(). It is very efficient, but highly unportable - available only in Linux (other Unices might have it but with different semantics).

  3. #3
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Re: copies file doesn't work well

    i 'd like to have a portable solution.
    Why the flush() function doesn't work?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: copies file doesn't work well

    What would you like it to do? It won't speed up anything.

    As for portability, I suggest using #ifdef directives and use sendfile() on Linux, some native function on Windows and QFile::copy() elsewhere.

Similar Threads

  1. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  2. file renaming on windows
    By jdd81 in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2007, 19:41
  3. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  4. Sending Binary File with QFTP
    By nbkhwjm in forum Newbie
    Replies: 2
    Last Post: 7th March 2007, 18:10
  5. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57

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.