-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index b5a05d3..f14f588 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -450,85 +450,91 @@ void AdvancedFm::move() { | |||
450 | QString curFile, destFile, item; | 450 | QString curFile, destFile, item; |
451 | 451 | ||
452 | QDir *thisDir = CurrentDir(); | 452 | QDir *thisDir = CurrentDir(); |
453 | QDir *thatDir = OtherDir(); | 453 | QDir *thatDir = OtherDir(); |
454 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 454 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
455 | item=(*it); | 455 | item=(*it); |
456 | QString destFile = thatDir->canonicalPath(); | 456 | QString destFile = thatDir->canonicalPath(); |
457 | 457 | ||
458 | if(destFile.right(1).find("/",0,TRUE) == -1) | 458 | if(destFile.right(1).find("/",0,TRUE) == -1) |
459 | destFile+="/"; | 459 | destFile+="/"; |
460 | destFile += item; | 460 | destFile += item; |
461 | // odebug << "Destination file is "+destFile << oendl; | 461 | // odebug << "Destination file is "+destFile << oendl; |
462 | 462 | ||
463 | curFile = thisDir->canonicalPath(); | 463 | curFile = thisDir->canonicalPath(); |
464 | if(curFile.right(1).find("/",0,TRUE) == -1) | 464 | if(curFile.right(1).find("/",0,TRUE) == -1) |
465 | curFile +="/"; | 465 | curFile +="/"; |
466 | curFile+= item; | 466 | curFile+= item; |
467 | // odebug << "CurrentFile file is " + curFile << oendl; | 467 | // odebug << "CurrentFile file is " + curFile << oendl; |
468 | 468 | ||
469 | if(QFileInfo(curFile).isDir()) { | 469 | if(QFileInfo(curFile).isDir()) { |
470 | moveDirectory( curFile, destFile ); | 470 | moveDirectory( curFile, destFile ); |
471 | rePopulate(); | 471 | rePopulate(); |
472 | return; | 472 | return; |
473 | } | 473 | } |
474 | QFile f( curFile); | 474 | QFile f( destFile); |
475 | if( f.exists()) { | 475 | if( f.exists()) { |
476 | switch ( QMessageBox::warning(this,tr("File Exists!"), | ||
477 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), | ||
478 | tr("Yes"),tr("No"),0,0,1)) { | ||
479 | case 1: | ||
480 | return; | ||
481 | break; | ||
482 | }; | ||
476 | if( !copyFile( curFile, destFile) ) { | 483 | if( !copyFile( curFile, destFile) ) { |
477 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 484 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); |
478 | return; | 485 | return; |
479 | } else | 486 | } else |
480 | QFile::remove(curFile); | 487 | QFile::remove(curFile); |
481 | } | 488 | } |
482 | } | 489 | } |
483 | |||
484 | } | 490 | } |
485 | rePopulate(); | 491 | rePopulate(); |
486 | //setOtherTabCurrent(); | 492 | //setOtherTabCurrent(); |
487 | } | 493 | } |
488 | 494 | ||
489 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 495 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
490 | int err = 0; | 496 | int err = 0; |
491 | if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; | 497 | if( copyDirectory( src, dest ) ) { |
498 | QString cmd = "rm -rf " + src; | ||
492 | err = system((const char*)cmd); | 499 | err = system((const char*)cmd); |
493 | } else | 500 | } else |
494 | err = -1; | 501 | err = -1; |
495 | 502 | ||
496 | if(err!=0) { | 503 | if(err!=0) { |
497 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); | 504 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); |
498 | return false; | 505 | return false; |
499 | } | 506 | } |
500 | return true; | 507 | return true; |
501 | } | 508 | } |
502 | 509 | ||
503 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 510 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
504 | 511 | ||
505 | QString cmd = "/bin/cp -fpR " + src + " " + dest; | 512 | QString cmd = "/bin/cp -fpR " + src + " " + dest; |
506 | owarn << cmd << oendl; | 513 | owarn << cmd << oendl; |
507 | int err = system( (const char *) cmd ); | 514 | int err = system( (const char *) cmd ); |
508 | if ( err != 0 ) { | 515 | if ( err != 0 ) { |
509 | QMessageBox::message("AdvancedFm", | 516 | QMessageBox::message("AdvancedFm", tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); |
510 | tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); | ||
511 | return false; | 517 | return false; |
512 | } | 518 | } |
513 | 519 | ||
514 | return true; | 520 | return true; |
515 | } | 521 | } |
516 | 522 | ||
517 | 523 | ||
518 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 524 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
519 | if(QFileInfo(src).isDir()) { | 525 | if(QFileInfo(src).isDir()) { |
520 | if( copyDirectory( src, dest )) { | 526 | if( copyDirectory( src, dest )) { |
521 | // setOtherTabCurrent(); | 527 | // setOtherTabCurrent(); |
522 | rePopulate(); | 528 | rePopulate(); |
523 | return true; | 529 | return true; |
524 | } | 530 | } |
525 | else | 531 | else |
526 | return false; | 532 | return false; |
527 | } | 533 | } |
528 | 534 | ||
529 | 535 | ||
530 | bool success = true; | 536 | bool success = true; |
531 | struct stat status; | 537 | struct stat status; |
532 | QFile srcFile(src); | 538 | QFile srcFile(src); |
533 | QFile destFile(dest); | 539 | QFile destFile(dest); |
534 | int err=0; | 540 | int err=0; |