Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-updates-src > by-pkgid > ab12019d4965549f356b8978ab2e74f1 > files > 10

krusader-2.0.0-5.2.mga1.src.rpm

From 93d9f230b6e7483659a7f7e6a55aa802cc55c2ba Mon Sep 17 00:00:00 2001
From: Anssi Hannula <anssi@mageia.org>
Date: Tue, 6 Dec 2011 06:02:59 +0200
Subject: [PATCH] krservices: use KStandardDirs::findExe to find executables

Use KStandardDirs::findExe() instead of a custom function to find
executables in PATH. This also fixes finding "kdesu" which is in libexec
on a standard KDE installation, as noted in krusader bug #271265 in KDE
bugzilla.
diff -Nurpa -x '*~' -x '*.orig' -x '*.rej' -x '*.swp' krusader-2.0.0//krusader/krservices.cpp newdir/krusader/krservices.cpp
--- krusader-2.0.0//krusader/krservices.cpp	2009-04-11 22:40:25.000000000 +0300
+++ krusader-2.0.0/krusader/krservices.cpp	2011-12-06 06:27:22.362240472 +0200
@@ -22,6 +22,7 @@
 #include <qtextstream.h>
 // KDE includes
 #include <kdebug.h>
+#include <kstandarddirs.h>
 // Krusader includes
 #include "krservices.h"
 #include "krusader.h"
@@ -35,7 +36,7 @@ bool KrServices::cmdExist(QString cmdNam
   if( QFile( group.readEntry( cmdName, QString() )).exists() )
     return true;
 
-  return !detectFullPathName( cmdName ).isEmpty();  
+  return !KStandardDirs::findExe( cmdName ).isEmpty();  
 }
 
 static const QStringList bin_suffixes = QStringList()
@@ -46,26 +47,6 @@ static const QStringList bin_suffixes =
 #endif
 ;
 
-QString KrServices::detectFullPathName(QString name)
-{
-  QStringList path = QString::fromLocal8Bit(getenv("PATH")).split(":");
-
-  for ( QStringList::Iterator it = path.begin(); it != path.end(); ++it )
-  foreach( QString suffix, bin_suffixes )
-  {
-    if( QDir(*it).exists( name + suffix ) )
-    {
-      QString dir = *it;
-      if( !dir.endsWith( "/" ) )
-        dir+="/";
-        
-      return dir+name;
-    }
-  }
-
-  return "";
-}
-
 QString KrServices::fullPathName( QString name, QString confName )
 {
   QString supposedName;
@@ -77,7 +58,7 @@ QString KrServices::fullPathName( QStrin
   if( QFile( supposedName = config.readEntry( confName, QString() )).exists() )
     return supposedName;
 
-  if( ( supposedName = detectFullPathName( name ) ).isEmpty() )
+  if( ( supposedName = KStandardDirs::findExe( name ) ).isEmpty() )
     return "";
 
   config.writeEntry( confName, supposedName );
diff -Nurpa -x '*~' -x '*.orig' -x '*.rej' -x '*.swp' krusader-2.0.0//krusader/krservices.h newdir/krusader/krservices.h
--- krusader-2.0.0//krusader/krservices.h	2009-04-11 22:40:25.000000000 +0300
+++ krusader-2.0.0/krusader/krservices.h	2011-12-06 06:27:42.123282482 +0200
@@ -37,7 +37,6 @@ public:
 
 	static bool         cmdExist(QString cmdName);
 	static QString      chooseFullPathName( QStringList names, QString confName );
-	static QString      detectFullPathName( QString name );
 	static QString      fullPathName( QString name, QString confName = QString() );
 	static QStringList  separateArgs( QString args );
 	static QString      registerdProtocol(QString mimetype);