author | llornkcor <llornkcor> | 2002-12-16 04:14:46 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-16 04:14:46 (UTC) |
commit | cc6c77e7014a3056debd6963946265671d41517d (patch) (side-by-side diff) | |
tree | 1b8f929dd83a8d64915b91ecb3052c19ff5ac0b5 | |
parent | b1880703eea8601e06cf3d3e8593b649cd1a485e (diff) | |
download | opie-cc6c77e7014a3056debd6963946265671d41517d.zip opie-cc6c77e7014a3056debd6963946265671d41517d.tar.gz opie-cc6c77e7014a3056debd6963946265671d41517d.tar.bz2 |
send as text the real filename is symlink
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 1 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 34 |
3 files changed, 30 insertions, 13 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 92804b2..c653b90 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -294,95 +294,97 @@ void AdvancedFm::populateRemoteView() { qDebug(mydirent->d_name); fileL.sprintf("%s", mydirent->d_name); fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); fileDate.sprintf("%s", ctime( &buf.st_mtime)); if( fileL.find(".") == -1 ){ item= new QListViewItem( Remote_View, fileL, fileS, fileDate); pm = Resource::loadPixmap( "UnknownDocument-14" ); item->setPixmap( 0,pm); } } closedir(dir); } Remote_View->setSorting( 3,FALSE); fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); } void AdvancedFm::localListClicked(QListViewItem *selectedItem) { if(selectedItem) { QString strItem=selectedItem->text(0); QString strSize=selectedItem->text(1); strSize=strSize.stripWhiteSpace(); if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink - QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); + QString strItem2 = dealWithSymName((const QString&)strItem); +// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); if(QDir(strItem2).exists() ) { currentDir.cd(strItem2, TRUE); populateLocalView(); } } else { // not a symlink if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); currentDir.cd(strItem,FALSE); populateLocalView(); Local_View->ensureItemVisible(Local_View->firstChild()); } else { currentDir.cdUp(); populateLocalView(); Local_View->ensureItemVisible(Local_View->firstChild()); } if(QDir(strItem).exists()){ currentDir.cd(strItem, TRUE); Local_View->ensureItemVisible(Local_View->firstChild()); populateLocalView(); } } else { strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); if( QFile::exists(strItem ) ) { // qDebug("clicked item "+strItem); // DocLnk doc( strItem, FALSE ); // doc.execute(); // Local_View->clearSelection(); } } //end not symlink chdir(strItem.latin1()); } } } void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { if(selectedItem) { QString strItem=selectedItem->text(0); QString strSize=selectedItem->text(1); strSize=strSize.stripWhiteSpace(); if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink - QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); + QString strItem2 = dealWithSymName((const QString&)strItem); +// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); currentRemoteDir.cd(strItem2, TRUE); populateRemoteView(); } else { // not a symlink if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); currentRemoteDir.cd(strItem,FALSE); populateRemoteView(); Remote_View->ensureItemVisible(Remote_View->firstChild()); } else { currentRemoteDir.cdUp(); populateRemoteView(); Remote_View->ensureItemVisible(Remote_View->firstChild()); } if(QDir(strItem).exists()){ currentRemoteDir.cd(strItem, TRUE); populateRemoteView(); Remote_View->ensureItemVisible(Remote_View->firstChild()); } } else { strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); if( QFile::exists(strItem ) ) { // qDebug("clicked item "+strItem); // DocLnk doc( strItem, FALSE ); @@ -440,49 +442,49 @@ void AdvancedFm::writeConfig() { } void AdvancedFm::currentPathComboChanged() { if (TabWidget->getCurrentTab() == 0) { // if (TabWidget->currentPageIndex() == 0) { if(QDir( currentPathCombo->lineEdit()->text()).exists()) { currentDir.setPath( currentPathCombo->lineEdit()->text() ); populateLocalView(); } else { QMessageBox::message(tr("Note"),tr("That directory does not exist")); } } if (TabWidget->getCurrentTab() == 0) { // if (TabWidget->currentPageIndex() == 0) { if(QDir( currentPathCombo->lineEdit()->text()).exists()) { currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); populateRemoteView(); } else { QMessageBox::message(tr("Note"),tr("That directory does not exist")); } } } void AdvancedFm::fillCombo(const QString ¤tPath) { - + qDebug("%d",TabWidget->getCurrentTab()); if (TabWidget->getCurrentTab() == 0) { // if (TabWidget->currentPageIndex() == 0) { 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) { if (TabWidget->getCurrentTab() == 0) { // if (TabWidget->currentPageIndex() == 0) { chdir( currentPath.latin1() ); currentDir.cd( currentPath, TRUE); populateLocalView(); diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 9948255..7ced056 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h @@ -103,48 +103,49 @@ protected slots: void localRename(); void runThis(); void runText(); void filePerms(); void doProperties(); void runCommand(); void runCommandStd(); QStringList getPath(); void mkSym(); void switchToLocalTab(); void switchToRemoteTab(); protected: bool zaurusDevice; QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; QStringList remoteDirPathStringList, localDirPathStringList; void init(); void initConnections(); void keyReleaseEvent( QKeyEvent *); QString getFileSystemType(const QString &); QString getDiskSpace(const QString &); void parsetab(const QString &fileName); QString checkDiskSpace(const QString &); + QString dealWithSymName(const QString &); protected slots: void showFileMenu(); void cancelMenuTimer(); void homeButtonPushed(); void docButtonPushed(); void SDButtonPushed(); void CFButtonPushed(); void QPEButtonPushed(); void upDir(); void currentPathComboChanged(); void copy(); void copyAs(); void copySameDir(); void currentPathComboActivated(const QString &); void fillCombo(const QString &); bool copyFile( const QString & , const QString & ); void move(); void fileStatus(); void doAbout(); void doBeam(); void fileBeamFinished( Ir *); private: diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 0a9f921..f77554a 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -82,113 +82,127 @@ void AdvancedFm::showHidden() { currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); // b=FALSE; } else { currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); // b=TRUE; } populateLocalView(); } void AdvancedFm::showRemoteHidden() { if (b) { currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); // b=TRUE; } else { currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); // b=FALSE; } populateRemoteView(); } +QString AdvancedFm::dealWithSymName(const QString &fileName) { + QString strItem = fileName; + return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); +} + void AdvancedFm::runThis() { QString fs; if (TabWidget->getCurrentTab() == 0) { QString curFile = Local_View->currentItem()->text(0); + if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink + curFile = dealWithSymName((const QString&)curFile); + if(curFile != "../") { - fs= getFileSystemType((const QString &) currentDir.canonicalPath()); + fs = getFileSystemType((const QString &) currentDir.canonicalPath()); QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); qDebug( fileInfo.owner()); 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 = currentDir.canonicalPath()+"/"+curFile; DocLnk nf(curFile); QString execStr = nf.exec(); qDebug( execStr); if( execStr.isEmpty() ) { } else { nf.execute(); } } } } else { QString curFile = Remote_View->currentItem()->text(0); if(curFile != "../") { + if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink + curFile = dealWithSymName((const QString&)curFile); fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); qDebug("Filesystemtype is "+fs); QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); 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 = currentRemoteDir.canonicalPath()+"/"+curFile; DocLnk nf(curFile); QString execStr = nf.exec(); qDebug(execStr); if( execStr.isEmpty() ) { } else { nf.execute(); } } } } } void AdvancedFm::runText() { if (TabWidget->getCurrentTab() == 0) { QString curFile = Local_View->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; } } else { QString curFile = Remote_View->currentItem()->text(0); if(curFile != "../") { curFile = currentRemoteDir.canonicalPath()+"/"+curFile; + if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink + curFile = dealWithSymName((const QString&)curFile); DocLnk nf(curFile); QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); e << curFile; } } } void AdvancedFm::localMakDir() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); } populateLocalView(); } void AdvancedFm::remoteMakDir() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); @@ -461,168 +475,168 @@ void AdvancedFm::copy() { 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)); destFile = currentRemoteDir.canonicalPath()+"/"+ item; qDebug("Destination file is "+destFile); curFile = currentDir.canonicalPath()+"/"+ item; qDebug("CurrentFile file is " + curFile); QFile f(destFile); if( f.exists()) { if(doMsg) { switch ( QMessageBox::warning(this,tr("File Exists!"), item+tr("\nexists. Ok to overwrite?"), tr("Yes"),tr("No"),0,0,1) ) { case 1: return; break; }; } f.remove(); } - if(!copyFile(destFile, curFile) ) { + if(!copyFile( curFile, destFile) ) { QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); return; } } populateRemoteView(); TabWidget->setCurrentTab(1); } else { 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)); destFile = currentDir.canonicalPath()+"/"+ item; qDebug("Destination file is "+destFile); curFile = currentRemoteDir.canonicalPath()+"/"+ item;; qDebug("CurrentFile file is " + curFile); QFile f(destFile); if( f.exists()) { switch ( QMessageBox::warning(this,tr("File Exists!"), item+tr("\nexists. Ok to overwrite?"), tr("Yes"),tr("No"),0,0,1) ) { case 1: return; break; }; f.remove(); } - if(!copyFile(destFile, curFile) ) { + if(!copyFile( curFile, destFile) ) { QMessageBox::message("AdvancedFm",tr("Could not copy\n") +curFile +tr("to\n")+destFile); return; } } populateLocalView(); TabWidget->setCurrentTab(0); } } } void AdvancedFm::copyAs() { qApp->processEvents(); QStringList curFileList = getPath(); QString curFile, item; InputDialog *fileDlg; if (TabWidget->getCurrentTab() == 0) { qDebug("tab 1"); for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString destFile; item=(*it); curFile = currentDir.canonicalPath()+"/"+(*it); fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); fileDlg->setInputText((const QString &) destFile ); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = currentRemoteDir.canonicalPath()+"/"+filename; QFile f(destFile); if( f.exists()) { switch (QMessageBox::warning(this,tr("File Exists!"), item+tr("\nexists. Ok to overwrite?"), tr("Yes"),tr("No"),0,0,1) ) { case 0: f.remove(); break; case 1: return; break; }; } - if(!copyFile(destFile, curFile) ) { + if(!copyFile( curFile,destFile) ) { QMessageBox::message("AdvancedFm",tr("Could not copy\n") +curFile +tr("to\n")+destFile); return; } } delete fileDlg; } populateRemoteView(); TabWidget->setCurrentTab(1); } else { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { item=(*it); curFile = currentRemoteDir.canonicalPath()+"/"+(*it); fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); QString destFile; fileDlg->setInputText((const QString &) destFile); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = currentDir.canonicalPath()+"/"+filename; QFile f( destFile); if( f.exists()) { switch ( QMessageBox::warning(this,tr("File Exists!"), item+tr("\nexists. Ok to overwrite?"), tr("Yes"),tr("No"),0,0,1) ) { case 0: f.remove(); break; case 1: return; break; }; } - if(!copyFile(destFile, curFile) ) { + if(!copyFile( curFile,destFile) ) { QMessageBox::message("AdvancedFm",tr("Could not copy\n") +curFile +tr("to\n")+destFile); return; } } delete fileDlg; } populateLocalView(); TabWidget->setCurrentTab(0); } } void AdvancedFm::copySameDir() { qApp->processEvents(); QStringList curFileList = getPath(); QString curFile, item, destFile; InputDialog *fileDlg; if (TabWidget->getCurrentTab() == 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { item=(*it); @@ -630,174 +644,174 @@ void AdvancedFm::copySameDir() { fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); fileDlg->setInputText((const QString &) destFile ); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = currentDir.canonicalPath()+"/"+filename; QFile f(destFile); if( f.exists()) { switch (QMessageBox::warning(this,tr("Delete"), destFile+tr(" already exists\nDo you really want to delete it?"), tr("Yes"),tr("No"),0,0,1) ) { case 0: f.remove(); break; case 1: return; break; }; } - if(!copyFile(destFile, curFile) ) { + if(!copyFile( curFile,destFile) ) { QMessageBox::message("AdvancedFm",tr("Could not copy\n") +curFile +tr("to\n")+destFile); return; } qDebug("copy "+curFile+" as "+destFile); } delete fileDlg; } populateLocalView(); } else { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { item=(*it); curFile = currentRemoteDir.canonicalPath()+"/"+ item; fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); fileDlg->setInputText((const QString &) destFile); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = currentRemoteDir.canonicalPath()+"/"+filename; QFile f(destFile); if( f.exists()) { switch ( QMessageBox::warning(this,tr("Delete"), destFile+tr(" already exists\nDo you really want to delete it?"), tr("Yes"),tr("No"),0,0,1) ) { case 0: f.remove(); break; case 1: return; break; }; } - if(!copyFile(destFile, curFile) ) { + if(!copyFile( curFile,destFile) ) { QMessageBox::message("AdvancedFm",tr("Could not copy\n") +curFile +tr("to\n")+destFile); return; } qDebug("copy "+curFile+" as "+destFile); } delete fileDlg; } populateRemoteView(); } } void AdvancedFm::move() { qApp->processEvents(); QStringList curFileList = getPath(); if( curFileList.count() > 0) { QString curFile, destFile, item; if (TabWidget->getCurrentTab() == 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { item=(*it); QString destFile = currentRemoteDir.canonicalPath(); if(destFile.right(1).find("/",0,TRUE) == -1) destFile+="/"; destFile += item; curFile = currentDir.canonicalPath(); qDebug("Destination file is "+destFile); if(curFile.right(1).find("/",0,TRUE) == -1) curFile +="/"; curFile+= item; qDebug("CurrentFile file is " + curFile); QFile f( curFile); if( f.exists()) { - if(!copyFile( destFile, curFile) ) { + if(!copyFile( curFile,destFile) ) { QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); return; } else QFile::remove(curFile); } } TabWidget->setCurrentTab(1); } else { //view 2 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { item = (*it); QString destFile = currentDir.canonicalPath(); if(destFile.right(1).find("/",0,TRUE) == -1) destFile+="/"; destFile += item; qDebug("Destination file is "+destFile); curFile = currentRemoteDir.canonicalPath(); if(curFile.right(1).find("/",0,TRUE) == -1) curFile +="/"; curFile+= item; qDebug("CurrentFile file is " + curFile); QFile f( curFile); if( f.exists()) { - if(!copyFile( destFile, curFile) ) { + if(!copyFile( curFile, destFile) ) { QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); return; } else QFile::remove( curFile); } TabWidget->setCurrentTab(0); } } populateRemoteView(); populateLocalView(); } } -bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { +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 ); 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; } // Set file permissions if( stat( (const char *) src, &status ) == 0 ){ |