summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp67
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp149
2 files changed, 89 insertions, 127 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
@@ -123,6 +123,4 @@ void AdvancedFm::populateView()
QFileInfo *fi;
- while ( (fi=it.current()) )
- {
- if (fi->isSymLink() )
- {
+ while ( (fi=it.current()) ) {
+ if (fi->isSymLink() ) {
QString symLink=fi->readLink();
@@ -130,12 +128,9 @@ void AdvancedFm::populateView()
fileS.sprintf( "%10i", sym.size() );
- fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
+ fileL = fi->fileName() +" -> " + sym.filePath().data();
fileDate = sym.lastModified().toString();
- }
- else
- {
+ } else {
fileS.sprintf( "%10i", fi->size() );
- fileL.sprintf( "%s",fi->fileName().data() );
+ fileL = fi->fileName();
fileDate= fi->lastModified().toString();
- if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() )
- {
+ if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
fileL+="/";
@@ -144,11 +139,8 @@ void AdvancedFm::populateView()
}
-
QFileInfo fileInfo( path + "/" + fileL);
- if(fileL !="./" && fi->exists())
- {
+ if(fileL !="./" && fi->exists()) {
item= new QListViewItem( thisView, fileL, fileS , fileDate);
- if(isDir || fileL.find("/",0,TRUE) != -1)
- {
+ if(isDir || fileL.find("/",0,TRUE) != -1) {
@@ -159,4 +151,3 @@ void AdvancedFm::populateView()
}
- else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
- {
+ else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
pm = Resource::loadPixmap( "exec");
@@ -165,8 +156,6 @@ void AdvancedFm::populateView()
| fileInfo.permission( QFileInfo::ExeGroup)
- | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
- {
+ | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
pm = Resource::loadPixmap( "exec");
}
- else if( !fi->isReadable() )
- {
+ else if( !fi->isReadable() ) {
pm = Resource::loadPixmap( "locked" );
@@ -180,10 +169,10 @@ void AdvancedFm::populateView()
}
- if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
- {
- // overlay link image
- pm= Resource::loadPixmap( "folder" );
- QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
- QPainter painter( &pm );
- painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
- pm.setMask( pm.createHeuristicMask( FALSE ) );
+ if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
+ // qDebug(" overlay link image");
+ pm= Resource::loadPixmap( "advancedfm/symlink" );
+ // pm= Resource::loadPixmap( "folder" );
+// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
+// QPainter painter( &pm );
+// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
+// pm.setMask( pm.createHeuristicMask( FALSE ) );
}
@@ -196,4 +185,3 @@ void AdvancedFm::populateView()
- if( path.find("dev",0,TRUE) != -1)
- {
+ if( path.find("dev",0,TRUE) != -1) {
struct stat buf;
@@ -204,4 +192,3 @@ void AdvancedFm::populateView()
if((dir = opendir( path.latin1())) != NULL)
- while ((mydirent = readdir(dir)) != NULL)
- {
+ while ((mydirent = readdir(dir)) != NULL) {
lstat( mydirent->d_name, &buf);
@@ -212,4 +199,3 @@ void AdvancedFm::populateView()
fileDate.sprintf("%s", ctime( &buf.st_mtime));
- if( fileL.find(".") == -1 )
- {
+ if( fileL.find(".") == -1 ) {
item= new QListViewItem( thisView, fileL, fileS, fileDate);
@@ -682,12 +668,11 @@ void AdvancedFm::addToDocs()
- if( strListPaths.count() > 0)
- {
+ if( strListPaths.count() > 0) {
QString curFile;
- for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it )
- {
+ for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
curFile = thisDir->canonicalPath()+"/"+(*it);
// qDebug(curFile);
+ QFileInfo fi(curFile);
DocLnk f;
// curFile.replace(QRegExp("\\..*"),"");
- f.setName((*it));
+ f.setName(fi.baseName() );
f.setFile( curFile);
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
@@ -40,2 +40,3 @@
+#include <errno.h>
#include <stdlib.h>
@@ -47,2 +48,3 @@
+
void AdvancedFm::doDirChange()
@@ -172,3 +174,2 @@ void AdvancedFm::doDelete()
{
-
QStringList curFileList = getPath();
@@ -176,6 +177,4 @@ void AdvancedFm::doDelete()
int count = curFileList.count();
- if( count > 0)
- {
- if(count > 1 )
- {
+ if( count > 0) {
+ if(count > 1 ) {
QString msg;
@@ -195,4 +194,4 @@ void AdvancedFm::doDelete()
QString myFile;
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
- {
+
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
myFile = (*it);
@@ -205,12 +204,8 @@ void AdvancedFm::doDelete()
f += myFile;
- if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) //if file is a directory
- {
+ if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
+ //if file is a directory
+
switch ( QMessageBox::warning( this, tr("Delete Directory?"),
tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
- tr("Yes"),
- tr("No"),
- 0,
- 0,
- 1) )
- {
+ tr("Yes"), tr("No"), 0, 0, 1) ) {
case 0:
@@ -231,8 +226,4 @@ void AdvancedFm::doDelete()
switch ( QMessageBox::warning(this,tr("Delete"),
- tr("Really delete\n%1?").arg( f ),
- tr("Yes"),
- tr("No"),
- 0,
- 0,
- 1) ) {
+ tr("Really delete\n%1?").arg( myFile ),
+ tr("Yes"), tr("No"), 0, 0, 1) ) {
case 1:
@@ -242,9 +233,16 @@ void AdvancedFm::doDelete()
}
+
QString cmd="rm "+f;
QFile file(f);
- if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) {
- qDebug("remove link files "+f);
-// AppLnk lnk(f);
-// qDebug(lnk.linkFile());
-// lnk.removeLinkFile();
+ QFileInfo fi(myFile);
+ if( fi.fileName().find("../",0,TRUE)==-1) {
+ qDebug("remove link files "+myFile);
+
+// DocLnk lnk(f);
+ DocLnk *lnk;
+ lnk = new DocLnk(f);
+ qDebug("Deleting doclnk " + lnk->linkFile());
+ if(lnk->isValid())
+ lnk->removeLinkFile();
+ // delete lnk;
file.remove();
@@ -369,4 +367,3 @@ void AdvancedFm::copy()
- if( !copyFile( curFile, destFile) )
- {
+ if( !copyFile( curFile, destFile) ) {
QMessageBox::message("AdvancedFm",
@@ -422,4 +419,3 @@ void AdvancedFm::copyAs()
}
- if( !copyFile( curFile, destFile) )
- {
+ if( !copyFile( curFile, destFile) ) {
QMessageBox::message("AdvancedFm",tr("Could not copy\n")
@@ -475,4 +471,3 @@ void AdvancedFm::copySameDir()
}
- if(!copyFile( curFile,destFile) )
- {
+ if(!copyFile( curFile,destFile) ) {
QMessageBox::message("AdvancedFm",tr("Could not copy\n")
@@ -518,4 +513,3 @@ void AdvancedFm::move()
if( f.exists()) {
- if( !copyFile( curFile, destFile) )
- {
+ if( !copyFile( curFile, destFile) ) {
QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
@@ -535,10 +529,7 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest )
{
-// char bf[ 50000 ];
-// int bytesRead;
bool success = true;
struct stat status;
-
-// QFile s( src );
-// QFile d( dest );
-
+ QFile srcFile(src);
+ QFile destFile(dest);
+ int err=0;
int read_fd=0;
@@ -547,9 +538,26 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest )
off_t offset = 0;
- read_fd = ::open(src.latin1(), O_RDONLY);
+ if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
+ qWarning("open failed");
+ return success = false;
+ }
+ read_fd = srcFile.handle();
if(read_fd != -1) {
fstat (read_fd, &stat_buf);
- write_fd = ::open(dest.latin1(), O_WRONLY | O_CREAT, stat_buf.st_mode);
+ if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
+ qWarning("destfile open failed");
+ return success = false;
+ }
+ write_fd = destFile.handle();
if(write_fd != -1) {
- if(sendfile(write_fd, read_fd, &offset, stat_buf.st_size) == -1) {
+ err =sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
+ if( err == -1) {
+ QString msg;
+ switch(err) {
+ case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
+ case EINVAL: msg = "Descriptor is not valid or locked. ";
+ case ENOMEM: msg = "Insufficient memory to read from in_fd.";
+ case EIO: msg = "Unspecified error while reading from in_fd.";
+ };
success = false;
+ qWarning(msg);
}
@@ -561,30 +569,6 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest )
}
-
- ::close (read_fd);
- ::close (write_fd);
-
-
-// if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) )
-// {
-// while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) )
-// {
-// if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
-// success = FALSE;
-// break;
-// }
-// }
-// if( success && (bytesRead > 0) )
-// {
-// d.writeBlock( bf, bytesRead );
-// }
-
-// }
-// else
-// {
-// success = FALSE;
-// }
-
+ srcFile.close();
+ destFile.close();
// Set file permissions
- if( stat( (const char *) src, &status ) == 0 )
- {
+ if( stat( (const char *) src, &status ) == 0 ) {
chmod( (const char *) dest, status.st_mode );
@@ -715,17 +699,11 @@ void AdvancedFm::doBeam()
Ir ir;
- if(!ir.supported())
- {
- }
- else
- {
+ if(!ir.supported()) {
+ } else {
QStringList curFileList = getPath();
- if( curFileList.count() > 0)
- {
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
- {
-
- QString curFile = CurrentDir()->canonicalPath()+"/"+(*it);
- if( curFile.right(1) == "/")
- {
- curFile = curFile.left( curFile.length() -1);
+ if( curFileList.count() > 0) {
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ QString curFile = (*it);
+ QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
+ if( curFilePath.right(1) == "/") {
+ curFilePath = curFilePath.left( curFilePath.length() -1);
}
@@ -733,3 +711,3 @@ void AdvancedFm::doBeam()
connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
- file->send( curFile, curFile );
+ file->send( curFilePath, curFile );
}
@@ -737,3 +715,2 @@ void AdvancedFm::doBeam()
}
-
}