summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfmMenu.cpp
authorerik <erik>2007-01-10 17:27:56 (UTC)
committer erik <erik>2007-01-10 17:27:56 (UTC)
commitd8e580a239ab84fbe063b2f3779d417598d5ca0a (patch) (unidiff)
treea8b215c071088f167f011e51027b0a30ef3a5622 /noncore/apps/advancedfm/advancedfmMenu.cpp
parente7d3e1d0f3c75979c01ea6373ed3c80d0c986000 (diff)
downloadopie-d8e580a239ab84fbe063b2f3779d417598d5ca0a.zip
opie-d8e580a239ab84fbe063b2f3779d417598d5ca0a.tar.gz
opie-d8e580a239ab84fbe063b2f3779d417598d5ca0a.tar.bz2
BUG: The case statement was using err to figure out what to say about
why sendfile didn't work. Since err is only the return value of sendfile this meant that it never reported the right thing because it can only be -1 at this point. What the author probably wanted to do was look at errno since that is what the man page says will have the real error info. FIX: Switch the case statement to use errno.
Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 9181810..3986b1f 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -561,49 +561,49 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
561 struct stat status; 561 struct stat status;
562 QFile srcFile(src); 562 QFile srcFile(src);
563 QFile destFile(dest); 563 QFile destFile(dest);
564 int err=0; 564 int err=0;
565 int read_fd=0; 565 int read_fd=0;
566 int write_fd=0; 566 int write_fd=0;
567 struct stat stat_buf; 567 struct stat stat_buf;
568 off_t offset = 0; 568 off_t offset = 0;
569 if(!srcFile.open( IO_ReadOnly|IO_Raw)) { 569 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
570// owarn << "open failed" << oendl; 570// owarn << "open failed" << oendl;
571 return success = false; 571 return success = false;
572 } 572 }
573 read_fd = srcFile.handle(); 573 read_fd = srcFile.handle();
574 if(read_fd != -1) { 574 if(read_fd != -1) {
575 fstat (read_fd, &stat_buf); 575 fstat (read_fd, &stat_buf);
576 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 576 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
577// owarn << "destfile open failed" << oendl; 577// owarn << "destfile open failed" << oendl;
578 return success = false; 578 return success = false;
579 } 579 }
580 write_fd = destFile.handle(); 580 write_fd = destFile.handle();
581 if(write_fd != -1) { 581 if(write_fd != -1) {
582 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 582 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
583 if( err == -1) { 583 if( err == -1) {
584 QString msg; 584 QString msg;
585 switch(err) { 585 switch(errno) {
586 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 586 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
587 case EINVAL: msg = "Descriptor is not valid or locked. "; 587 case EINVAL: msg = "Descriptor is not valid or locked. ";
588 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 588 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
589 case EIO: msg = "Unspecified error while reading from in_fd."; 589 case EIO: msg = "Unspecified error while reading from in_fd.";
590 }; 590 };
591 success = false; 591 success = false;
592// owarn << msg << oendl; 592// owarn << msg << oendl;
593 } 593 }
594 } else { 594 } else {
595 success = false; 595 success = false;
596 } 596 }
597 } else { 597 } else {
598 success = false; 598 success = false;
599 } 599 }
600 srcFile.close(); 600 srcFile.close();
601 destFile.close(); 601 destFile.close();
602 // Set file permissions 602 // Set file permissions
603 if( stat( QFile::encodeName(src), &status ) == 0 ) { 603 if( stat( QFile::encodeName(src), &status ) == 0 ) {
604 chmod( QFile::encodeName(dest), status.st_mode ); 604 chmod( QFile::encodeName(dest), status.st_mode );
605 } 605 }
606 606
607 return success; 607 return success;
608} 608}
609 609