summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp77
1 files changed, 51 insertions, 26 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 93203cd..eae86a4 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -46,3 +46,4 @@
46#include <dirent.h> 46#include <dirent.h>
47 47#include <sys/sendfile.h>
48#include <fcntl.h>
48 49
@@ -314,3 +315,3 @@ void AdvancedFm::copy()
314 msg=tr("Really copy\n%1 files?").arg(count); 315 msg=tr("Really copy\n%1 files?").arg(count);
315 switch ( QMessageBox::warning(this,tr("Delete"),msg 316 switch ( QMessageBox::warning(this,tr("Copy"),msg
316 ,tr("Yes"),tr("No"),0,0,1) ) 317 ,tr("Yes"),tr("No"),0,0,1) )
@@ -522,28 +523,52 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest )
522{ 523{
523 char bf[ 50000 ]; 524// char bf[ 50000 ];
524 int bytesRead; 525// int bytesRead;
525 bool success = TRUE; 526 bool success = true;
526 struct stat status; 527 struct stat status;
528
529// QFile s( src );
530// QFile d( dest );
531
532 int read_fd=0;
533 int write_fd=0;
534 struct stat stat_buf;
535 off_t offset = 0;
536 read_fd = ::open(src.latin1(), O_RDONLY);
537 if(read_fd != -1) {
538 fstat (read_fd, &stat_buf);
539 write_fd = ::open(dest.latin1(), O_WRONLY | O_CREAT, stat_buf.st_mode);
540 if(write_fd != -1) {
541 if(sendfile(write_fd, read_fd, &offset, stat_buf.st_size) == -1) {
542 success = false;
543 }
544 } else {
545 success = false;
546 }
547 } else {
548 success = false;
549 }
527 550
528 QFile s( src ); 551 ::close (read_fd);
529 QFile d( dest ); 552 ::close (write_fd);
530 553
531 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) 554
532 { 555// if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) )
533 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) 556// {
534 { 557// while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) )
535 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 558// {
536 success = FALSE; 559// if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
537 break; 560// success = FALSE;
538 } 561// break;
539 } 562// }
540 if( success && (bytesRead > 0) ) 563// }
541 { 564// if( success && (bytesRead > 0) )
542 d.writeBlock( bf, bytesRead ); 565// {
543 } 566// d.writeBlock( bf, bytesRead );
544 } 567// }
545 else 568
546 { 569// }
547 success = FALSE; 570// else
548 } 571// {
572// success = FALSE;
573// }
549 574