-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 8d07f69..9721f84 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -204,193 +204,193 @@ void AdvancedFm::populateView() { thisView->setSorting( 3,FALSE); fillCombo( (const QString &) path ); } void AdvancedFm::rePopulate() { // qDebug("repopulate views"); populateView(); setOtherTabCurrent(); populateView(); // int tmpTab = whichTab; // // odebug << "" << tmpTab << "" << oendl; // for(int i =1; i < 3; i++) { // TabWidget->setCurrentWidget(i - 1); // populateView(); // } // TabWidget->setCurrentWidget( tmpTab - 1); } void AdvancedFm::ListClicked(QListViewItem *selectedItem) { // if ( TabWidget->currentWidget() == tab) // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local"); // else // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote"); if(selectedItem) { QString strItem=selectedItem->text(0); // owarn << strItem << oendl; QString strSize=selectedItem->text(1); strSize=strSize.stripWhiteSpace(); bool isDirectory = false; QString strItem2; if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink strItem2 = dealWithSymName((const QString&)strItem); if(QDir(strItem2).exists() ) strItem = strItem2; } if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { if(QDir(strItem).exists()) isDirectory = true; } if( isDirectory ) { CurrentDir()->cd( strItem, TRUE); populateView(); CurrentView()->ensureItemVisible( CurrentView()->firstChild()); } chdir( strItem.latin1()); } } void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { Q_UNUSED(item); switch (mouse) { case 1: { if(renameBox != 0 ) { cancelRename(); } } break; // case 2: // menuTimer.start( 50, TRUE ); // break; }; } void AdvancedFm::refreshCurrentTab() { populateView(); // if ( TabWidget->currentWidget() == tab) { } void AdvancedFm::switchToLocalTab() { TabWidget->setCurrentWidget(0); // Local_View->setFocus(); whichTab = 1; } void AdvancedFm::switchToRemoteTab() { TabWidget->setCurrentWidget(1); // Remote_View->setFocus(); whichTab = 2; } void AdvancedFm::currentPathComboChanged() { if(QDir( currentPathCombo->lineEdit()->text()).exists()) { CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); populateView(); } else { - QMessageBox::message(tr("Note"),tr("That directory does not exist")); + QMessageBox::message(tr("Note"),tr("<p>That directory does not exist</p>")); } } void AdvancedFm::fillCombo(const QString ¤tPath) { if ( TabWidget->currentWidget() == tab) { // if ( whichTab == 1) { currentPathCombo->lineEdit()->setText( currentPath); if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { currentPathCombo->clear(); localDirPathStringList.prepend( currentPath ); currentPathCombo->insertStringList( localDirPathStringList,-1); } } else { currentPathCombo->lineEdit()->setText( currentPath); if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { currentPathCombo->clear(); remoteDirPathStringList.prepend( currentPath ); currentPathCombo->insertStringList( remoteDirPathStringList,-1); } } } void AdvancedFm::currentPathComboActivated(const QString & currentPath) { chdir( currentPath.latin1() ); CurrentDir()->cd( currentPath, TRUE); populateView(); update(); } QStringList AdvancedFm::getPath() { QStringList strList; QListView *thisView=CurrentView(); QList<QListViewItem> * getSelectedItems( QListView * thisView ); QListViewItemIterator it( thisView ); for ( ; it.current(); ++it ) { if ( it.current()->isSelected() ) { strList << it.current()->text(0); // odebug << it.current()->text(0) << oendl; } } return strList; } void AdvancedFm::changeTo(const QString dir) { chdir( dir.latin1()); CurrentDir()->cd(dir, TRUE); populateView(); update(); } void AdvancedFm::homeButtonPushed() { changeTo(QDir::homeDirPath()); } void AdvancedFm::docButtonPushed() { changeTo(QPEApplication::documentDir()); } void AdvancedFm::SDButtonPushed() { changeTo("/mnt/card");// this can change so fix } void AdvancedFm::CFButtonPushed() { if(zaurusDevice) changeTo("/mnt/cf"); //zaurus else changeTo("/mnt/hda"); //ipaq } void AdvancedFm::QPEButtonPushed() { changeTo(QPEApplication::qpeDir()); } void AdvancedFm::doAbout() { QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); } void AdvancedFm::keyPressEvent( QKeyEvent *e) { Q_UNUSED(e); } void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { // if( CurrentView()->hasFocus() ) // e->ignore(); if( currentPathCombo->lineEdit()->hasFocus()) { // qDebug("shout!"); } else if( e->key() == Key_Left ) upDir(); else if( e->key() == Key_Return || e->key() == Key_Enter) navigateToSelected(); else if( e->key() == Key_Tab) setOtherTabCurrent(); else if( e->key() == Key_Delete ) @@ -576,193 +576,193 @@ QString AdvancedFm::checkDiskSpace(const QString &path) { return ""; } void AdvancedFm::addToDocs() { QStringList strListPaths = getPath(); QDir *thisDir = CurrentDir(); if( strListPaths.count() > 0) { QString curFile; for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { curFile = thisDir->canonicalPath()+"/"+(*it); // odebug << curFile << oendl; QFileInfo fi(curFile); DocLnk f; // curFile.replace(QRegExp("\\..*"),""); f.setName(fi.baseName() ); f.setFile( curFile); f.writeLink(); } } } void AdvancedFm::customDirsToMenu() { Config cfg("AdvancedFm"); cfg.setGroup("Menu"); QStringList list = cfg.readListEntry( "CustomDir", ','); menuButton->insertItems(list ); // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) // { // customDirMenu->insertItem(*it ); // } } void AdvancedFm::dirMenuSelected(int item) { switch(item) { case -21: case 0: addCustomDir(); break; case -22: case 1: removeCustomDir(); break; default: { // gotoCustomDir( menuButton->text(item)); // gotoCustomDir( customDirMenu->text(item)); } break; }; } void AdvancedFm::addCustomDir() { Config cfg("AdvancedFm"); cfg.setGroup("Menu"); QString dir; QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); dir = CurrentDir()->canonicalPath(); bool addIt=true; for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { if( dir == (*it)) { addIt=false; } } if(addIt) { menuButton->insertItem(dir); // customDirMenu->insertItem(dir); list << dir; } cfg.writeEntry("CustomDir", list, ','); cfg.write(); } void AdvancedFm::removeCustomDir() { // odebug << "remove custom dir" << oendl; Config cfg("AdvancedFm"); cfg.setGroup("Menu"); QString dir; QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); QStringList list2; dir = CurrentDir()->canonicalPath(); int ramble=2; // int ramble=-24; //first remove list if(list.grep(dir,true).isEmpty()) { QMessageBox::message(tr( "AdvancedFm" ), - tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); + tr("<p>Cannot remove current directory from bookmarks. It is not bookmarked!</p>")); } else { for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { if((*it) != dir) { //current item is not our current dir, so add it to temp list list2 <<(*it); } else { // customDirMenu->removeItem( ramble); menuButton->remove( ramble); } ramble++; // ramble--; } cfg.writeEntry("CustomDir", list2, ','); cfg.write(); } // customDirsToMenu(); } void AdvancedFm::gotoCustomDir(const QString &dir) { // odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; // QString curDir = dir; // QDir *thisDir = CurrentDir(); // if( curDir.isEmpty()) { // } if( dir == s_addBookmark) { addCustomDir(); } if( dir == s_removeBookmark) { removeCustomDir( ); } else { changeTo( dir); // if(QDir( curDir).exists() ) // { // thisDir->setPath( curDir ); // chdir( curDir.latin1() ); // thisDir->cd( curDir, TRUE); // populateView(); // } } } QDir *AdvancedFm::CurrentDir() { if ( whichTab == 1) { // qDebug("CurrentTab is Local"); return ¤tDir; } else { // qDebug("CurrentTab is Remote"); return ¤tRemoteDir; } } QDir *AdvancedFm::OtherDir() { // if ( TabWidget->currentWidget() == tab) { if ( whichTab == 1) { return ¤tRemoteDir; } else { return ¤tDir; } } QListView * AdvancedFm::CurrentView() { // if ( TabWidget->currentWidget() == tab) { if ( whichTab == 1) { // qDebug("CurrentView: local"); return Local_View; } else { // owarn << "CurrentView Tab 2" << oendl; // qDebug("CurrentView: remote"); return Remote_View; } } QListView * AdvancedFm::OtherView() { if ( whichTab == 1) return Remote_View; else return Local_View; } void AdvancedFm::setOtherTabCurrent() { // qDebug("setOtherTabCurrent() %d",whichTab); if ( whichTab == 1) { TabWidget->setCurrentWidget(1); } else { TabWidget->setCurrentWidget(0); } // OtherView()->setFocus(); OtherView()->setSelected( CurrentView()->firstChild(), true); } void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { // odebug << "qcop message "+msg << oendl; QDataStream stream ( data, IO_ReadOnly ); diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index f14f588..706658e 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -54,332 +54,332 @@ void AdvancedFm::showMenuHidden() { CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); } else { CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); } b = !b; populateView(); } void AdvancedFm::showHidden() { if (b) { CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); } else { CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); } populateView(); } QString AdvancedFm::dealWithSymName(const QString &fileName) { QString strItem = fileName; return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); } void AdvancedFm::runThis() { if( !CurrentView()->currentItem()) return; QString fs; QDir *thisDir = CurrentDir(); QString curFile = CurrentView()->currentItem()->text(0); QString path = thisDir->canonicalPath(); if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink curFile = dealWithSymName((const QString&)curFile); if(curFile != "../") { fs = getFileSystemType((const QString &) path); QFileInfo fileInfo( path + "/" + curFile); // odebug << fileInfo.owner() << oendl; if( (fileInfo.permission( QFileInfo::ExeUser) | fileInfo.permission( QFileInfo::ExeGroup) | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { QCopEnvelope e("QPE/System", "execute(QString)" ); e << curFile; } else { curFile = path + "/" + curFile; DocLnk nf(curFile); QString execStr = nf.exec(); // odebug << execStr << oendl; if( execStr.isEmpty() ) { } else { nf.execute(); } } } } void AdvancedFm::runText() { if( !CurrentView()->currentItem()) return; QString curFile = CurrentView()->currentItem()->text(0); if(curFile != "../") { if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink curFile = dealWithSymName((const QString&)curFile); curFile = CurrentDir()->canonicalPath()+"/"+curFile; QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); e << curFile; } } void AdvancedFm::makeDir() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { QDir *thisDir = CurrentDir(); QString filename = fileDlg->LineEdit1->text(); thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); } populateView(); } void AdvancedFm::doDelete() { QStringList curFileList = getPath(); bool doMsg=true; int count = curFileList.count(); if( count > 0) { if(count > 1 ) { QString msg; - msg=tr("Really delete\n%1 files?").arg(count); + msg=tr("<p>Really delete %1 files?</p>").arg(count); switch ( QMessageBox::warning(this,tr("Delete"),msg ,tr("Yes"),tr("No"),0,0,1) ) { case 0: doMsg=false; break; case 1: return; break; }; } QString myFile; for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { myFile = (*it); if( myFile.find(" -> ",0,TRUE) != -1) myFile = myFile.left( myFile.find(" -> ",0,TRUE)); QString f = CurrentDir()->canonicalPath(); if(f.right(1).find("/",0,TRUE) == -1) f += "/"; f += myFile; 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("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , tr("Yes"), tr("No"), 0, 0, 1) ) { case 0: { f=f.left(f.length()-1); QString cmd="rm -rf "+f; startProcess( (const QString)cmd.latin1() ); populateView(); } break; case 1: // exit break; }; } else { if(doMsg) { switch ( QMessageBox::warning(this,tr("Delete"), - tr("Really delete\n%1?").arg( myFile ), + tr("<p>Really delete %1?</p>").arg( myFile ), tr("Yes"), tr("No"), 0, 0, 1) ) { case 1: return; break; }; } QString cmd="rm "+f; QFile file(f); QFileInfo fi(myFile); if( fi.fileName().find("../",0,TRUE)==-1) { // odebug << "remove link files "+myFile << oendl; // DocLnk lnk(f); DocLnk *lnk; lnk = new DocLnk(f); // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; if(lnk->isValid()) lnk->removeLinkFile(); // delete lnk; file.remove(); } } } } populateView(); } void AdvancedFm::filePerms() { QStringList curFileList = getPath(); QString filePath; filePath = CurrentDir()->canonicalPath()+"/"; for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { filePermissions *filePerm; filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); QPEApplication::execDialog( filePerm ); if( filePerm ) delete filePerm; } populateView(); } void AdvancedFm::doProperties() { #if defined(QT_QWS_OPIE) QStringList curFileList = getPath(); QString filePath; filePath = CurrentDir()->canonicalPath()+"/"; // odebug << "" << curFileList.count() << "" << oendl; for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { // odebug << (filePath+*it) << oendl; DocLnk lnk( (filePath+*it)); LnkProperties prop( &lnk ); QPEApplication::execDialog( &prop ); } #endif } void AdvancedFm::upDir() { QDir *thisDir = CurrentDir(); QString current = thisDir->canonicalPath(); QDir dir(current); dir.cdUp(); current = dir.canonicalPath(); chdir( current.latin1() ); thisDir->cd( current, TRUE); populateView(); update(); } void AdvancedFm::copyTimer() { QTimer::singleShot(125,this,SLOT(copy())); } void AdvancedFm::copy() { QStringList curFileList = getPath(); QDir *thisDir = CurrentDir(); QDir *thatDir = OtherDir(); bool doMsg=true; int count=curFileList.count(); if( count > 0) { if(count > 1 ){ QString msg; - msg=tr("Really copy\n%1 files?").arg(count); + msg=tr("<p>Really copy %1 files?</p>").arg(count); switch ( QMessageBox::warning(this,tr("Copy"),msg ,tr("Yes"),tr("No"),0,0,1) ) { case 0: doMsg=false; break; case 1: return; break; }; } QString curFile, item, destFile; for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { item=(*it); if(item.find("->",0,TRUE)) //symlink item = item.left(item.find("->",0,TRUE)); curFile = thisDir->canonicalPath()+"/"+ item; destFile = thatDir->canonicalPath()+"/"+ item; // odebug << "Destination file is "+destFile << oendl; // odebug << "CurrentFile file is " + curFile << oendl; QFile f(destFile); if( f.exists()) { if(doMsg) { switch ( QMessageBox::warning(this,tr("File Exists!"), tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), tr("Yes"),tr("No"),0,0,1)) { case 1: return; break; }; } f.remove(); } if( !copyFile( curFile, destFile) ) { QMessageBox::message("AdvancedFm", tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); return; } } rePopulate(); } } void AdvancedFm::copyAsTimer() { QTimer::singleShot(125,this,SLOT(copyAs())); } void AdvancedFm::copyAs() { QStringList curFileList = getPath(); QString curFile, item; InputDialog *fileDlg; QDir *thisDir = CurrentDir(); QDir *thatDir = OtherDir(); for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString destFile; item=(*it); curFile = thisDir->canonicalPath()+"/"+(*it); fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); fileDlg->setInputText((const QString &) destFile ); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = thatDir->canonicalPath()+"/"+filename; QFile f( destFile); if( f.exists()) { switch (QMessageBox::warning(this,tr("File Exists!"), tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), tr("Yes"),tr("No"),0,0,1) ) { case 0: f.remove(); break; case 1: return; break; }; } if( !copyFile( curFile, destFile) ) { QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); return; } } delete fileDlg; } rePopulate(); @@ -408,205 +408,205 @@ void AdvancedFm::copySameDir() { fileDlg->setInputText((const QString &) destFile ); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = thisDir->canonicalPath()+"/"+filename; QFile f(destFile); if( f.exists()) { switch (QMessageBox::warning(this,tr("Delete"), tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), tr("Yes"),tr("No"),0,0,1) ) { case 0: f.remove(); break; case 1: return; break; }; } if(!copyFile( curFile,destFile) ) { QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); return; } // odebug << "copy "+curFile+" as "+destFile << oendl; } delete fileDlg; } rePopulate(); } void AdvancedFm::moveTimer() { QTimer::singleShot(125,this,SLOT(move())); } void AdvancedFm::move() { QStringList curFileList = getPath(); if( curFileList.count() > 0) { QString curFile, destFile, item; QDir *thisDir = CurrentDir(); QDir *thatDir = OtherDir(); for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { item=(*it); QString destFile = thatDir->canonicalPath(); if(destFile.right(1).find("/",0,TRUE) == -1) destFile+="/"; destFile += item; // odebug << "Destination file is "+destFile << oendl; curFile = thisDir->canonicalPath(); if(curFile.right(1).find("/",0,TRUE) == -1) curFile +="/"; curFile+= item; // odebug << "CurrentFile file is " + curFile << oendl; if(QFileInfo(curFile).isDir()) { moveDirectory( curFile, destFile ); rePopulate(); return; } QFile f( destFile); if( f.exists()) { switch ( QMessageBox::warning(this,tr("File Exists!"), tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), tr("Yes"),tr("No"),0,0,1)) { case 1: return; break; }; if( !copyFile( curFile, destFile) ) { QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); return; } else QFile::remove(curFile); } } } rePopulate(); // setOtherTabCurrent(); } bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { int err = 0; if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; err = system((const char*)cmd); } else err = -1; if(err!=0) { - QMessageBox::message(tr("Note"),tr("Could not move\n") + src); + QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); return false; } return true; } bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { QString cmd = "/bin/cp -fpR " + src + " " + dest; owarn << cmd << oendl; int err = system( (const char *) cmd ); if ( err != 0 ) { - QMessageBox::message("AdvancedFm", tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); + QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); return false; } return true; } bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { if(QFileInfo(src).isDir()) { if( copyDirectory( src, dest )) { // setOtherTabCurrent(); rePopulate(); return true; } else return false; } bool success = true; struct stat status; QFile srcFile(src); QFile destFile(dest); int err=0; int read_fd=0; int write_fd=0; struct stat stat_buf; off_t offset = 0; if(!srcFile.open( IO_ReadOnly|IO_Raw)) { // owarn << "open failed" << oendl; return success = false; } read_fd = srcFile.handle(); if(read_fd != -1) { fstat (read_fd, &stat_buf); if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { // owarn << "destfile open failed" << oendl; return success = false; } write_fd = destFile.handle(); if(write_fd != -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; // owarn << msg << oendl; } } else { success = false; } } else { success = false; } srcFile.close(); destFile.close(); // Set file permissions if( stat( QFile::encodeName(src), &status ) == 0 ) { chmod( QFile::encodeName(dest), status.st_mode ); } return success; } void AdvancedFm::runCommand() { if( !CurrentView()->currentItem()) return; QDir *thisDir = CurrentDir(); QString curFile; curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); fileDlg->setInputText(curFile); fileDlg->exec(); //QString command; if( fileDlg->result() == 1 ) { // odebug << fileDlg->LineEdit1->text() << oendl; QStringList command; command << "/bin/sh"; command << "-c"; command << fileDlg->LineEdit1->text(); Output *outDlg; outDlg = new Output( command, this, tr("AdvancedFm Output"), true); QPEApplication::execDialog( outDlg ); qApp->processEvents(); } } |