-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index 5abe05c..1a1e027 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp | |||
@@ -30,32 +30,33 @@ | |||
30 | #include <assert.h> | 30 | #include <assert.h> |
31 | //US#include <errno.h> | 31 | //US#include <errno.h> |
32 | //US #ifdef HAVE_SYS_STAT_H | 32 | //US #ifdef HAVE_SYS_STAT_H |
33 | //US #include <sys/stat.h> | 33 | //US #include <sys/stat.h> |
34 | //US #endif | 34 | //US #endif |
35 | //US#include <sys/types.h> | 35 | //US#include <sys/types.h> |
36 | //US#include <dirent.h> | 36 | //US#include <dirent.h> |
37 | //US#include <pwd.h> | 37 | //US#include <pwd.h> |
38 | 38 | ||
39 | #include <qregexp.h> | 39 | #include <qregexp.h> |
40 | #include <qasciidict.h> | 40 | #include <qasciidict.h> |
41 | #include <qdict.h> | 41 | #include <qdict.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qfileinfo.h> | 43 | #include <qfileinfo.h> |
44 | #include <qstring.h> | 44 | #include <qstring.h> |
45 | #include <qstringlist.h> | 45 | #include <qstringlist.h> |
46 | #include <qpe/qpeapplication.h> | ||
46 | 47 | ||
47 | #include "kstandarddirs.h" | 48 | #include "kstandarddirs.h" |
48 | #include "kconfig.h" | 49 | #include "kconfig.h" |
49 | #include "kdebug.h" | 50 | #include "kdebug.h" |
50 | //US #include "kinstance.h" | 51 | //US #include "kinstance.h" |
51 | #include "kshell.h" | 52 | #include "kshell.h" |
52 | //US#include <sys/param.h> | 53 | //US#include <sys/param.h> |
53 | //US#include <unistd.h> | 54 | //US#include <unistd.h> |
54 | 55 | ||
55 | //US | 56 | //US |
56 | QString KStandardDirs::mAppDir = QString::null; | 57 | QString KStandardDirs::mAppDir = QString::null; |
57 | 58 | ||
58 | 59 | ||
59 | template class QDict<QStringList>; | 60 | template class QDict<QStringList>; |
60 | 61 | ||
61 | #if 0 | 62 | #if 0 |
@@ -337,36 +338,37 @@ QStringList KStandardDirs::findDirs( const char *type, | |||
337 | 338 | ||
338 | QString KStandardDirs::findResourceDir( const char *type, | 339 | QString KStandardDirs::findResourceDir( const char *type, |
339 | const QString& filename) const | 340 | const QString& filename) const |
340 | { | 341 | { |
341 | #ifndef NDEBUG | 342 | #ifndef NDEBUG |
342 | if (filename.isEmpty()) { | 343 | if (filename.isEmpty()) { |
343 | kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl; | 344 | kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl; |
344 | return QString::null; | 345 | return QString::null; |
345 | } | 346 | } |
346 | #endif | 347 | #endif |
347 | 348 | ||
348 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) | 349 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) |
349 | applyDataRestrictions(filename); | 350 | applyDataRestrictions(filename); |
350 | QStringList candidates = resourceDirs(type); | 351 | QStringList candidates = resourceDirs(type); |
351 | QString fullPath; | 352 | QString fullPath; |
352 | 353 | ||
353 | for (QStringList::ConstIterator it = candidates.begin(); | 354 | for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) |
354 | it != candidates.end(); it++) | 355 | { |
355 | if (exists(*it + filename)) | 356 | if (exists(*it + filename)) |
356 | return *it; | 357 | return *it; |
358 | } | ||
357 | 359 | ||
358 | #ifndef NDEBUG | 360 | #ifndef NDEBUG |
359 | if(false && type != "locale") | 361 | if(false && type != "locale") |
360 | kdDebug() << "KStdDirs::findResDir(): can't find \"" << filename << "\" in type \"" << type << "\"." << endl; | 362 | kdDebug() << "KStdDirs::findResDir(): can't find \"" << filename << "\" in type \"" << type << "\"." << endl; |
361 | #endif | 363 | #endif |
362 | 364 | ||
363 | return QString::null; | 365 | return QString::null; |
364 | } | 366 | } |
365 | 367 | ||
366 | bool KStandardDirs::exists(const QString &fullPath) | 368 | bool KStandardDirs::exists(const QString &fullPath) |
367 | { | 369 | { |
368 | //US struct stat buff; | 370 | //US struct stat buff; |
369 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); | 371 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); |
370 | 372 | ||
371 | //US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) | 373 | //US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) |
372 | if (fullPathInfo.isReadable()) | 374 | if (fullPathInfo.isReadable()) |
@@ -384,32 +386,33 @@ bool KStandardDirs::exists(const QString &fullPath) | |||
384 | } | 386 | } |
385 | return false; | 387 | return false; |
386 | } | 388 | } |
387 | 389 | ||
388 | static void lookupDirectory(const QString& path, const QString &relPart, | 390 | static void lookupDirectory(const QString& path, const QString &relPart, |
389 | const QRegExp ®exp, | 391 | const QRegExp ®exp, |
390 | QStringList& list, | 392 | QStringList& list, |
391 | QStringList& relList, | 393 | QStringList& relList, |
392 | bool recursive, bool uniq) | 394 | bool recursive, bool uniq) |
393 | { | 395 | { |
394 | QString pattern = regexp.pattern(); | 396 | QString pattern = regexp.pattern(); |
395 | if (recursive || pattern.contains('?') || pattern.contains('*')) | 397 | if (recursive || pattern.contains('?') || pattern.contains('*')) |
396 | { | 398 | { |
397 | // We look for a set of files. | 399 | // We look for a set of files. |
398 | //US DIR *dp = opendir( QFile::encodeName(path)); | 400 | //US DIR *dp = opendir( QFile::encodeName(path)); |
399 | QDir dp(QFile::encodeName(path)); | 401 | QDir dp(QFile::encodeName(path)); |
402 | |||
400 | if (!dp.exists()) | 403 | if (!dp.exists()) |
401 | return; | 404 | return; |
402 | static int iii = 0; | 405 | static int iii = 0; |
403 | ++iii; | 406 | ++iii; |
404 | if ( iii == 5 ) | 407 | if ( iii == 5 ) |
405 | abort(); | 408 | abort(); |
406 | assert(path.at(path.length() - 1) == '/'); | 409 | assert(path.at(path.length() - 1) == '/'); |
407 | 410 | ||
408 | //US struct dirent *ep; | 411 | //US struct dirent *ep; |
409 | //US struct stat buff; | 412 | //US struct stat buff; |
410 | 413 | ||
411 | QString _dot("."); | 414 | QString _dot("."); |
412 | QString _dotdot(".."); | 415 | QString _dotdot(".."); |
413 | 416 | ||
414 | //US while( ( ep = readdir( dp ) ) != 0L ) | 417 | //US while( ( ep = readdir( dp ) ) != 0L ) |
415 | QStringList direntries = dp.entryList(); | 418 | QStringList direntries = dp.entryList(); |
@@ -1208,32 +1211,34 @@ void KStandardDirs::addKDEDefaults() | |||
1208 | // begin KDEDIRS | 1211 | // begin KDEDIRS |
1209 | QString kdedirs = readEnvPath("MICROKDEDIRS"); | 1212 | QString kdedirs = readEnvPath("MICROKDEDIRS"); |
1210 | if (!kdedirs.isEmpty()) | 1213 | if (!kdedirs.isEmpty()) |
1211 | { | 1214 | { |
1212 | tokenize(kdedirList, kdedirs, ":"); | 1215 | tokenize(kdedirList, kdedirs, ":"); |
1213 | } | 1216 | } |
1214 | else | 1217 | else |
1215 | { | 1218 | { |
1216 | QString kdedir = readEnvPath("MICROKDEDIR"); | 1219 | QString kdedir = readEnvPath("MICROKDEDIR"); |
1217 | if (!kdedir.isEmpty()) | 1220 | if (!kdedir.isEmpty()) |
1218 | { | 1221 | { |
1219 | kdedir = KShell::tildeExpand(kdedir); | 1222 | kdedir = KShell::tildeExpand(kdedir); |
1220 | kdedirList.append(kdedir); | 1223 | kdedirList.append(kdedir); |
1221 | } | 1224 | } |
1222 | } | 1225 | } |
1223 | //US kdedirList.append(KDEDIR); | 1226 | //US kdedirList.append(KDEDIR); |
1227 | //US for embedded, add qtopia dir as kdedir | ||
1228 | kdedirList.append(QPEApplication::qpeDir()); | ||
1224 | 1229 | ||
1225 | #ifdef __KDE_EXECPREFIX | 1230 | #ifdef __KDE_EXECPREFIX |
1226 | QString execPrefix(__KDE_EXECPREFIX); | 1231 | QString execPrefix(__KDE_EXECPREFIX); |
1227 | if (execPrefix!="NONE") | 1232 | if (execPrefix!="NONE") |
1228 | kdedirList.append(execPrefix); | 1233 | kdedirList.append(execPrefix); |
1229 | #endif | 1234 | #endif |
1230 | 1235 | ||
1231 | QString localKdeDir; | 1236 | QString localKdeDir; |
1232 | 1237 | ||
1233 | //US if (getuid()) | 1238 | //US if (getuid()) |
1234 | if (true) | 1239 | if (true) |
1235 | { | 1240 | { |
1236 | localKdeDir = readEnvPath("MICROKDEHOME"); | 1241 | localKdeDir = readEnvPath("MICROKDEHOME"); |
1237 | if (!localKdeDir.isEmpty()) | 1242 | if (!localKdeDir.isEmpty()) |
1238 | { | 1243 | { |
1239 | if (localKdeDir.at(localKdeDir.length()-1) != '/') | 1244 | if (localKdeDir.at(localKdeDir.length()-1) != '/') |