Diffstat (limited to 'microkde/kdecore/kstandarddirs.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index d5bfefd..f10934b 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp | |||
@@ -1,184 +1,186 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> | 2 | Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> |
3 | Copyright (C) 1999 Stephan Kulow <coolo@kde.org> | 3 | Copyright (C) 1999 Stephan Kulow <coolo@kde.org> |
4 | Copyright (C) 1999 Waldo Bastian <bastian@kde.org> | 4 | Copyright (C) 1999 Waldo Bastian <bastian@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License version 2 as published by the Free Software Foundation. | 8 | License version 2 as published by the Free Software Foundation. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> | 22 | * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> |
23 | * Version:$Id$ | 23 | * Version:$Id$ |
24 | * Generated:Thu Mar 5 16:05:28 EST 1998 | 24 | * Generated:Thu Mar 5 16:05:28 EST 1998 |
25 | */ | 25 | */ |
26 | 26 | ||
27 | //US #include "config.h" | 27 | //US #include "config.h" |
28 | 28 | ||
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
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 <q3asciidict.h> |
41 | #include <qdict.h> | 41 | #include <q3dict.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 <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qapplication.h> | 46 | #include <qapplication.h> |
47 | 47 | ||
48 | #include <qstringlist.h> | 48 | #include <qstringlist.h> |
49 | //Added by qt3to4: | ||
50 | #include <Q3CString> | ||
49 | 51 | ||
50 | #include "kstandarddirs.h" | 52 | #include "kstandarddirs.h" |
51 | #include "kconfig.h" | 53 | #include "kconfig.h" |
52 | #include "kdebug.h" | 54 | #include "kdebug.h" |
53 | //US #include "kinstance.h" | 55 | //US #include "kinstance.h" |
54 | #include "kshell.h" | 56 | #include "kshell.h" |
55 | //US#include <sys/param.h> | 57 | //US#include <sys/param.h> |
56 | //US#include <unistd.h> | 58 | //US#include <unistd.h> |
57 | 59 | ||
58 | //US | 60 | //US |
59 | QString KStandardDirs::mAppDir = QString::null; | 61 | QString KStandardDirs::mAppDir = QString::null; |
60 | 62 | ||
61 | 63 | ||
62 | template class QDict<QStringList>; | 64 | template class Q3Dict<QStringList>; |
63 | 65 | ||
64 | #if 0 | 66 | #if 0 |
65 | #include <qtextedit.h> | 67 | #include <q3textedit.h> |
66 | void ddd( QString op ) | 68 | void ddd( QString op ) |
67 | { | 69 | { |
68 | static QTextEdit * dot = 0; | 70 | static Q3TextEdit * dot = 0; |
69 | if ( ! dot ) | 71 | if ( ! dot ) |
70 | dot = new QTextEdit(); | 72 | dot = new Q3TextEdit(); |
71 | 73 | ||
72 | dot->show(); | 74 | dot->show(); |
73 | 75 | ||
74 | dot->append( op ); | 76 | dot->append( op ); |
75 | 77 | ||
76 | } | 78 | } |
77 | #endif | 79 | #endif |
78 | class KStandardDirs::KStandardDirsPrivate | 80 | class KStandardDirs::KStandardDirsPrivate |
79 | { | 81 | { |
80 | public: | 82 | public: |
81 | KStandardDirsPrivate() | 83 | KStandardDirsPrivate() |
82 | : restrictionsActive(false), | 84 | : restrictionsActive(false), |
83 | dataRestrictionActive(false) | 85 | dataRestrictionActive(false) |
84 | { } | 86 | { } |
85 | 87 | ||
86 | bool restrictionsActive; | 88 | bool restrictionsActive; |
87 | bool dataRestrictionActive; | 89 | bool dataRestrictionActive; |
88 | QAsciiDict<bool> restrictions; | 90 | Q3AsciiDict<bool> restrictions; |
89 | QStringList xdgdata_prefixes; | 91 | QStringList xdgdata_prefixes; |
90 | QStringList xdgconf_prefixes; | 92 | QStringList xdgconf_prefixes; |
91 | }; | 93 | }; |
92 | 94 | ||
93 | static const char* const types[] = {"html", "icon", "apps", "sound", | 95 | static const char* const types[] = {"html", "icon", "apps", "sound", |
94 | "data", "locale", "services", "mime", | 96 | "data", "locale", "services", "mime", |
95 | "servicetypes", "config", "exe", "tmp", | 97 | "servicetypes", "config", "exe", "tmp", |
96 | "wallpaper", "lib", "pixmap", "templates", | 98 | "wallpaper", "lib", "pixmap", "templates", |
97 | "module", "qtplugins", | 99 | "module", "qtplugins", |
98 | "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; | 100 | "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; |
99 | 101 | ||
100 | static int tokenize( QStringList& token, const QString& str, | 102 | static int tokenize( QStringList& token, const QString& str, |
101 | const QString& delim ); | 103 | const QString& delim ); |
102 | 104 | ||
103 | KStandardDirs::KStandardDirs( ) : addedCustoms(false) | 105 | KStandardDirs::KStandardDirs( ) : addedCustoms(false) |
104 | { | 106 | { |
105 | d = new KStandardDirsPrivate; | 107 | d = new KStandardDirsPrivate; |
106 | dircache.setAutoDelete(true); | 108 | dircache.setAutoDelete(true); |
107 | relatives.setAutoDelete(true); | 109 | relatives.setAutoDelete(true); |
108 | absolutes.setAutoDelete(true); | 110 | absolutes.setAutoDelete(true); |
109 | savelocations.setAutoDelete(true); | 111 | savelocations.setAutoDelete(true); |
110 | addKDEDefaults(); | 112 | addKDEDefaults(); |
111 | } | 113 | } |
112 | 114 | ||
113 | KStandardDirs::~KStandardDirs() | 115 | KStandardDirs::~KStandardDirs() |
114 | { | 116 | { |
115 | delete d; | 117 | delete d; |
116 | } | 118 | } |
117 | 119 | ||
118 | bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const | 120 | bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const |
119 | { | 121 | { |
120 | if (!d || !d->restrictionsActive) | 122 | if (!d || !d->restrictionsActive) |
121 | return false; | 123 | return false; |
122 | 124 | ||
123 | if (d->restrictions[type]) | 125 | if (d->restrictions[type]) |
124 | return true; | 126 | return true; |
125 | 127 | ||
126 | if (strcmp(type, "data")==0) | 128 | if (strcmp(type, "data")==0) |
127 | { | 129 | { |
128 | applyDataRestrictions(relPath); | 130 | applyDataRestrictions(relPath); |
129 | if (d->dataRestrictionActive) | 131 | if (d->dataRestrictionActive) |
130 | { | 132 | { |
131 | d->dataRestrictionActive = false; | 133 | d->dataRestrictionActive = false; |
132 | return true; | 134 | return true; |
133 | } | 135 | } |
134 | } | 136 | } |
135 | return false; | 137 | return false; |
136 | } | 138 | } |
137 | 139 | ||
138 | void KStandardDirs::applyDataRestrictions(const QString &relPath) const | 140 | void KStandardDirs::applyDataRestrictions(const QString &relPath) const |
139 | { | 141 | { |
140 | QString key; | 142 | QString key; |
141 | int i = relPath.find('/'); | 143 | int i = relPath.find('/'); |
142 | if (i != -1) | 144 | if (i != -1) |
143 | key = "data_"+relPath.left(i); | 145 | key = "data_"+relPath.left(i); |
144 | else | 146 | else |
145 | key = "data_"+relPath; | 147 | key = "data_"+relPath; |
146 | 148 | ||
147 | if (d && d->restrictions[key.latin1()]) | 149 | if (d && d->restrictions[key.latin1()]) |
148 | d->dataRestrictionActive = true; | 150 | d->dataRestrictionActive = true; |
149 | } | 151 | } |
150 | 152 | ||
151 | 153 | ||
152 | QStringList KStandardDirs::allTypes() const | 154 | QStringList KStandardDirs::allTypes() const |
153 | { | 155 | { |
154 | QStringList list; | 156 | QStringList list; |
155 | for (int i = 0; types[i] != 0; ++i) | 157 | for (int i = 0; types[i] != 0; ++i) |
156 | list.append(QString::fromLatin1(types[i])); | 158 | list.append(QString::fromLatin1(types[i])); |
157 | return list; | 159 | return list; |
158 | } | 160 | } |
159 | 161 | ||
160 | void KStandardDirs::addPrefix( const QString& _dir ) | 162 | void KStandardDirs::addPrefix( const QString& _dir ) |
161 | { | 163 | { |
162 | if (_dir.isNull()) | 164 | if (_dir.isNull()) |
163 | return; | 165 | return; |
164 | 166 | ||
165 | QString dir = _dir; | 167 | QString dir = _dir; |
166 | if (dir.at(dir.length() - 1) != '/') | 168 | if (dir.at(dir.length() - 1) != '/') |
167 | dir += '/'; | 169 | dir += '/'; |
168 | 170 | ||
169 | if (!prefixes.contains(dir)) { | 171 | if (!prefixes.contains(dir)) { |
170 | prefixes.append(dir); | 172 | prefixes.append(dir); |
171 | dircache.clear(); | 173 | dircache.clear(); |
172 | } | 174 | } |
173 | } | 175 | } |
174 | 176 | ||
175 | void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) | 177 | void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) |
176 | { | 178 | { |
177 | if (_dir.isNull()) | 179 | if (_dir.isNull()) |
178 | return; | 180 | return; |
179 | 181 | ||
180 | QString dir = _dir; | 182 | QString dir = _dir; |
181 | if (dir.at(dir.length() - 1) != '/') | 183 | if (dir.at(dir.length() - 1) != '/') |
182 | dir += '/'; | 184 | dir += '/'; |
183 | 185 | ||
184 | if (!d->xdgconf_prefixes.contains(dir)) { | 186 | if (!d->xdgconf_prefixes.contains(dir)) { |
@@ -352,230 +354,230 @@ QString KStandardDirs::findResourceDir( const char *type, | |||
352 | applyDataRestrictions(filename); | 354 | applyDataRestrictions(filename); |
353 | QStringList candidates = resourceDirs(type); | 355 | QStringList candidates = resourceDirs(type); |
354 | QString fullPath; | 356 | QString fullPath; |
355 | #ifdef DESKTOP_VERSION | 357 | #ifdef DESKTOP_VERSION |
356 | #ifdef _WIN32_ | 358 | #ifdef _WIN32_ |
357 | candidates.prepend( qApp->applicationDirPath () +"\\"); | 359 | candidates.prepend( qApp->applicationDirPath () +"\\"); |
358 | #else | 360 | #else |
359 | candidates.prepend( qApp->applicationDirPath () +"/"); | 361 | candidates.prepend( qApp->applicationDirPath () +"/"); |
360 | #endif | 362 | #endif |
361 | #endif | 363 | #endif |
362 | for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) | 364 | for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) |
363 | { | 365 | { |
364 | //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1()); | 366 | //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1()); |
365 | if (exists(*it + filename)) | 367 | if (exists(*it + filename)) |
366 | return *it; | 368 | return *it; |
367 | } | 369 | } |
368 | 370 | ||
369 | #ifndef NDEBUG | 371 | #ifndef NDEBUG |
370 | if(false && type != "locale") | 372 | if(false && type != "locale") |
371 | qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1()); | 373 | qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1()); |
372 | 374 | ||
373 | #endif | 375 | #endif |
374 | 376 | ||
375 | return QString::null; | 377 | return QString::null; |
376 | } | 378 | } |
377 | 379 | ||
378 | bool KStandardDirs::exists(const QString &fullPath) | 380 | bool KStandardDirs::exists(const QString &fullPath) |
379 | { | 381 | { |
380 | //US struct stat buff; | 382 | //US struct stat buff; |
381 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); | 383 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); |
382 | 384 | ||
383 | //US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) | 385 | //US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) |
384 | if (fullPathInfo.isReadable()) | 386 | if (fullPathInfo.isReadable()) |
385 | { | 387 | { |
386 | if (fullPath.at(fullPath.length() - 1) != '/') { | 388 | if (fullPath.at(fullPath.length() - 1) != '/') { |
387 | //US if (S_ISREG( buff.st_mode )) | 389 | //US if (S_ISREG( buff.st_mode )) |
388 | if (fullPathInfo.isFile()) | 390 | if (fullPathInfo.isFile()) |
389 | return true; | 391 | return true; |
390 | } | 392 | } |
391 | else { | 393 | else { |
392 | //US if (S_ISDIR( buff.st_mode )) | 394 | //US if (S_ISDIR( buff.st_mode )) |
393 | if (fullPathInfo.isDir()) | 395 | if (fullPathInfo.isDir()) |
394 | return true; | 396 | return true; |
395 | } | 397 | } |
396 | } | 398 | } |
397 | return false; | 399 | return false; |
398 | } | 400 | } |
399 | 401 | ||
400 | static void lookupDirectory(const QString& path, const QString &relPart, | 402 | static void lookupDirectory(const QString& path, const QString &relPart, |
401 | const QRegExp ®exp, | 403 | const QRegExp ®exp, |
402 | QStringList& list, | 404 | QStringList& list, |
403 | QStringList& relList, | 405 | QStringList& relList, |
404 | bool recursive, bool uniq) | 406 | bool recursive, bool uniq) |
405 | { | 407 | { |
406 | QString pattern = regexp.pattern(); | 408 | QString pattern = regexp.pattern(); |
407 | if (recursive || pattern.contains('?') || pattern.contains('*')) | 409 | if (recursive || pattern.contains('?') || pattern.contains('*')) |
408 | { | 410 | { |
409 | // We look for a set of files. | 411 | // We look for a set of files. |
410 | //US DIR *dp = opendir( QFile::encodeName(path)); | 412 | //US DIR *dp = opendir( QFile::encodeName(path)); |
411 | QDir dp(QFile::encodeName(path)); | 413 | QDir dp(QFile::encodeName(path)); |
412 | 414 | ||
413 | if (!dp.exists()) | 415 | if (!dp.exists()) |
414 | return; | 416 | return; |
415 | static int iii = 0; | 417 | static int iii = 0; |
416 | ++iii; | 418 | ++iii; |
417 | if ( iii == 5 ) | 419 | if ( iii == 5 ) |
418 | abort(); | 420 | abort(); |
419 | assert(path.at(path.length() - 1) == '/'); | 421 | assert(path.at(path.length() - 1) == '/'); |
420 | 422 | ||
421 | //US struct dirent *ep; | 423 | //US struct dirent *ep; |
422 | //US struct stat buff; | 424 | //US struct stat buff; |
423 | 425 | ||
424 | QString _dot("."); | 426 | QString _dot("."); |
425 | QString _dotdot(".."); | 427 | QString _dotdot(".."); |
426 | 428 | ||
427 | //US while( ( ep = readdir( dp ) ) != 0L ) | 429 | //US while( ( ep = readdir( dp ) ) != 0L ) |
428 | QStringList direntries = dp.entryList(); | 430 | QStringList direntries = dp.entryList(); |
429 | QStringList::Iterator it = direntries.begin(); | 431 | QStringList::Iterator it = direntries.begin(); |
430 | 432 | ||
431 | while ( it != list.end() ) // for each file... | 433 | while ( it != list.end() ) // for each file... |
432 | { | 434 | { |
433 | 435 | ||
434 | //US QString fn( QFile::decodeName(ep->d_name)); | 436 | //US QString fn( QFile::decodeName(ep->d_name)); |
435 | QString fn = (*it); // dp.entryList already decodes | 437 | QString fn = (*it); // dp.entryList already decodes |
436 | it++; | 438 | it++; |
437 | if ( fn.isNull() ) | 439 | if ( fn.isNull() ) |
438 | break; | 440 | break; |
439 | 441 | ||
440 | if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) | 442 | if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) |
441 | continue; | 443 | continue; |
442 | 444 | ||
443 | /*US | 445 | /*US |
444 | if (!recursive && !regexp.exactMatch(fn)) | 446 | if (!recursive && !regexp.exactMatch(fn)) |
445 | continue; // No match | 447 | continue; // No match |
446 | */ | 448 | */ |
447 | //US this should do the same: | 449 | //US this should do the same: |
448 | int pos = regexp.match(fn); | 450 | int pos = regexp.exactMatch(fn); |
449 | if (!recursive && !pos == 0) | 451 | if (!recursive && !pos == 0) |
450 | continue; // No match | 452 | continue; // No match |
451 | 453 | ||
452 | QString pathfn = path + fn; | 454 | QString pathfn = path + fn; |
453 | /*US | 455 | /*US |
454 | if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { | 456 | if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { |
455 | kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; | 457 | kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; |
456 | continue; // Couldn't stat (e.g. no read permissions) | 458 | continue; // Couldn't stat (e.g. no read permissions) |
457 | } | 459 | } |
458 | 460 | ||
459 | if ( recursive ) | 461 | if ( recursive ) |
460 | { | 462 | { |
461 | if ( S_ISDIR( buff.st_mode )) { | 463 | if ( S_ISDIR( buff.st_mode )) { |
462 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); | 464 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); |
463 | } | 465 | } |
464 | */ | 466 | */ |
465 | //US replacement: | 467 | //US replacement: |
466 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); | 468 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); |
467 | if ( pathfnInfo.isReadable() == false ) | 469 | if ( pathfnInfo.isReadable() == false ) |
468 | { | 470 | { |
469 | //US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; | 471 | //US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; |
470 | continue; // Couldn't stat (e.g. no read permissions) | 472 | continue; // Couldn't stat (e.g. no read permissions) |
471 | } | 473 | } |
472 | 474 | ||
473 | if ( recursive ) | 475 | if ( recursive ) |
474 | { | 476 | { |
475 | if ( pathfnInfo.isDir()) { | 477 | if ( pathfnInfo.isDir()) { |
476 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); | 478 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); |
477 | } | 479 | } |
478 | 480 | ||
479 | 481 | ||
480 | /*US | 482 | /*US |
481 | if (!regexp.exactMatch(fn)) | 483 | if (!regexp.exactMatch(fn)) |
482 | continue; // No match | 484 | continue; // No match |
483 | */ | 485 | */ |
484 | //US this should do the same: | 486 | //US this should do the same: |
485 | pos = regexp.match(fn); | 487 | pos = regexp.exactMatch(fn); |
486 | if (!pos == 0) | 488 | if (!pos == 0) |
487 | continue; // No match | 489 | continue; // No match |
488 | } | 490 | } |
489 | 491 | ||
490 | //US if ( S_ISREG( buff.st_mode)) | 492 | //US if ( S_ISREG( buff.st_mode)) |
491 | if ( pathfnInfo.isFile()) | 493 | if ( pathfnInfo.isFile()) |
492 | { | 494 | { |
493 | if (!uniq || !relList.contains(relPart + fn)) | 495 | if (!uniq || !relList.contains(relPart + fn)) |
494 | { | 496 | { |
495 | list.append( pathfn ); | 497 | list.append( pathfn ); |
496 | relList.append( relPart + fn ); | 498 | relList.append( relPart + fn ); |
497 | } | 499 | } |
498 | } | 500 | } |
499 | } | 501 | } |
500 | //US closedir( dp ); | 502 | //US closedir( dp ); |
501 | } | 503 | } |
502 | else | 504 | else |
503 | { | 505 | { |
504 | // We look for a single file. | 506 | // We look for a single file. |
505 | QString fn = pattern; | 507 | QString fn = pattern; |
506 | QString pathfn = path + fn; | 508 | QString pathfn = path + fn; |
507 | //US struct stat buff; | 509 | //US struct stat buff; |
508 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); | 510 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); |
509 | 511 | ||
510 | 512 | ||
511 | //US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) | 513 | //US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) |
512 | if ( pathfnInfo.isReadable() == false ) | 514 | if ( pathfnInfo.isReadable() == false ) |
513 | return; // File not found | 515 | return; // File not found |
514 | 516 | ||
515 | //US if ( S_ISREG( buff.st_mode)) | 517 | //US if ( S_ISREG( buff.st_mode)) |
516 | if ( pathfnInfo.isFile()) | 518 | if ( pathfnInfo.isFile()) |
517 | { | 519 | { |
518 | if (!uniq || !relList.contains(relPart + fn)) | 520 | if (!uniq || !relList.contains(relPart + fn)) |
519 | { | 521 | { |
520 | list.append( pathfn ); | 522 | list.append( pathfn ); |
521 | relList.append( relPart + fn ); | 523 | relList.append( relPart + fn ); |
522 | } | 524 | } |
523 | } | 525 | } |
524 | } | 526 | } |
525 | } | 527 | } |
526 | 528 | ||
527 | static void lookupPrefix(const QString& prefix, const QString& relpath, | 529 | static void lookupPrefix(const QString& prefix, const QString& relpath, |
528 | const QString& relPart, | 530 | const QString& relPart, |
529 | const QRegExp ®exp, | 531 | const QRegExp ®exp, |
530 | QStringList& list, | 532 | QStringList& list, |
531 | QStringList& relList, | 533 | QStringList& relList, |
532 | bool recursive, bool uniq) | 534 | bool recursive, bool uniq) |
533 | { | 535 | { |
534 | if (relpath.isNull()) { | 536 | if (relpath.isNull()) { |
535 | lookupDirectory(prefix, relPart, regexp, list, | 537 | lookupDirectory(prefix, relPart, regexp, list, |
536 | relList, recursive, uniq); | 538 | relList, recursive, uniq); |
537 | return; | 539 | return; |
538 | } | 540 | } |
539 | QString path; | 541 | QString path; |
540 | QString rest; | 542 | QString rest; |
541 | 543 | ||
542 | if (relpath.length()) | 544 | if (relpath.length()) |
543 | { | 545 | { |
544 | int slash = relpath.find('/'); | 546 | int slash = relpath.find('/'); |
545 | if (slash < 0) | 547 | if (slash < 0) |
546 | rest = relpath.left(relpath.length() - 1); | 548 | rest = relpath.left(relpath.length() - 1); |
547 | else { | 549 | else { |
548 | path = relpath.left(slash); | 550 | path = relpath.left(slash); |
549 | rest = relpath.mid(slash + 1); | 551 | rest = relpath.mid(slash + 1); |
550 | } | 552 | } |
551 | } | 553 | } |
552 | assert(prefix.at(prefix.length() - 1) == '/'); | 554 | assert(prefix.at(prefix.length() - 1) == '/'); |
553 | 555 | ||
554 | //US struct stat buff; | 556 | //US struct stat buff; |
555 | 557 | ||
556 | if (path.contains('*') || path.contains('?')) { | 558 | if (path.contains('*') || path.contains('?')) { |
557 | QRegExp pathExp(path, true, true); | 559 | QRegExp pathExp(path, true, true); |
558 | //USDIR *dp = opendir( QFile::encodeName(prefix) ); | 560 | //USDIR *dp = opendir( QFile::encodeName(prefix) ); |
559 | QDir dp(QFile::encodeName(prefix)); | 561 | QDir dp(QFile::encodeName(prefix)); |
560 | 562 | ||
561 | //USif (!dp) | 563 | //USif (!dp) |
562 | if (!dp.exists()) | 564 | if (!dp.exists()) |
563 | { | 565 | { |
564 | return; | 566 | return; |
565 | } | 567 | } |
566 | 568 | ||
567 | //USstruct dirent *ep; | 569 | //USstruct dirent *ep; |
568 | 570 | ||
569 | QString _dot("."); | 571 | QString _dot("."); |
570 | QString _dotdot(".."); | 572 | QString _dotdot(".."); |
571 | 573 | ||
572 | //USwhile( ( ep = readdir( dp ) ) != 0L ) | 574 | //USwhile( ( ep = readdir( dp ) ) != 0L ) |
573 | QStringList direntries = dp.entryList(); | 575 | QStringList direntries = dp.entryList(); |
574 | QStringList::Iterator it = direntries.begin(); | 576 | QStringList::Iterator it = direntries.begin(); |
575 | 577 | ||
576 | while ( it != list.end() ) // for each file... | 578 | while ( it != list.end() ) // for each file... |
577 | { | 579 | { |
578 | //US QString fn( QFile::decodeName(ep->d_name)); | 580 | //US QString fn( QFile::decodeName(ep->d_name)); |
579 | QString fn = (*it); // dp.entryList() already encodes the strings | 581 | QString fn = (*it); // dp.entryList() already encodes the strings |
580 | it++; | 582 | it++; |
581 | 583 | ||
@@ -1015,293 +1017,293 @@ QString KStandardDirs::saveLocation(const char *type, | |||
1015 | (strcmp(type, "tmp") == 0) || | 1017 | (strcmp(type, "tmp") == 0) || |
1016 | (strcmp(type, "cache") == 0) )) | 1018 | (strcmp(type, "cache") == 0) )) |
1017 | { | 1019 | { |
1018 | (void) resourceDirs(type); // Generate socket|tmp|cache resource. | 1020 | (void) resourceDirs(type); // Generate socket|tmp|cache resource. |
1019 | dirs = relatives.find(type); // Search again. | 1021 | dirs = relatives.find(type); // Search again. |
1020 | } | 1022 | } |
1021 | if (dirs) | 1023 | if (dirs) |
1022 | { | 1024 | { |
1023 | // Check for existance of typed directory + suffix | 1025 | // Check for existance of typed directory + suffix |
1024 | if (strncmp(type, "xdgdata-", 8) == 0) | 1026 | if (strncmp(type, "xdgdata-", 8) == 0) |
1025 | pPath = new QString(realPath(localxdgdatadir() + dirs->last())); | 1027 | pPath = new QString(realPath(localxdgdatadir() + dirs->last())); |
1026 | else if (strncmp(type, "xdgconf-", 8) == 0) | 1028 | else if (strncmp(type, "xdgconf-", 8) == 0) |
1027 | pPath = new QString(realPath(localxdgconfdir() + dirs->last())); | 1029 | pPath = new QString(realPath(localxdgconfdir() + dirs->last())); |
1028 | else | 1030 | else |
1029 | pPath = new QString(realPath(localkdedir() + dirs->last())); | 1031 | pPath = new QString(realPath(localkdedir() + dirs->last())); |
1030 | } | 1032 | } |
1031 | else { | 1033 | else { |
1032 | dirs = absolutes.find(type); | 1034 | dirs = absolutes.find(type); |
1033 | if (!dirs) | 1035 | if (!dirs) |
1034 | qFatal("KStandardDirs: The resource type %s is not registered", type); | 1036 | qFatal("KStandardDirs: The resource type %s is not registered", type); |
1035 | pPath = new QString(realPath(dirs->last())); | 1037 | pPath = new QString(realPath(dirs->last())); |
1036 | } | 1038 | } |
1037 | 1039 | ||
1038 | savelocations.insert(type, pPath); | 1040 | savelocations.insert(type, pPath); |
1039 | } | 1041 | } |
1040 | 1042 | ||
1041 | QString fullPath = *pPath + suffix; | 1043 | QString fullPath = *pPath + suffix; |
1042 | //US struct stat st; | 1044 | //US struct stat st; |
1043 | //US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) | 1045 | //US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) |
1044 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); | 1046 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); |
1045 | if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) | 1047 | if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) |
1046 | 1048 | ||
1047 | 1049 | ||
1048 | { | 1050 | { |
1049 | if(!create) { | 1051 | if(!create) { |
1050 | #ifndef NDEBUG | 1052 | #ifndef NDEBUG |
1051 | qDebug("save location %s doesn't exist", fullPath.latin1()); | 1053 | qDebug("save location %s doesn't exist", fullPath.latin1()); |
1052 | #endif | 1054 | #endif |
1053 | return fullPath; | 1055 | return fullPath; |
1054 | } | 1056 | } |
1055 | if(!makeDir(fullPath, 0700)) { | 1057 | if(!makeDir(fullPath, 0700)) { |
1056 | qWarning("failed to create %s", fullPath.latin1()); | 1058 | qWarning("failed to create %s", fullPath.latin1()); |
1057 | return fullPath; | 1059 | return fullPath; |
1058 | } | 1060 | } |
1059 | dircache.remove(type); | 1061 | dircache.remove(type); |
1060 | } | 1062 | } |
1061 | return fullPath; | 1063 | return fullPath; |
1062 | } | 1064 | } |
1063 | 1065 | ||
1064 | QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) | 1066 | QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) |
1065 | { | 1067 | { |
1066 | QString fullPath = absPath; | 1068 | QString fullPath = absPath; |
1067 | int i = absPath.findRev('/'); | 1069 | int i = absPath.findRev('/'); |
1068 | if (i != -1) | 1070 | if (i != -1) |
1069 | { | 1071 | { |
1070 | fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize | 1072 | fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize |
1071 | } | 1073 | } |
1072 | 1074 | ||
1073 | QStringList candidates = resourceDirs(type); | 1075 | QStringList candidates = resourceDirs(type); |
1074 | 1076 | ||
1075 | for (QStringList::ConstIterator it = candidates.begin(); | 1077 | for (QStringList::ConstIterator it = candidates.begin(); |
1076 | it != candidates.end(); it++) | 1078 | it != candidates.end(); it++) |
1077 | if (fullPath.startsWith(*it)) | 1079 | if (fullPath.startsWith(*it)) |
1078 | { | 1080 | { |
1079 | return fullPath.mid((*it).length()); | 1081 | return fullPath.mid((*it).length()); |
1080 | } | 1082 | } |
1081 | 1083 | ||
1082 | return absPath; | 1084 | return absPath; |
1083 | } | 1085 | } |
1084 | 1086 | ||
1085 | 1087 | ||
1086 | bool KStandardDirs::makeDir(const QString& dir2, int mode) | 1088 | bool KStandardDirs::makeDir(const QString& dir2, int mode) |
1087 | { | 1089 | { |
1088 | QString dir = QDir::convertSeparators( dir2 ); | 1090 | QString dir = QDir::convertSeparators( dir2 ); |
1089 | #if 0 | 1091 | #if 0 |
1090 | //LR | 1092 | //LR |
1091 | 1093 | ||
1092 | // we want an absolute path | 1094 | // we want an absolute path |
1093 | if (dir.at(0) != '/') | 1095 | if (dir.at(0) != '/') |
1094 | return false; | 1096 | return false; |
1095 | 1097 | ||
1096 | QString target = dir; | 1098 | QString target = dir; |
1097 | uint len = target.length(); | 1099 | uint len = target.length(); |
1098 | 1100 | ||
1099 | // append trailing slash if missing | 1101 | // append trailing slash if missing |
1100 | if (dir.at(len - 1) != '/') | 1102 | if (dir.at(len - 1) != '/') |
1101 | target += '/'; | 1103 | target += '/'; |
1102 | 1104 | ||
1103 | QString base(""); | 1105 | QString base(""); |
1104 | uint i = 1; | 1106 | uint i = 1; |
1105 | 1107 | ||
1106 | while( i < len ) | 1108 | while( i < len ) |
1107 | { | 1109 | { |
1108 | //US struct stat st; | 1110 | //US struct stat st; |
1109 | int pos = target.find('/', i); | 1111 | int pos = target.find('/', i); |
1110 | base += target.mid(i - 1, pos - i + 1); | 1112 | base += target.mid(i - 1, pos - i + 1); |
1111 | QCString baseEncoded = QFile::encodeName(base); | 1113 | Q3CString baseEncoded = QFile::encodeName(base); |
1112 | // bail out if we encountered a problem | 1114 | // bail out if we encountered a problem |
1113 | //US if (stat(baseEncoded, &st) != 0) | 1115 | //US if (stat(baseEncoded, &st) != 0) |
1114 | QFileInfo baseEncodedInfo(baseEncoded); | 1116 | QFileInfo baseEncodedInfo(baseEncoded); |
1115 | if (!baseEncodedInfo.exists()) | 1117 | if (!baseEncodedInfo.exists()) |
1116 | { | 1118 | { |
1117 | // Directory does not exist.... | 1119 | // Directory does not exist.... |
1118 | // Or maybe a dangling symlink ? | 1120 | // Or maybe a dangling symlink ? |
1119 | //US if (lstat(baseEncoded, &st) == 0) | 1121 | //US if (lstat(baseEncoded, &st) == 0) |
1120 | if (baseEncodedInfo.isSymLink()) { | 1122 | if (baseEncodedInfo.isSymLink()) { |
1121 | //US (void)unlink(baseEncoded); // try removing | 1123 | //US (void)unlink(baseEncoded); // try removing |
1122 | QFile(baseEncoded).remove(); | 1124 | QFile(baseEncoded).remove(); |
1123 | } | 1125 | } |
1124 | 1126 | ||
1125 | //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) | 1127 | //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) |
1126 | QDir dirObj; | 1128 | QDir dirObj; |
1127 | if ( dirObj.mkdir(baseEncoded) != true ) | 1129 | if ( dirObj.mkdir(baseEncoded) != true ) |
1128 | { | 1130 | { |
1129 | //US perror("trying to create local folder"); | 1131 | //US perror("trying to create local folder"); |
1130 | return false; // Couldn't create it :-( | 1132 | return false; // Couldn't create it :-( |
1131 | } | 1133 | } |
1132 | } | 1134 | } |
1133 | i = pos + 1; | 1135 | i = pos + 1; |
1134 | } | 1136 | } |
1135 | return true; | 1137 | return true; |
1136 | #endif | 1138 | #endif |
1137 | 1139 | ||
1138 | // ******************************************** | 1140 | // ******************************************** |
1139 | // new code for WIN32 | 1141 | // new code for WIN32 |
1140 | QDir dirObj; | 1142 | QDir dirObj; |
1141 | 1143 | ||
1142 | 1144 | ||
1143 | // we want an absolute path | 1145 | // we want an absolute path |
1144 | #ifndef _WIN32_ | 1146 | #ifndef _WIN32_ |
1145 | if (dir.at(0) != '/') | 1147 | if (dir.at(0) != '/') |
1146 | return false; | 1148 | return false; |
1147 | #endif | 1149 | #endif |
1148 | 1150 | ||
1149 | QString target = dir; | 1151 | QString target = dir; |
1150 | uint len = target.length(); | 1152 | uint len = target.length(); |
1151 | #ifndef _WIN32_ | 1153 | #ifndef _WIN32_ |
1152 | // append trailing slash if missing | 1154 | // append trailing slash if missing |
1153 | if (dir.at(len - 1) != '/') | 1155 | if (dir.at(len - 1) != '/') |
1154 | target += '/'; | 1156 | target += '/'; |
1155 | #endif | 1157 | #endif |
1156 | 1158 | ||
1157 | QString base(""); | 1159 | QString base(""); |
1158 | uint i = 1; | 1160 | uint i = 1; |
1159 | 1161 | ||
1160 | while( i < len ) | 1162 | while( i < len ) |
1161 | { | 1163 | { |
1162 | //US struct stat st; | 1164 | //US struct stat st; |
1163 | #ifndef _WIN32_ | 1165 | #ifndef _WIN32_ |
1164 | int pos = target.find('/', i); | 1166 | int pos = target.find('/', i); |
1165 | #else | 1167 | #else |
1166 | int pos = target.find('\\', i); | 1168 | int pos = target.find('\\', i); |
1167 | #endif | 1169 | #endif |
1168 | if ( pos < 0 ) | 1170 | if ( pos < 0 ) |
1169 | return true; | 1171 | return true; |
1170 | base += target.mid(i - 1, pos - i + 1); | 1172 | base += target.mid(i - 1, pos - i + 1); |
1171 | //QMessageBox::information( 0,"cap111", base, 1 ); | 1173 | //QMessageBox::information( 0,"cap111", base, 1 ); |
1172 | /*US | 1174 | /*US |
1173 | QCString baseEncoded = QFile::encodeName(base); | 1175 | QCString baseEncoded = QFile::encodeName(base); |
1174 | // bail out if we encountered a problem | 1176 | // bail out if we encountered a problem |
1175 | if (stat(baseEncoded, &st) != 0) | 1177 | if (stat(baseEncoded, &st) != 0) |
1176 | { | 1178 | { |
1177 | // Directory does not exist.... | 1179 | // Directory does not exist.... |
1178 | // Or maybe a dangling symlink ? | 1180 | // Or maybe a dangling symlink ? |
1179 | if (lstat(baseEncoded, &st) == 0) | 1181 | if (lstat(baseEncoded, &st) == 0) |
1180 | (void)unlink(baseEncoded); // try removing | 1182 | (void)unlink(baseEncoded); // try removing |
1181 | 1183 | ||
1182 | 1184 | ||
1183 | if ( mkdir(baseEncoded, (mode_t) mode) != 0) { | 1185 | if ( mkdir(baseEncoded, (mode_t) mode) != 0) { |
1184 | perror("trying to create local folder"); | 1186 | perror("trying to create local folder"); |
1185 | return false; // Couldn't create it :-( | 1187 | return false; // Couldn't create it :-( |
1186 | } | 1188 | } |
1187 | } | 1189 | } |
1188 | */ | 1190 | */ |
1189 | 1191 | ||
1190 | if (dirObj.exists(base) == false) | 1192 | if (dirObj.exists(base) == false) |
1191 | { | 1193 | { |
1192 | //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); | 1194 | //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); |
1193 | if (dirObj.mkdir(base) != true) | 1195 | if (dirObj.mkdir(base) != true) |
1194 | { | 1196 | { |
1195 | qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); | 1197 | qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); |
1196 | return false; | 1198 | return false; |
1197 | } | 1199 | } |
1198 | } | 1200 | } |
1199 | 1201 | ||
1200 | i = pos + 1; | 1202 | i = pos + 1; |
1201 | } | 1203 | } |
1202 | return true; | 1204 | return true; |
1203 | 1205 | ||
1204 | } | 1206 | } |
1205 | 1207 | ||
1206 | QString readEnvPath(const char *env) | 1208 | QString readEnvPath(const char *env) |
1207 | { | 1209 | { |
1208 | //#ifdef _WIN32_ | 1210 | //#ifdef _WIN32_ |
1209 | // return ""; | 1211 | // return ""; |
1210 | //#else | 1212 | //#else |
1211 | QCString c_path; | 1213 | Q3CString c_path; |
1212 | if ( getenv(env) != NULL ) | 1214 | if ( getenv(env) != NULL ) |
1213 | c_path = QString ( getenv(env) ); | 1215 | c_path = QString ( getenv(env) ); |
1214 | if (c_path.isEmpty()) | 1216 | if (c_path.isEmpty()) |
1215 | return QString::null; | 1217 | return QString::null; |
1216 | return QFile::decodeName(c_path); | 1218 | return QFile::decodeName(c_path); |
1217 | //#endif | 1219 | //#endif |
1218 | 1220 | ||
1219 | } | 1221 | } |
1220 | 1222 | ||
1221 | void KStandardDirs::addKDEDefaults() | 1223 | void KStandardDirs::addKDEDefaults() |
1222 | { | 1224 | { |
1223 | 1225 | ||
1224 | //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); | 1226 | //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); |
1225 | //return; | 1227 | //return; |
1226 | QStringList kdedirList; | 1228 | QStringList kdedirList; |
1227 | 1229 | ||
1228 | // begin KDEDIRS | 1230 | // begin KDEDIRS |
1229 | QString kdedirs = readEnvPath("MICROKDEDIRS"); | 1231 | QString kdedirs = readEnvPath("MICROKDEDIRS"); |
1230 | if (!kdedirs.isEmpty()) | 1232 | if (!kdedirs.isEmpty()) |
1231 | { | 1233 | { |
1232 | tokenize(kdedirList, kdedirs, ":"); | 1234 | tokenize(kdedirList, kdedirs, ":"); |
1233 | } | 1235 | } |
1234 | else | 1236 | else |
1235 | { | 1237 | { |
1236 | QString kdedir = readEnvPath("MICROKDEDIR"); | 1238 | QString kdedir = readEnvPath("MICROKDEDIR"); |
1237 | if (!kdedir.isEmpty()) | 1239 | if (!kdedir.isEmpty()) |
1238 | { | 1240 | { |
1239 | kdedir = KShell::tildeExpand(kdedir); | 1241 | kdedir = KShell::tildeExpand(kdedir); |
1240 | kdedirList.append(kdedir); | 1242 | kdedirList.append(kdedir); |
1241 | } | 1243 | } |
1242 | } | 1244 | } |
1243 | //US kdedirList.append(KDEDIR); | 1245 | //US kdedirList.append(KDEDIR); |
1244 | //US for embedded, add qtopia dir as kdedir | 1246 | //US for embedded, add qtopia dir as kdedir |
1245 | 1247 | ||
1246 | #ifndef DESKTOP_VERSION | 1248 | #ifndef DESKTOP_VERSION |
1247 | QString tmp = readEnvPath("QPEDIR"); | 1249 | QString tmp = readEnvPath("QPEDIR"); |
1248 | if (!tmp.isEmpty()) | 1250 | if (!tmp.isEmpty()) |
1249 | kdedirList.append(tmp); | 1251 | kdedirList.append(tmp); |
1250 | 1252 | ||
1251 | tmp = readEnvPath("QTDIR"); | 1253 | tmp = readEnvPath("QTDIR"); |
1252 | if (!tmp.isEmpty()) | 1254 | if (!tmp.isEmpty()) |
1253 | kdedirList.append(tmp); | 1255 | kdedirList.append(tmp); |
1254 | 1256 | ||
1255 | tmp = readEnvPath("OPIEDIR"); | 1257 | tmp = readEnvPath("OPIEDIR"); |
1256 | if (!tmp.isEmpty()) | 1258 | if (!tmp.isEmpty()) |
1257 | kdedirList.append(tmp); | 1259 | kdedirList.append(tmp); |
1258 | 1260 | ||
1259 | #endif | 1261 | #endif |
1260 | 1262 | ||
1261 | #ifdef __KDE_EXECPREFIX | 1263 | #ifdef __KDE_EXECPREFIX |
1262 | QString execPrefix(__KDE_EXECPREFIX); | 1264 | QString execPrefix(__KDE_EXECPREFIX); |
1263 | if (execPrefix!="NONE") | 1265 | if (execPrefix!="NONE") |
1264 | kdedirList.append(execPrefix); | 1266 | kdedirList.append(execPrefix); |
1265 | #endif | 1267 | #endif |
1266 | 1268 | ||
1267 | QString localKdeDir; | 1269 | QString localKdeDir; |
1268 | 1270 | ||
1269 | //US if (getuid()) | 1271 | //US if (getuid()) |
1270 | if (true) | 1272 | if (true) |
1271 | { | 1273 | { |
1272 | localKdeDir = readEnvPath("MICROKDEHOME"); | 1274 | localKdeDir = readEnvPath("MICROKDEHOME"); |
1273 | if (!localKdeDir.isEmpty()) | 1275 | if (!localKdeDir.isEmpty()) |
1274 | { | 1276 | { |
1275 | #ifdef _WIN32_ | 1277 | #ifdef _WIN32_ |
1276 | if (localKdeDir.at(localKdeDir.length()-1) != '\\') | 1278 | if (localKdeDir.at(localKdeDir.length()-1) != '\\') |
1277 | localKdeDir += '\\'; | 1279 | localKdeDir += '\\'; |
1278 | #else | 1280 | #else |
1279 | if (localKdeDir.at(localKdeDir.length()-1) != '/') | 1281 | if (localKdeDir.at(localKdeDir.length()-1) != '/') |
1280 | localKdeDir += '/'; | 1282 | localKdeDir += '/'; |
1281 | #endif | 1283 | #endif |
1282 | //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); | 1284 | //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); |
1283 | } | 1285 | } |
1284 | else | 1286 | else |
1285 | { | 1287 | { |
1286 | QString confFile; | 1288 | QString confFile; |
1287 | #ifdef DESKTOP_VERSION | 1289 | #ifdef DESKTOP_VERSION |
1288 | confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; | 1290 | confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; |
1289 | QFileInfo fi ( confFile ); | 1291 | QFileInfo fi ( confFile ); |
1290 | if ( !fi.exists() ) | 1292 | if ( !fi.exists() ) |
1291 | confFile = QDir::homeDirPath() + "/.microkdehome"; | 1293 | confFile = QDir::homeDirPath() + "/.microkdehome"; |
1292 | else | 1294 | else |
1293 | qDebug("Loading path info from " + confFile ); | 1295 | qDebug("Loading path info from " + confFile ); |
1294 | 1296 | ||
1295 | #else | 1297 | #else |
1296 | confFile = QDir::homeDirPath() + "/.microkdehome"; | 1298 | confFile = QDir::homeDirPath() + "/.microkdehome"; |
1297 | #endif | 1299 | #endif |
1298 | KConfig cfg ( confFile ); | 1300 | KConfig cfg ( confFile ); |
1299 | cfg.setGroup("Global"); | 1301 | cfg.setGroup("Global"); |
1300 | localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" ); | 1302 | localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" ); |
1301 | #ifdef DESKTOP_VERSION | 1303 | #ifdef DESKTOP_VERSION |
1302 | if ( localKdeDir.startsWith( "LOCAL:" ) ) { | 1304 | if ( localKdeDir.startsWith( "LOCAL:" ) ) { |
1303 | #ifdef _WIN32_ | 1305 | #ifdef _WIN32_ |
1304 | localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 ); | 1306 | localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 ); |
1305 | #else | 1307 | #else |
1306 | localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 ); | 1308 | localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 ); |
1307 | #endif | 1309 | #endif |