summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp71
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp267
2 files changed, 150 insertions, 188 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 60558e7..77dca49 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -122,34 +122,26 @@ void AdvancedFm::populateView()
122 QFileInfoListIterator it(*list); 122 QFileInfoListIterator it(*list);
123 QFileInfo *fi; 123 QFileInfo *fi;
124 while ( (fi=it.current()) ) 124 while ( (fi=it.current()) ) {
125 { 125 if (fi->isSymLink() ) {
126 if (fi->isSymLink() )
127 {
128 QString symLink=fi->readLink(); 126 QString symLink=fi->readLink();
129 QFileInfo sym( symLink); 127 QFileInfo sym( symLink);
130 fileS.sprintf( "%10i", sym.size() ); 128 fileS.sprintf( "%10i", sym.size() );
131 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 129 fileL = fi->fileName() +" -> " + sym.filePath().data();
132 fileDate = sym.lastModified().toString(); 130 fileDate = sym.lastModified().toString();
133 } 131 } else {
134 else
135 {
136 fileS.sprintf( "%10i", fi->size() ); 132 fileS.sprintf( "%10i", fi->size() );
137 fileL.sprintf( "%s",fi->fileName().data() ); 133 fileL = fi->fileName();
138 fileDate= fi->lastModified().toString(); 134 fileDate= fi->lastModified().toString();
139 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) 135 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
140 {
141 fileL+="/"; 136 fileL+="/";
142 isDir=TRUE; 137 isDir=TRUE;
143 } 138 }
144 } 139 }
145
146 QFileInfo fileInfo( path + "/" + fileL); 140 QFileInfo fileInfo( path + "/" + fileL);
147 141
148 if(fileL !="./" && fi->exists()) 142 if(fileL !="./" && fi->exists()) {
149 { 143 item = new QListViewItem( thisView, fileL, fileS , fileDate);
150 item= new QListViewItem( thisView, fileL, fileS , fileDate);
151 144
152 if(isDir || fileL.find("/",0,TRUE) != -1) 145 if(isDir || fileL.find("/",0,TRUE) != -1) {
153 {
154 146
155 if( !QDir( fi->filePath() ).isReadable()) //is directory 147 if( !QDir( fi->filePath() ).isReadable()) //is directory
@@ -158,16 +150,13 @@ void AdvancedFm::populateView()
158 pm= Resource::loadPixmap( "folder" ); 150 pm= Resource::loadPixmap( "folder" );
159 } 151 }
160 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) 152 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
161 { 153 pm = Resource::loadPixmap( "exec");
162 pm = Resource::loadPixmap( "exec");
163 } 154 }
164 else if( (fileInfo.permission( QFileInfo::ExeUser) 155 else if( (fileInfo.permission( QFileInfo::ExeUser)
165 | fileInfo.permission( QFileInfo::ExeGroup) 156 | fileInfo.permission( QFileInfo::ExeGroup)
166 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) 157 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
167 {
168 pm = Resource::loadPixmap( "exec"); 158 pm = Resource::loadPixmap( "exec");
169 } 159 }
170 else if( !fi->isReadable() ) 160 else if( !fi->isReadable() ) {
171 {
172 pm = Resource::loadPixmap( "locked" ); 161 pm = Resource::loadPixmap( "locked" );
173 } 162 }
@@ -179,12 +168,12 @@ void AdvancedFm::populateView()
179 } 168 }
180 } 169 }
181 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) 170 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
182 { 171 // qDebug(" overlay link image");
183 // overlay link image 172 pm= Resource::loadPixmap( "advancedfm/symlink" );
184 pm= Resource::loadPixmap( "folder" ); 173 // pm= Resource::loadPixmap( "folder" );
185 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 174// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
186 QPainter painter( &pm ); 175// QPainter painter( &pm );
187 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 176// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
188 pm.setMask( pm.createHeuristicMask( FALSE ) ); 177// pm.setMask( pm.createHeuristicMask( FALSE ) );
189 } 178 }
190 item->setPixmap( 0,pm); 179 item->setPixmap( 0,pm);
@@ -195,6 +184,5 @@ void AdvancedFm::populateView()
195 } 184 }
196 185
197 if( path.find("dev",0,TRUE) != -1) 186 if( path.find("dev",0,TRUE) != -1) {
198 {
199 struct stat buf; 187 struct stat buf;
200 dev_t devT; 188 dev_t devT;
@@ -203,6 +191,5 @@ void AdvancedFm::populateView()
203 191
204 if((dir = opendir( path.latin1())) != NULL) 192 if((dir = opendir( path.latin1())) != NULL)
205 while ((mydirent = readdir(dir)) != NULL) 193 while ((mydirent = readdir(dir)) != NULL) {
206 {
207 lstat( mydirent->d_name, &buf); 194 lstat( mydirent->d_name, &buf);
208// qDebug(mydirent->d_name); 195// qDebug(mydirent->d_name);
@@ -211,6 +198,5 @@ void AdvancedFm::populateView()
211 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 198 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
212 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 199 fileDate.sprintf("%s", ctime( &buf.st_mtime));
213 if( fileL.find(".") == -1 ) 200 if( fileL.find(".") == -1 ) {
214 {
215 item= new QListViewItem( thisView, fileL, fileS, fileDate); 201 item= new QListViewItem( thisView, fileL, fileS, fileDate);
216 pm = unknownXpm; 202 pm = unknownXpm;
@@ -681,14 +667,13 @@ void AdvancedFm::addToDocs()
681 QDir *thisDir = CurrentDir(); 667 QDir *thisDir = CurrentDir();
682 668
683 if( strListPaths.count() > 0) 669 if( strListPaths.count() > 0) {
684 {
685 QString curFile; 670 QString curFile;
686 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) 671 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
687 {
688 curFile = thisDir->canonicalPath()+"/"+(*it); 672 curFile = thisDir->canonicalPath()+"/"+(*it);
689// qDebug(curFile); 673// qDebug(curFile);
674 QFileInfo fi(curFile);
690 DocLnk f; 675 DocLnk f;
691// curFile.replace(QRegExp("\\..*"),""); 676// curFile.replace(QRegExp("\\..*"),"");
692 f.setName((*it)); 677 f.setName(fi.baseName() );
693 f.setFile( curFile); 678 f.setFile( curFile);
694 f.writeLink(); 679 f.writeLink();
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 9f21245..00d0e07 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -39,4 +39,5 @@
39#include <qlistview.h> 39#include <qlistview.h>
40 40
41#include <errno.h>
41#include <stdlib.h> 42#include <stdlib.h>
42#include <unistd.h> 43#include <unistd.h>
@@ -46,4 +47,5 @@
46#include <fcntl.h> 47#include <fcntl.h>
47 48
49
48void AdvancedFm::doDirChange() 50void AdvancedFm::doDirChange()
49{ 51{
@@ -171,87 +173,83 @@ void AdvancedFm::makeDir()
171void AdvancedFm::doDelete() 173void AdvancedFm::doDelete()
172{ 174{
173 175 QStringList curFileList = getPath();
174 QStringList curFileList = getPath(); 176 bool doMsg=true;
175 bool doMsg=true; 177 int count = curFileList.count();
176 int count = curFileList.count(); 178 if( count > 0) {
177 if( count > 0) 179 if(count > 1 ) {
178 { 180 QString msg;
179 if(count > 1 ) 181 msg=tr("Really delete\n%1 files?").arg(count);
180 { 182 switch ( QMessageBox::warning(this,tr("Delete"),msg
181 QString msg; 183 ,tr("Yes"),tr("No"),0,0,1) )
182 msg=tr("Really delete\n%1 files?").arg(count); 184 {
183 switch ( QMessageBox::warning(this,tr("Delete"),msg 185 case 0:
184 ,tr("Yes"),tr("No"),0,0,1) ) 186 doMsg=false;
185 { 187 break;
186 case 0: 188 case 1:
187 doMsg=false; 189 return;
188 break; 190 break;
189 case 1: 191 };
190 return;
191 break;
192 };
193 } 192 }
194 193
195 QString myFile; 194 QString myFile;
196 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
197 {
198 myFile = (*it);
199 if( myFile.find(" -> ",0,TRUE) != -1)
200 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
201
202 QString f = CurrentDir()->canonicalPath();
203 if(f.right(1).find("/",0,TRUE) == -1)
204 f += "/";
205 f += myFile;
206 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) //if file is a directory
207 {
208 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
209 tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
210 tr("Yes"),
211 tr("No"),
212 0,
213 0,
214 1) )
215 {
216 case 0:
217 {
218 f=f.left(f.length()-1);
219 QString cmd="rm -rf "+f;
220 startProcess( (const QString)cmd.latin1() );
221 populateView();
222 }
223 break;
224 case 1:
225 // exit
226 break;
227 };
228 195
229 } else { 196 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
230 if(doMsg) { 197 myFile = (*it);
231 switch ( QMessageBox::warning(this,tr("Delete"), 198 if( myFile.find(" -> ",0,TRUE) != -1)
232 tr("Really delete\n%1?").arg( f ), 199 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
233 tr("Yes"), 200
234 tr("No"), 201 QString f = CurrentDir()->canonicalPath();
235 0, 202 if(f.right(1).find("/",0,TRUE) == -1)
236 0, 203 f += "/";
237 1) ) { 204 f += myFile;
238 case 1: 205 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
239 return; 206 //if file is a directory
240 break; 207
241 }; 208 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
242 } 209 tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
243 QString cmd="rm "+f; 210 tr("Yes"), tr("No"), 0, 0, 1) ) {
244 QFile file(f); 211 case 0:
245 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) { 212 {
246 qDebug("remove link files "+f); 213 f=f.left(f.length()-1);
247// AppLnk lnk(f); 214 QString cmd="rm -rf "+f;
248// qDebug(lnk.linkFile()); 215 startProcess( (const QString)cmd.latin1() );
249// lnk.removeLinkFile(); 216 populateView();
250 file.remove(); 217 }
251 } 218 break;
219 case 1:
220 // exit
221 break;
222 };
223
224 } else {
225 if(doMsg) {
226 switch ( QMessageBox::warning(this,tr("Delete"),
227 tr("Really delete\n%1?").arg( myFile ),
228 tr("Yes"), tr("No"), 0, 0, 1) ) {
229 case 1:
230 return;
231 break;
232 };
233 }
234
235 QString cmd="rm "+f;
236 QFile file(f);
237 QFileInfo fi(myFile);
238 if( fi.fileName().find("../",0,TRUE)==-1) {
239 qDebug("remove link files "+myFile);
240
241// DocLnk lnk(f);
242 DocLnk *lnk;
243 lnk = new DocLnk(f);
244 qDebug("Deleting doclnk " + lnk->linkFile());
245 if(lnk->isValid())
246 lnk->removeLinkFile();
247 // delete lnk;
248 file.remove();
249 }
250 }
252 } 251 }
253 } 252 }
254 } 253 populateView();
255 populateView();
256} 254}
257 255
@@ -368,6 +366,5 @@ void AdvancedFm::copy()
368 } 366 }
369 367
370 if( !copyFile( curFile, destFile) ) 368 if( !copyFile( curFile, destFile) ) {
371 {
372 QMessageBox::message("AdvancedFm", 369 QMessageBox::message("AdvancedFm",
373 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); 370 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
@@ -421,6 +418,5 @@ void AdvancedFm::copyAs()
421 }; 418 };
422 } 419 }
423 if( !copyFile( curFile, destFile) ) 420 if( !copyFile( curFile, destFile) ) {
424 {
425 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 421 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
426 +curFile +tr("to\n")+destFile); 422 +curFile +tr("to\n")+destFile);
@@ -474,6 +470,5 @@ void AdvancedFm::copySameDir()
474 }; 470 };
475 } 471 }
476 if(!copyFile( curFile,destFile) ) 472 if(!copyFile( curFile,destFile) ) {
477 {
478 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 473 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
479 +curFile +tr("to\n")+destFile); 474 +curFile +tr("to\n")+destFile);
@@ -517,6 +512,5 @@ void AdvancedFm::move()
517 QFile f( curFile); 512 QFile f( curFile);
518 if( f.exists()) { 513 if( f.exists()) {
519 if( !copyFile( curFile, destFile) ) 514 if( !copyFile( curFile, destFile) ) {
520 {
521 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 515 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
522 return; 516 return;
@@ -534,23 +528,37 @@ void AdvancedFm::move()
534bool AdvancedFm::copyFile( const QString & src, const QString & dest ) 528bool AdvancedFm::copyFile( const QString & src, const QString & dest )
535{ 529{
536// char bf[ 50000 ];
537// int bytesRead;
538 bool success = true; 530 bool success = true;
539 struct stat status; 531 struct stat status;
540 532 QFile srcFile(src);
541// QFile s( src ); 533 QFile destFile(dest);
542// QFile d( dest ); 534 int err=0;
543
544 int read_fd=0; 535 int read_fd=0;
545 int write_fd=0; 536 int write_fd=0;
546 struct stat stat_buf; 537 struct stat stat_buf;
547 off_t offset = 0; 538 off_t offset = 0;
548 read_fd = ::open(src.latin1(), O_RDONLY); 539 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
540 qWarning("open failed");
541 return success = false;
542 }
543 read_fd = srcFile.handle();
549 if(read_fd != -1) { 544 if(read_fd != -1) {
550 fstat (read_fd, &stat_buf); 545 fstat (read_fd, &stat_buf);
551 write_fd = ::open(dest.latin1(), O_WRONLY | O_CREAT, stat_buf.st_mode); 546 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
547 qWarning("destfile open failed");
548 return success = false;
549 }
550 write_fd = destFile.handle();
552 if(write_fd != -1) { 551 if(write_fd != -1) {
553 if(sendfile(write_fd, read_fd, &offset, stat_buf.st_size) == -1) { 552 err =sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
554 success = false; 553 if( err == -1) {
554 QString msg;
555 switch(err) {
556 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
557 case EINVAL: msg = "Descriptor is not valid or locked. ";
558 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
559 case EIO: msg = "Unspecified error while reading from in_fd.";
560 };
561 success = false;
562 qWarning(msg);
555 } 563 }
556 } else { 564 } else {
@@ -560,32 +568,8 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest )
560 success = false; 568 success = false;
561 } 569 }
562 570 srcFile.close();
563 ::close (read_fd); 571 destFile.close();
564 ::close (write_fd);
565
566
567// if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) )
568// {
569// while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) )
570// {
571// if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
572// success = FALSE;
573// break;
574// }
575// }
576// if( success && (bytesRead > 0) )
577// {
578// d.writeBlock( bf, bytesRead );
579// }
580
581// }
582// else
583// {
584// success = FALSE;
585// }
586
587 // Set file permissions 572 // Set file permissions
588 if( stat( (const char *) src, &status ) == 0 ) 573 if( stat( (const char *) src, &status ) == 0 ) {
589 {
590 chmod( (const char *) dest, status.st_mode ); 574 chmod( (const char *) dest, status.st_mode );
591 } 575 }
@@ -713,28 +697,21 @@ void AdvancedFm::mkSym()
713void AdvancedFm::doBeam() 697void AdvancedFm::doBeam()
714{ 698{
715 Ir ir; 699 Ir ir;
716 if(!ir.supported()) 700 if(!ir.supported()) {
717 { 701 } else {
718 }
719 else
720 {
721 QStringList curFileList = getPath(); 702 QStringList curFileList = getPath();
722 if( curFileList.count() > 0) 703 if( curFileList.count() > 0) {
723 { 704 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
724 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 705 QString curFile = (*it);
725 { 706 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
726 707 if( curFilePath.right(1) == "/") {
727 QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); 708 curFilePath = curFilePath.left( curFilePath.length() -1);
728 if( curFile.right(1) == "/")
729 {
730 curFile = curFile.left( curFile.length() -1);
731 }
732 Ir *file = new Ir(this, "IR");
733 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
734 file->send( curFile, curFile );
735 } 709 }
736 } 710 Ir *file = new Ir(this, "IR");
737 } 711 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
738 712 file->send( curFilePath, curFile );
713 }
714 }
715 }
739} 716}
740 717