[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.2/kdelibs/kio/kio
From:       Darío Andrés Rodríguez <andresbajotierra () gmail ! co
Date:       2009-02-03 19:55:30
Message-ID: 1233690930.777670.6842.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 920798 by darioandres:

Backport of SVN commit 920789 to 4.2branch
Doing the things properly as suggested by Friedrich W. H. Kossebau
CCBUG: 183006



 M  +24 -17    ksambashare.cpp  


--- branches/KDE/4.2/kdelibs/kio/kio/ksambashare.cpp #920797:920798
@@ -29,6 +29,19 @@
 #include <kconfiggroup.h>
 #include <kglobal.h>
 
+// Default smb.conf locations
+static const char * DefaultSambaConfigFilePathList[] =
+{
+  "/etc/samba/smb.conf",
+  "/etc/smb.conf",
+  "/usr/local/etc/smb.conf",
+  "/usr/local/samba/lib/smb.conf",
+  "/usr/samba/lib/smb.conf",
+  "/usr/lib/smb.conf",
+  "/usr/local/lib/smb.conf"
+};
+static const int DefaultSambaConfigFilePathListSize = sizeof( \
DefaultSambaConfigFilePathList ) / sizeof(char*); +
 class KSambaShare::KSambaSharePrivate
 {
 public:
@@ -77,28 +90,22 @@
   if ( QFile::exists( smbConf ) )
     return true;
 
-  //Default locations of "smb.conf" file
-  QList<QLatin1String> files;
-  files << QLatin1String( "/etc/samba/smb.conf" );
-  files << QLatin1String( "/etc/smb.conf" );
-  files << QLatin1String( "/usr/local/etc/smb.conf " );
-  files << QLatin1String( "/usr/local/samba/lib/smb.conf" );
-  files << QLatin1String( "/usr/samba/lib/smb.conf" );
-  files << QLatin1String( "/usr/lib/smb.conf" );
-  files << QLatin1String( "/usr/local/lib/smb.conf" );
-  
-  while( !files.isEmpty() )
+  bool success = false;
+  for( int i = 0; i<DefaultSambaConfigFilePathListSize; ++i )
   {
-    QLatin1String filePath = files.takeFirst();
-    if ( QFile::exists( filePath ) )
+    const QString filePath( DefaultSambaConfigFilePathList[i] );
+    if( QFile::exists( filePath ) )
     {
-      smbConf = filePath;
-      return true;
+        smbConf = filePath;
+        success = true;
+        break;
     }
   }
   
-  kDebug(7000) << "KSambaShare: Could not found smb.conf!";
-  return false;
+  if( ! success )
+    kDebug(7000) << "KSambaShare: Could not find smb.conf!";
+
+  return success;
   
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic