Index: kdecore/sycoca/ksycoca.cpp
===================================================================
--- kdecore/sycoca/ksycoca.cpp	(revision 794385)
+++ kdecore/sycoca/ksycoca.cpp	(working copy)
@@ -22,7 +22,6 @@
 #include "ktoolinvocation.h"
 #include "kglobal.h"
 #include "kmemfile.h"
-
 #include "kdebug.h"
 #include "kstandarddirs.h"
 
@@ -155,12 +154,7 @@
    sycoca_mmap = 0;
    QDataStream* &m_str = KSycocaPrivate::_self->m_str;
    m_str = 0;
-   QString path;
-   QByteArray ksycoca_env = getenv("KDESYCOCA");
-   if (ksycoca_env.isEmpty())
-      path = KGlobal::dirs()->saveLocation("cache") + KSYCOCA_FILENAME;
-   else
-      path = QFile::decodeName(ksycoca_env);
+   QString path = KSycoca::absoluteFilePath();
 
    kDebug(7011) << "Trying to open ksycoca from " << path;
 #ifdef Q_OS_WIN
@@ -171,7 +165,7 @@
    bool bOpen = m_database->open( QIODevice::ReadOnly );
    if (!bOpen)
    {
-     path = KStandardDirs::locate("services", KSYCOCA_FILENAME);
+     path = KSycoca::absoluteFilePath(true);
      if (!path.isEmpty())
      {
        kDebug(7011) << "Trying to open global ksycoca from " << path;
@@ -497,6 +491,18 @@
    return d->updateSig;
 }
 
+QString KSycoca::absoluteFilePath(bool globalDatabase)
+{
+   if (globalDatabase)
+      return KStandardDirs::locate("services", KSYCOCA_FILENAME);
+
+   QByteArray ksycoca_env = getenv("KDESYCOCA");
+   if (ksycoca_env.isEmpty())
+      return KGlobal::dirs()->saveLocation("cache") + KSYCOCA_FILENAME;
+   else
+      return QFile::decodeName(ksycoca_env);
+}
+    
 QString KSycoca::language()
 {
    if (d->language.isEmpty())
Index: kdecore/sycoca/ksycoca.h
===================================================================
--- kdecore/sycoca/ksycoca.h	(revision 794385)
+++ kdecore/sycoca/ksycoca.h	(working copy)
@@ -102,6 +102,17 @@
     */
    QString kfsstnd_prefixes();
    /**
+    * @internal - returns absolute file path of the database
+    * 
+    * if globalDatabase is true the database is searched under 
+    * the 'services' install path. 
+    * Otherwise, the value from the environment variable KDESYCOCA 
+    * is returned if set. If not set the path is build based on  
+    * KStandardDirs cache save location. 
+    */
+   static QString absoluteFilePath(bool globalDatabase=false);
+
+   /**
     * @internal - returns language stored inside database
     */
    QString language();
Index: kded/kbuildsycoca.cpp
===================================================================
--- kded/kbuildsycoca.cpp	(revision 794385)
+++ kded/kbuildsycoca.cpp	(working copy)
@@ -104,22 +104,7 @@
 
 static QString sycocaPath()
 {
-  QString path;
-
-  if (bGlobalDatabase)
-  {
-     path = KGlobal::dirs()->saveLocation("services")+KSYCOCA_FILENAME;
-  }
-  else
-  {
-     QByteArray ksycoca_env = getenv("KDESYCOCA");
-     if (ksycoca_env.isEmpty())
-        path = KGlobal::dirs()->saveLocation("cache")+KSYCOCA_FILENAME;
-     else
-        path = QFile::decodeName(ksycoca_env);
-  }
-
-  return path;
+  return KSycoca::absoluteFilePath(bGlobalDatabase);
 }
 
 KBuildSycoca::KBuildSycoca()
