summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-09-25 05:50:48 (UTC)
committer llornkcor <llornkcor>2004-09-25 05:50:48 (UTC)
commitdba0864dd99dfc86a33bde72809634be7f0da9c4 (patch) (unidiff)
tree074ccc67cc4e7474d697117357bca2c1b19cef16
parent244945237bc55945ba41f86d5f175204e00592ea (diff)
downloadopie-dba0864dd99dfc86a33bde72809634be7f0da9c4.zip
opie-dba0864dd99dfc86a33bde72809634be7f0da9c4.tar.gz
opie-dba0864dd99dfc86a33bde72809634be7f0da9c4.tar.bz2
fix move overwrite
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp114
1 files changed, 60 insertions, 54 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
@@ -445,73 +445,79 @@ void AdvancedFm::moveTimer() {
445 445
446void AdvancedFm::move() { 446void AdvancedFm::move() {
447 447
448 QStringList curFileList = getPath(); 448 QStringList curFileList = getPath();
449 if( curFileList.count() > 0) { 449 if( curFileList.count() > 0) {
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 if( !copyFile( curFile, destFile) ) { 476 switch ( QMessageBox::warning(this,tr("File Exists!"),
477 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 477 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile),
478 return; 478 tr("Yes"),tr("No"),0,0,1)) {
479 } else 479 case 1:
480 QFile::remove(curFile); 480 return;
481 } 481 break;
482 } 482 };
483 483 if( !copyFile( curFile, destFile) ) {
484 } 484 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile));
485 rePopulate(); 485 return;
486 } else
487 QFile::remove(curFile);
488 }
489 }
490 }
491 rePopulate();
486 //setOtherTabCurrent(); 492 //setOtherTabCurrent();
487} 493}
488 494
489bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { 495bool 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 ) ) {
492 err = system((const char*)cmd); 498 QString cmd = "rm -rf " + src;
493 } else 499 err = system((const char*)cmd);
494 err = -1; 500 } else
495 501 err = -1;
496 if(err!=0) { 502
497 QMessageBox::message(tr("Note"),tr("Could not move\n") + src); 503 if(err!=0) {
498 return false; 504 QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
499 } 505 return false;
500 return true; 506 }
507 return true;
501} 508}
502 509
503bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { 510bool 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 ) ); 517 return false;
511 return false; 518 }
512 }
513 519
514 return true; 520 return true;
515} 521}
516 522
517 523