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.
// the function save the file in path to /FSMOUNT_PENDRIVE_MOUNTPOINT/LOG_LOTE_DIR/loteName
{
mountPendrive(); // mount device
QDir dirPen
(FSMOUNT_PENDRIVE_MOUNTPOINT
);
// for make destiny directory
path_base.append("/");
path_base.append(loteName);
if(!dirPen.mkpath(path_base)) // create the path
{
printf("ERROR: Can't create Directory\n");
}
/* conditioning the originFile and the destinyFile */
QString fileOrigin
= path, fileDest
= FSMOUNT_PENDRIVE_MOUNTPOINT;
fileOrigin.append("/");
fileOrigin.append(file);
fileDest.append(path_base);
fileDest.append("/");
fileDest.append(file);
if(!QFile::exists(fileDest
)) // check file exists {
if(!QFile::copy( fileOrigin, fileDest
)) // copy file {
msg.setText(tr("Error: can't copy file"));
msg.exec();
goto out;
}
}
out:
umountPendrive(); // here is the problem!! can't umount device
}
// the function save the file in path to /FSMOUNT_PENDRIVE_MOUNTPOINT/LOG_LOTE_DIR/loteName
bool save2Pen::copy2Pen( QString loteName, QString file, QString path )
{
mountPendrive(); // mount device
QDir dirPen(FSMOUNT_PENDRIVE_MOUNTPOINT); // for make destiny directory
QString path_base = LOG_LOTE_DIR;
path_base.append("/");
path_base.append(loteName);
if(!dirPen.mkpath(path_base)) // create the path
{
printf("ERROR: Can't create Directory\n");
}
/* conditioning the originFile and the destinyFile */
QString fileOrigin = path, fileDest = FSMOUNT_PENDRIVE_MOUNTPOINT;
fileOrigin.append("/");
fileOrigin.append(file);
fileDest.append(path_base);
fileDest.append("/");
fileDest.append(file);
if(!QFile::exists(fileDest)) // check file exists
{
if(!QFile::copy( fileOrigin, fileDest )) // copy file
{
QMessageBox msg(this);
msg.setText(tr("Error: can't copy file"));
msg.setIcon( QMessageBox::Critical );
msg.exec();
goto out;
}
}
out:
umountPendrive(); // here is the problem!! can't umount device
}
To copy to clipboard, switch view to plain text mode
Bookmarks