Results 1 to 3 of 3

Thread: problem copying files and unmount drives

  1. #1
    Join Date
    Jul 2009
    Posts
    3

    Default problem copying files and unmount drives

    Hi every body, I am new in this forum (sorry for my english).. I need help with a problem very particular;

    Sumarizing, the code do this:

    mount USB device
    copy file to usb
    umount USB device

    When I try to copy files to an USB device it's all ok, but when I try to umount the device I get the error " can't umount the device. resource is busy". Another interesting thing is, if I umount the device in another console, and do a new copy of same files are all ok. So I think the problem is in the mkpath instruction.. I probe everything (I guess) in relation with dirs.. I create with mkdir, I close the path to the USB device, etc... but I have the same error.

    Qt Code:
    1. // the function save the file in path to /FSMOUNT_PENDRIVE_MOUNTPOINT/LOG_LOTE_DIR/loteName
    2.  
    3. bool save2Pen::copy2Pen( QString loteName, QString file, QString path )
    4. {
    5.  
    6. mountPendrive(); // mount device
    7.  
    8. QDir dirPen(FSMOUNT_PENDRIVE_MOUNTPOINT); // for make destiny directory
    9.  
    10. QString path_base = LOG_LOTE_DIR;
    11.  
    12. path_base.append("/");
    13. path_base.append(loteName);
    14.  
    15.  
    16. if(!dirPen.mkpath(path_base)) // create the path
    17. {
    18. printf("ERROR: Can't create Directory\n");
    19. }
    20.  
    21.  
    22. /* conditioning the originFile and the destinyFile */
    23.  
    24. QString fileOrigin = path, fileDest = FSMOUNT_PENDRIVE_MOUNTPOINT;
    25. fileOrigin.append("/");
    26. fileOrigin.append(file);
    27.  
    28. fileDest.append(path_base);
    29. fileDest.append("/");
    30. fileDest.append(file);
    31.  
    32.  
    33. if(!QFile::exists(fileDest)) // check file exists
    34. {
    35. if(!QFile::copy( fileOrigin, fileDest )) // copy file
    36. {
    37. QMessageBox msg(this);
    38. msg.setText(tr("Error: can't copy file"));
    39. msg.setIcon( QMessageBox::Critical );
    40. msg.exec();
    41. goto out;
    42. }
    43. }
    44.  
    45.  
    46. out:
    47. umountPendrive(); // here is the problem!! can't umount device
    48.  
    49.  
    50. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by alejo; 14th July 2009 at 18:01.

  2. #2
    Join Date
    Oct 2007
    Location
    Grenoble, France
    Posts
    80
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem copying files and unmount drives

    This really doesn't look like Qt specific problem.
    Maybe you simply should do what that error message is trying to tell you? Can't you check if the device is busy before trying to unmount it?
    You have to run a level 3 diagnostic.

    Ashes to ashes, Qt to Qt ( wysota )

  3. #3
    Join Date
    Jul 2009
    Posts
    3

    Default Re: problem copying files and unmount drives

    Yes, the device still are busy. But I don't know why. maybe I need to close the files used for copy. But I'm used a static function QFile:copy().

Similar Threads

  1. problem with reading text files
    By Axsis in forum Newbie
    Replies: 1
    Last Post: 25th April 2008, 12:29
  2. compiling problem / Qt DLL files
    By ht1 in forum Newbie
    Replies: 1
    Last Post: 5th January 2008, 17:58
  3. Replies: 2
    Last Post: 5th September 2007, 22:31
  4. problem with include files
    By JR in forum General Discussion
    Replies: 2
    Last Post: 22nd December 2006, 20:44
  5. Problem converting .ui files from Qt3 to 4
    By Amanda in forum Qt Programming
    Replies: 6
    Last Post: 28th October 2006, 04:34

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.