author | ulf69 <ulf69> | 2004-06-29 05:35:06 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-06-29 05:35:06 (UTC) |
commit | b863f47dbb927a54f492b70ac59f3f99202dd7ca (patch) (unidiff) | |
tree | c5fffc44350972f0e7c963ea1ac98f2d5ce2dcfa | |
parent | ed68714fca68286417778f0f5378b9f65d4acaa3 (diff) | |
download | kdepimpi-b863f47dbb927a54f492b70ac59f3f99202dd7ca.zip kdepimpi-b863f47dbb927a54f492b70ac59f3f99202dd7ca.tar.gz kdepimpi-b863f47dbb927a54f492b70ac59f3f99202dd7ca.tar.bz2 |
added Qtopia as directory to search for libraries (Qtopia/libs)
-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 | |||
@@ -1,173 +1,174 @@ | |||
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 <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 |
62 | #include <qtextedit.h> | 63 | #include <qtextedit.h> |
63 | void ddd( QString op ) | 64 | void ddd( QString op ) |
64 | { | 65 | { |
65 | static QTextEdit * dot = 0; | 66 | static QTextEdit * dot = 0; |
66 | if ( ! dot ) | 67 | if ( ! dot ) |
67 | dot = new QTextEdit(); | 68 | dot = new QTextEdit(); |
68 | 69 | ||
69 | dot->show(); | 70 | dot->show(); |
70 | 71 | ||
71 | dot->append( op ); | 72 | dot->append( op ); |
72 | 73 | ||
73 | } | 74 | } |
74 | #endif | 75 | #endif |
75 | class KStandardDirs::KStandardDirsPrivate | 76 | class KStandardDirs::KStandardDirsPrivate |
76 | { | 77 | { |
77 | public: | 78 | public: |
78 | KStandardDirsPrivate() | 79 | KStandardDirsPrivate() |
79 | : restrictionsActive(false), | 80 | : restrictionsActive(false), |
80 | dataRestrictionActive(false) | 81 | dataRestrictionActive(false) |
81 | { } | 82 | { } |
82 | 83 | ||
83 | bool restrictionsActive; | 84 | bool restrictionsActive; |
84 | bool dataRestrictionActive; | 85 | bool dataRestrictionActive; |
85 | QAsciiDict<bool> restrictions; | 86 | QAsciiDict<bool> restrictions; |
86 | QStringList xdgdata_prefixes; | 87 | QStringList xdgdata_prefixes; |
87 | QStringList xdgconf_prefixes; | 88 | QStringList xdgconf_prefixes; |
88 | }; | 89 | }; |
89 | 90 | ||
90 | static const char* const types[] = {"html", "icon", "apps", "sound", | 91 | static const char* const types[] = {"html", "icon", "apps", "sound", |
91 | "data", "locale", "services", "mime", | 92 | "data", "locale", "services", "mime", |
92 | "servicetypes", "config", "exe", | 93 | "servicetypes", "config", "exe", |
93 | "wallpaper", "lib", "pixmap", "templates", | 94 | "wallpaper", "lib", "pixmap", "templates", |
94 | "module", "qtplugins", | 95 | "module", "qtplugins", |
95 | "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; | 96 | "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; |
96 | 97 | ||
97 | static int tokenize( QStringList& token, const QString& str, | 98 | static int tokenize( QStringList& token, const QString& str, |
98 | const QString& delim ); | 99 | const QString& delim ); |
99 | 100 | ||
100 | KStandardDirs::KStandardDirs( ) : addedCustoms(false) | 101 | KStandardDirs::KStandardDirs( ) : addedCustoms(false) |
101 | { | 102 | { |
102 | d = new KStandardDirsPrivate; | 103 | d = new KStandardDirsPrivate; |
103 | dircache.setAutoDelete(true); | 104 | dircache.setAutoDelete(true); |
104 | relatives.setAutoDelete(true); | 105 | relatives.setAutoDelete(true); |
105 | absolutes.setAutoDelete(true); | 106 | absolutes.setAutoDelete(true); |
106 | savelocations.setAutoDelete(true); | 107 | savelocations.setAutoDelete(true); |
107 | addKDEDefaults(); | 108 | addKDEDefaults(); |
108 | } | 109 | } |
109 | 110 | ||
110 | KStandardDirs::~KStandardDirs() | 111 | KStandardDirs::~KStandardDirs() |
111 | { | 112 | { |
112 | delete d; | 113 | delete d; |
113 | } | 114 | } |
114 | 115 | ||
115 | bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const | 116 | bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const |
116 | { | 117 | { |
117 | if (!d || !d->restrictionsActive) | 118 | if (!d || !d->restrictionsActive) |
118 | return false; | 119 | return false; |
119 | 120 | ||
120 | if (d->restrictions[type]) | 121 | if (d->restrictions[type]) |
121 | return true; | 122 | return true; |
122 | 123 | ||
123 | if (strcmp(type, "data")==0) | 124 | if (strcmp(type, "data")==0) |
124 | { | 125 | { |
125 | applyDataRestrictions(relPath); | 126 | applyDataRestrictions(relPath); |
126 | if (d->dataRestrictionActive) | 127 | if (d->dataRestrictionActive) |
127 | { | 128 | { |
128 | d->dataRestrictionActive = false; | 129 | d->dataRestrictionActive = false; |
129 | return true; | 130 | return true; |
130 | } | 131 | } |
131 | } | 132 | } |
132 | return false; | 133 | return false; |
133 | } | 134 | } |
134 | 135 | ||
135 | void KStandardDirs::applyDataRestrictions(const QString &relPath) const | 136 | void KStandardDirs::applyDataRestrictions(const QString &relPath) const |
136 | { | 137 | { |
137 | QString key; | 138 | QString key; |
138 | int i = relPath.find('/'); | 139 | int i = relPath.find('/'); |
139 | if (i != -1) | 140 | if (i != -1) |
140 | key = "data_"+relPath.left(i); | 141 | key = "data_"+relPath.left(i); |
141 | else | 142 | else |
142 | key = "data_"+relPath; | 143 | key = "data_"+relPath; |
143 | 144 | ||
144 | if (d && d->restrictions[key.latin1()]) | 145 | if (d && d->restrictions[key.latin1()]) |
145 | d->dataRestrictionActive = true; | 146 | d->dataRestrictionActive = true; |
146 | } | 147 | } |
147 | 148 | ||
148 | 149 | ||
149 | QStringList KStandardDirs::allTypes() const | 150 | QStringList KStandardDirs::allTypes() const |
150 | { | 151 | { |
151 | QStringList list; | 152 | QStringList list; |
152 | for (int i = 0; types[i] != 0; ++i) | 153 | for (int i = 0; types[i] != 0; ++i) |
153 | list.append(QString::fromLatin1(types[i])); | 154 | list.append(QString::fromLatin1(types[i])); |
154 | return list; | 155 | return list; |
155 | } | 156 | } |
156 | 157 | ||
157 | void KStandardDirs::addPrefix( const QString& _dir ) | 158 | void KStandardDirs::addPrefix( const QString& _dir ) |
158 | { | 159 | { |
159 | if (_dir.isNull()) | 160 | if (_dir.isNull()) |
160 | return; | 161 | return; |
161 | 162 | ||
162 | QString dir = _dir; | 163 | QString dir = _dir; |
163 | if (dir.at(dir.length() - 1) != '/') | 164 | if (dir.at(dir.length() - 1) != '/') |
164 | dir += '/'; | 165 | dir += '/'; |
165 | 166 | ||
166 | if (!prefixes.contains(dir)) { | 167 | if (!prefixes.contains(dir)) { |
167 | prefixes.append(dir); | 168 | prefixes.append(dir); |
168 | dircache.clear(); | 169 | dircache.clear(); |
169 | } | 170 | } |
170 | } | 171 | } |
171 | 172 | ||
172 | void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) | 173 | void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) |
173 | { | 174 | { |
@@ -225,303 +226,305 @@ bool KStandardDirs::addResourceType( const char *type, | |||
225 | return true; | 226 | return true; |
226 | } | 227 | } |
227 | return false; | 228 | return false; |
228 | } | 229 | } |
229 | 230 | ||
230 | bool KStandardDirs::addResourceDir( const char *type, | 231 | bool KStandardDirs::addResourceDir( const char *type, |
231 | const QString& absdir) | 232 | const QString& absdir) |
232 | { | 233 | { |
233 | QStringList *paths = absolutes.find(type); | 234 | QStringList *paths = absolutes.find(type); |
234 | if (!paths) { | 235 | if (!paths) { |
235 | paths = new QStringList(); | 236 | paths = new QStringList(); |
236 | absolutes.insert(type, paths); | 237 | absolutes.insert(type, paths); |
237 | } | 238 | } |
238 | QString copy = absdir; | 239 | QString copy = absdir; |
239 | if (copy.at(copy.length() - 1) != '/') | 240 | if (copy.at(copy.length() - 1) != '/') |
240 | copy += '/'; | 241 | copy += '/'; |
241 | 242 | ||
242 | if (!paths->contains(copy)) { | 243 | if (!paths->contains(copy)) { |
243 | paths->append(copy); | 244 | paths->append(copy); |
244 | dircache.remove(type); // clean the cache | 245 | dircache.remove(type); // clean the cache |
245 | return true; | 246 | return true; |
246 | } | 247 | } |
247 | return false; | 248 | return false; |
248 | } | 249 | } |
249 | 250 | ||
250 | QString KStandardDirs::findResource( const char *type, | 251 | QString KStandardDirs::findResource( const char *type, |
251 | const QString& filename ) const | 252 | const QString& filename ) const |
252 | { | 253 | { |
253 | if (filename.at(0) == '/') | 254 | if (filename.at(0) == '/') |
254 | return filename; // absolute dirs are absolute dirs, right? :-/ | 255 | return filename; // absolute dirs are absolute dirs, right? :-/ |
255 | 256 | ||
256 | #if 0 | 257 | #if 0 |
257 | kdDebug() << "Find resource: " << type << endl; | 258 | kdDebug() << "Find resource: " << type << endl; |
258 | for (QStringList::ConstIterator pit = prefixes.begin(); | 259 | for (QStringList::ConstIterator pit = prefixes.begin(); |
259 | pit != prefixes.end(); | 260 | pit != prefixes.end(); |
260 | pit++) | 261 | pit++) |
261 | { | 262 | { |
262 | kdDebug() << "Prefix: " << *pit << endl; | 263 | kdDebug() << "Prefix: " << *pit << endl; |
263 | } | 264 | } |
264 | #endif | 265 | #endif |
265 | 266 | ||
266 | QString dir = findResourceDir(type, filename); | 267 | QString dir = findResourceDir(type, filename); |
267 | if (dir.isNull()) | 268 | if (dir.isNull()) |
268 | return dir; | 269 | return dir; |
269 | else return dir + filename; | 270 | else return dir + filename; |
270 | } | 271 | } |
271 | /*US | 272 | /*US |
272 | static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash) | 273 | static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash) |
273 | { | 274 | { |
274 | QCString cFile = QFile::encodeName(file); | 275 | QCString cFile = QFile::encodeName(file); |
275 | //US struct stat buff; | 276 | //US struct stat buff; |
276 | //US if ((access(cFile, R_OK) == 0) && | 277 | //US if ((access(cFile, R_OK) == 0) && |
277 | //US (stat( cFile, &buff ) == 0) && | 278 | //US (stat( cFile, &buff ) == 0) && |
278 | //US (S_ISREG( buff.st_mode ))) | 279 | //US (S_ISREG( buff.st_mode ))) |
279 | QFileInfo pathfnInfo(cFile); | 280 | QFileInfo pathfnInfo(cFile); |
280 | if (( pathfnInfo.isReadable() == true ) && | 281 | if (( pathfnInfo.isReadable() == true ) && |
281 | ( pathfnInfo.isFile()) ) | 282 | ( pathfnInfo.isFile()) ) |
282 | { | 283 | { |
283 | //US hash = hash + (Q_UINT32) buff.st_ctime; | 284 | //US hash = hash + (Q_UINT32) buff.st_ctime; |
284 | hash = hash + (Q_UINT32) pathfnInfo.lastModified(); | 285 | hash = hash + (Q_UINT32) pathfnInfo.lastModified(); |
285 | } | 286 | } |
286 | return hash; | 287 | return hash; |
287 | } | 288 | } |
288 | */ | 289 | */ |
289 | /*US | 290 | /*US |
290 | Q_UINT32 KStandardDirs::calcResourceHash( const char *type, | 291 | Q_UINT32 KStandardDirs::calcResourceHash( const char *type, |
291 | const QString& filename, bool deep) const | 292 | const QString& filename, bool deep) const |
292 | { | 293 | { |
293 | Q_UINT32 hash = 0; | 294 | Q_UINT32 hash = 0; |
294 | 295 | ||
295 | if (filename.at(0) == '/') | 296 | if (filename.at(0) == '/') |
296 | { | 297 | { |
297 | // absolute dirs are absolute dirs, right? :-/ | 298 | // absolute dirs are absolute dirs, right? :-/ |
298 | return updateHash(filename, hash); | 299 | return updateHash(filename, hash); |
299 | } | 300 | } |
300 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) | 301 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) |
301 | applyDataRestrictions(filename); | 302 | applyDataRestrictions(filename); |
302 | QStringList candidates = resourceDirs(type); | 303 | QStringList candidates = resourceDirs(type); |
303 | QString fullPath; | 304 | QString fullPath; |
304 | 305 | ||
305 | for (QStringList::ConstIterator it = candidates.begin(); | 306 | for (QStringList::ConstIterator it = candidates.begin(); |
306 | it != candidates.end(); it++) | 307 | it != candidates.end(); it++) |
307 | { | 308 | { |
308 | hash = updateHash(*it + filename, hash); | 309 | hash = updateHash(*it + filename, hash); |
309 | if (!deep && hash) | 310 | if (!deep && hash) |
310 | return hash; | 311 | return hash; |
311 | } | 312 | } |
312 | return hash; | 313 | return hash; |
313 | } | 314 | } |
314 | */ | 315 | */ |
315 | 316 | ||
316 | QStringList KStandardDirs::findDirs( const char *type, | 317 | QStringList KStandardDirs::findDirs( const char *type, |
317 | const QString& reldir ) const | 318 | const QString& reldir ) const |
318 | { | 319 | { |
319 | QStringList list; | 320 | QStringList list; |
320 | 321 | ||
321 | checkConfig(); | 322 | checkConfig(); |
322 | 323 | ||
323 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) | 324 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) |
324 | applyDataRestrictions(reldir); | 325 | applyDataRestrictions(reldir); |
325 | QStringList candidates = resourceDirs(type); | 326 | QStringList candidates = resourceDirs(type); |
326 | QDir testdir; | 327 | QDir testdir; |
327 | 328 | ||
328 | for (QStringList::ConstIterator it = candidates.begin(); | 329 | for (QStringList::ConstIterator it = candidates.begin(); |
329 | it != candidates.end(); it++) { | 330 | it != candidates.end(); it++) { |
330 | testdir.setPath(*it + reldir); | 331 | testdir.setPath(*it + reldir); |
331 | if (testdir.exists()) | 332 | if (testdir.exists()) |
332 | list.append(testdir.absPath() + '/'); | 333 | list.append(testdir.absPath() + '/'); |
333 | } | 334 | } |
334 | 335 | ||
335 | return list; | 336 | return list; |
336 | } | 337 | } |
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()) |
373 | { | 375 | { |
374 | if (fullPath.at(fullPath.length() - 1) != '/') { | 376 | if (fullPath.at(fullPath.length() - 1) != '/') { |
375 | //US if (S_ISREG( buff.st_mode )) | 377 | //US if (S_ISREG( buff.st_mode )) |
376 | if (fullPathInfo.isFile()) | 378 | if (fullPathInfo.isFile()) |
377 | return true; | 379 | return true; |
378 | } | 380 | } |
379 | else { | 381 | else { |
380 | //US if (S_ISDIR( buff.st_mode )) | 382 | //US if (S_ISDIR( buff.st_mode )) |
381 | if (fullPathInfo.isDir()) | 383 | if (fullPathInfo.isDir()) |
382 | return true; | 384 | return true; |
383 | } | 385 | } |
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(); |
416 | QStringList::Iterator it = direntries.begin(); | 419 | QStringList::Iterator it = direntries.begin(); |
417 | 420 | ||
418 | while ( it != list.end() ) // for each file... | 421 | while ( it != list.end() ) // for each file... |
419 | { | 422 | { |
420 | 423 | ||
421 | //US QString fn( QFile::decodeName(ep->d_name)); | 424 | //US QString fn( QFile::decodeName(ep->d_name)); |
422 | QString fn = (*it); // dp.entryList already decodes | 425 | QString fn = (*it); // dp.entryList already decodes |
423 | it++; | 426 | it++; |
424 | if ( fn.isNull() ) | 427 | if ( fn.isNull() ) |
425 | break; | 428 | break; |
426 | 429 | ||
427 | if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) | 430 | if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) |
428 | continue; | 431 | continue; |
429 | 432 | ||
430 | /*US | 433 | /*US |
431 | if (!recursive && !regexp.exactMatch(fn)) | 434 | if (!recursive && !regexp.exactMatch(fn)) |
432 | continue; // No match | 435 | continue; // No match |
433 | */ | 436 | */ |
434 | //US this should do the same: | 437 | //US this should do the same: |
435 | int pos = regexp.match(fn); | 438 | int pos = regexp.match(fn); |
436 | if (!recursive && !pos == 0) | 439 | if (!recursive && !pos == 0) |
437 | continue; // No match | 440 | continue; // No match |
438 | 441 | ||
439 | QString pathfn = path + fn; | 442 | QString pathfn = path + fn; |
440 | /*US | 443 | /*US |
441 | if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { | 444 | if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { |
442 | kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; | 445 | kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; |
443 | continue; // Couldn't stat (e.g. no read permissions) | 446 | continue; // Couldn't stat (e.g. no read permissions) |
444 | } | 447 | } |
445 | 448 | ||
446 | if ( recursive ) | 449 | if ( recursive ) |
447 | { | 450 | { |
448 | if ( S_ISDIR( buff.st_mode )) { | 451 | if ( S_ISDIR( buff.st_mode )) { |
449 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); | 452 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); |
450 | } | 453 | } |
451 | */ | 454 | */ |
452 | //US replacement: | 455 | //US replacement: |
453 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); | 456 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); |
454 | if ( pathfnInfo.isReadable() == false ) | 457 | if ( pathfnInfo.isReadable() == false ) |
455 | { | 458 | { |
456 | //US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; | 459 | //US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; |
457 | continue; // Couldn't stat (e.g. no read permissions) | 460 | continue; // Couldn't stat (e.g. no read permissions) |
458 | } | 461 | } |
459 | 462 | ||
460 | if ( recursive ) | 463 | if ( recursive ) |
461 | { | 464 | { |
462 | if ( pathfnInfo.isDir()) { | 465 | if ( pathfnInfo.isDir()) { |
463 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); | 466 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); |
464 | } | 467 | } |
465 | 468 | ||
466 | 469 | ||
467 | /*US | 470 | /*US |
468 | if (!regexp.exactMatch(fn)) | 471 | if (!regexp.exactMatch(fn)) |
469 | continue; // No match | 472 | continue; // No match |
470 | */ | 473 | */ |
471 | //US this should do the same: | 474 | //US this should do the same: |
472 | pos = regexp.match(fn); | 475 | pos = regexp.match(fn); |
473 | if (!pos == 0) | 476 | if (!pos == 0) |
474 | continue; // No match | 477 | continue; // No match |
475 | } | 478 | } |
476 | 479 | ||
477 | //US if ( S_ISREG( buff.st_mode)) | 480 | //US if ( S_ISREG( buff.st_mode)) |
478 | if ( pathfnInfo.isFile()) | 481 | if ( pathfnInfo.isFile()) |
479 | { | 482 | { |
480 | if (!uniq || !relList.contains(relPart + fn)) | 483 | if (!uniq || !relList.contains(relPart + fn)) |
481 | { | 484 | { |
482 | list.append( pathfn ); | 485 | list.append( pathfn ); |
483 | relList.append( relPart + fn ); | 486 | relList.append( relPart + fn ); |
484 | } | 487 | } |
485 | } | 488 | } |
486 | } | 489 | } |
487 | //US closedir( dp ); | 490 | //US closedir( dp ); |
488 | } | 491 | } |
489 | else | 492 | else |
490 | { | 493 | { |
491 | // We look for a single file. | 494 | // We look for a single file. |
492 | QString fn = pattern; | 495 | QString fn = pattern; |
493 | QString pathfn = path + fn; | 496 | QString pathfn = path + fn; |
494 | //US struct stat buff; | 497 | //US struct stat buff; |
495 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); | 498 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); |
496 | 499 | ||
497 | 500 | ||
498 | //US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) | 501 | //US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) |
499 | if ( pathfnInfo.isReadable() == false ) | 502 | if ( pathfnInfo.isReadable() == false ) |
500 | return; // File not found | 503 | return; // File not found |
501 | 504 | ||
502 | //US if ( S_ISREG( buff.st_mode)) | 505 | //US if ( S_ISREG( buff.st_mode)) |
503 | if ( pathfnInfo.isFile()) | 506 | if ( pathfnInfo.isFile()) |
504 | { | 507 | { |
505 | if (!uniq || !relList.contains(relPart + fn)) | 508 | if (!uniq || !relList.contains(relPart + fn)) |
506 | { | 509 | { |
507 | list.append( pathfn ); | 510 | list.append( pathfn ); |
508 | relList.append( relPart + fn ); | 511 | relList.append( relPart + fn ); |
509 | } | 512 | } |
510 | } | 513 | } |
511 | } | 514 | } |
512 | } | 515 | } |
513 | 516 | ||
514 | static void lookupPrefix(const QString& prefix, const QString& relpath, | 517 | static void lookupPrefix(const QString& prefix, const QString& relpath, |
515 | const QString& relPart, | 518 | const QString& relPart, |
516 | const QRegExp ®exp, | 519 | const QRegExp ®exp, |
517 | QStringList& list, | 520 | QStringList& list, |
518 | QStringList& relList, | 521 | QStringList& relList, |
519 | bool recursive, bool uniq) | 522 | bool recursive, bool uniq) |
520 | { | 523 | { |
521 | if (relpath.isNull()) { | 524 | if (relpath.isNull()) { |
522 | lookupDirectory(prefix, relPart, regexp, list, | 525 | lookupDirectory(prefix, relPart, regexp, list, |
523 | relList, recursive, uniq); | 526 | relList, recursive, uniq); |
524 | return; | 527 | return; |
525 | } | 528 | } |
526 | QString path; | 529 | QString path; |
527 | QString rest; | 530 | QString rest; |
@@ -1096,256 +1099,258 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode) | |||
1096 | // bail out if we encountered a problem | 1099 | // bail out if we encountered a problem |
1097 | //US if (stat(baseEncoded, &st) != 0) | 1100 | //US if (stat(baseEncoded, &st) != 0) |
1098 | QFileInfo baseEncodedInfo(baseEncoded); | 1101 | QFileInfo baseEncodedInfo(baseEncoded); |
1099 | if (!baseEncodedInfo.exists()) | 1102 | if (!baseEncodedInfo.exists()) |
1100 | { | 1103 | { |
1101 | // Directory does not exist.... | 1104 | // Directory does not exist.... |
1102 | // Or maybe a dangling symlink ? | 1105 | // Or maybe a dangling symlink ? |
1103 | //US if (lstat(baseEncoded, &st) == 0) | 1106 | //US if (lstat(baseEncoded, &st) == 0) |
1104 | if (baseEncodedInfo.isSymLink()) { | 1107 | if (baseEncodedInfo.isSymLink()) { |
1105 | //US (void)unlink(baseEncoded); // try removing | 1108 | //US (void)unlink(baseEncoded); // try removing |
1106 | QFile(baseEncoded).remove(); | 1109 | QFile(baseEncoded).remove(); |
1107 | } | 1110 | } |
1108 | 1111 | ||
1109 | //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) | 1112 | //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) |
1110 | QDir dirObj; | 1113 | QDir dirObj; |
1111 | if ( dirObj.mkdir(baseEncoded) != true ) | 1114 | if ( dirObj.mkdir(baseEncoded) != true ) |
1112 | { | 1115 | { |
1113 | //US perror("trying to create local folder"); | 1116 | //US perror("trying to create local folder"); |
1114 | return false; // Couldn't create it :-( | 1117 | return false; // Couldn't create it :-( |
1115 | } | 1118 | } |
1116 | } | 1119 | } |
1117 | i = pos + 1; | 1120 | i = pos + 1; |
1118 | } | 1121 | } |
1119 | return true; | 1122 | return true; |
1120 | #endif | 1123 | #endif |
1121 | 1124 | ||
1122 | // ******************************************** | 1125 | // ******************************************** |
1123 | // new code for WIN32 | 1126 | // new code for WIN32 |
1124 | QDir dirObj; | 1127 | QDir dirObj; |
1125 | 1128 | ||
1126 | 1129 | ||
1127 | // we want an absolute path | 1130 | // we want an absolute path |
1128 | #ifndef _WIN32_ | 1131 | #ifndef _WIN32_ |
1129 | if (dir.at(0) != '/') | 1132 | if (dir.at(0) != '/') |
1130 | return false; | 1133 | return false; |
1131 | #endif | 1134 | #endif |
1132 | 1135 | ||
1133 | QString target = dir; | 1136 | QString target = dir; |
1134 | uint len = target.length(); | 1137 | uint len = target.length(); |
1135 | #ifndef _WIN32_ | 1138 | #ifndef _WIN32_ |
1136 | // append trailing slash if missing | 1139 | // append trailing slash if missing |
1137 | if (dir.at(len - 1) != '/') | 1140 | if (dir.at(len - 1) != '/') |
1138 | target += '/'; | 1141 | target += '/'; |
1139 | #endif | 1142 | #endif |
1140 | 1143 | ||
1141 | QString base(""); | 1144 | QString base(""); |
1142 | uint i = 1; | 1145 | uint i = 1; |
1143 | 1146 | ||
1144 | while( i < len ) | 1147 | while( i < len ) |
1145 | { | 1148 | { |
1146 | //US struct stat st; | 1149 | //US struct stat st; |
1147 | #ifndef _WIN32_ | 1150 | #ifndef _WIN32_ |
1148 | int pos = target.find('/', i); | 1151 | int pos = target.find('/', i); |
1149 | #else | 1152 | #else |
1150 | int pos = target.find('\\', i); | 1153 | int pos = target.find('\\', i); |
1151 | #endif | 1154 | #endif |
1152 | if ( pos < 0 ) | 1155 | if ( pos < 0 ) |
1153 | return true; | 1156 | return true; |
1154 | base += target.mid(i - 1, pos - i + 1); | 1157 | base += target.mid(i - 1, pos - i + 1); |
1155 | //QMessageBox::information( 0,"cap111", base, 1 ); | 1158 | //QMessageBox::information( 0,"cap111", base, 1 ); |
1156 | /*US | 1159 | /*US |
1157 | QCString baseEncoded = QFile::encodeName(base); | 1160 | QCString baseEncoded = QFile::encodeName(base); |
1158 | // bail out if we encountered a problem | 1161 | // bail out if we encountered a problem |
1159 | if (stat(baseEncoded, &st) != 0) | 1162 | if (stat(baseEncoded, &st) != 0) |
1160 | { | 1163 | { |
1161 | // Directory does not exist.... | 1164 | // Directory does not exist.... |
1162 | // Or maybe a dangling symlink ? | 1165 | // Or maybe a dangling symlink ? |
1163 | if (lstat(baseEncoded, &st) == 0) | 1166 | if (lstat(baseEncoded, &st) == 0) |
1164 | (void)unlink(baseEncoded); // try removing | 1167 | (void)unlink(baseEncoded); // try removing |
1165 | 1168 | ||
1166 | 1169 | ||
1167 | if ( mkdir(baseEncoded, (mode_t) mode) != 0) { | 1170 | if ( mkdir(baseEncoded, (mode_t) mode) != 0) { |
1168 | perror("trying to create local folder"); | 1171 | perror("trying to create local folder"); |
1169 | return false; // Couldn't create it :-( | 1172 | return false; // Couldn't create it :-( |
1170 | } | 1173 | } |
1171 | } | 1174 | } |
1172 | */ | 1175 | */ |
1173 | 1176 | ||
1174 | if (dirObj.exists(base) == false) | 1177 | if (dirObj.exists(base) == false) |
1175 | { | 1178 | { |
1176 | //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); | 1179 | //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); |
1177 | if (dirObj.mkdir(base) != true) | 1180 | if (dirObj.mkdir(base) != true) |
1178 | { | 1181 | { |
1179 | qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); | 1182 | qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); |
1180 | return false; | 1183 | return false; |
1181 | } | 1184 | } |
1182 | } | 1185 | } |
1183 | 1186 | ||
1184 | i = pos + 1; | 1187 | i = pos + 1; |
1185 | } | 1188 | } |
1186 | return true; | 1189 | return true; |
1187 | 1190 | ||
1188 | } | 1191 | } |
1189 | 1192 | ||
1190 | static QString readEnvPath(const char *env) | 1193 | static QString readEnvPath(const char *env) |
1191 | { | 1194 | { |
1192 | #ifdef _WIN32_ | 1195 | #ifdef _WIN32_ |
1193 | return ""; | 1196 | return ""; |
1194 | #else | 1197 | #else |
1195 | QCString c_path = getenv(env); | 1198 | QCString c_path = getenv(env); |
1196 | if (c_path.isEmpty()) | 1199 | if (c_path.isEmpty()) |
1197 | return QString::null; | 1200 | return QString::null; |
1198 | return QFile::decodeName(c_path); | 1201 | return QFile::decodeName(c_path); |
1199 | #endif | 1202 | #endif |
1200 | } | 1203 | } |
1201 | 1204 | ||
1202 | void KStandardDirs::addKDEDefaults() | 1205 | void KStandardDirs::addKDEDefaults() |
1203 | { | 1206 | { |
1204 | //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); | 1207 | //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); |
1205 | //return; | 1208 | //return; |
1206 | QStringList kdedirList; | 1209 | QStringList kdedirList; |
1207 | 1210 | ||
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) != '/') |
1240 | localKdeDir += '/'; | 1245 | localKdeDir += '/'; |
1241 | } | 1246 | } |
1242 | else | 1247 | else |
1243 | { | 1248 | { |
1244 | localKdeDir = QDir::homeDirPath() + "/kdepim/"; | 1249 | localKdeDir = QDir::homeDirPath() + "/kdepim/"; |
1245 | } | 1250 | } |
1246 | } | 1251 | } |
1247 | else | 1252 | else |
1248 | { | 1253 | { |
1249 | // We treat root different to prevent root messing up the | 1254 | // We treat root different to prevent root messing up the |
1250 | // file permissions in the users home directory. | 1255 | // file permissions in the users home directory. |
1251 | localKdeDir = readEnvPath("MICROKDEROOTHOME"); | 1256 | localKdeDir = readEnvPath("MICROKDEROOTHOME"); |
1252 | if (!localKdeDir.isEmpty()) | 1257 | if (!localKdeDir.isEmpty()) |
1253 | { | 1258 | { |
1254 | if (localKdeDir.at(localKdeDir.length()-1) != '/') | 1259 | if (localKdeDir.at(localKdeDir.length()-1) != '/') |
1255 | localKdeDir += '/'; | 1260 | localKdeDir += '/'; |
1256 | } | 1261 | } |
1257 | else | 1262 | else |
1258 | { | 1263 | { |
1259 | //US struct passwd *pw = getpwuid(0); | 1264 | //US struct passwd *pw = getpwuid(0); |
1260 | //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; | 1265 | //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; |
1261 | qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); | 1266 | qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); |
1262 | } | 1267 | } |
1263 | 1268 | ||
1264 | } | 1269 | } |
1265 | 1270 | ||
1266 | //US localKdeDir = appDir(); | 1271 | //US localKdeDir = appDir(); |
1267 | 1272 | ||
1268 | //US | 1273 | //US |
1269 | // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); | 1274 | // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); |
1270 | if (localKdeDir != "-/") | 1275 | if (localKdeDir != "-/") |
1271 | { | 1276 | { |
1272 | localKdeDir = KShell::tildeExpand(localKdeDir); | 1277 | localKdeDir = KShell::tildeExpand(localKdeDir); |
1273 | addPrefix(localKdeDir); | 1278 | addPrefix(localKdeDir); |
1274 | } | 1279 | } |
1275 | 1280 | ||
1276 | for (QStringList::ConstIterator it = kdedirList.begin(); | 1281 | for (QStringList::ConstIterator it = kdedirList.begin(); |
1277 | it != kdedirList.end(); it++) | 1282 | it != kdedirList.end(); it++) |
1278 | { | 1283 | { |
1279 | QString dir = KShell::tildeExpand(*it); | 1284 | QString dir = KShell::tildeExpand(*it); |
1280 | addPrefix(dir); | 1285 | addPrefix(dir); |
1281 | } | 1286 | } |
1282 | // end KDEDIRS | 1287 | // end KDEDIRS |
1283 | 1288 | ||
1284 | // begin XDG_CONFIG_XXX | 1289 | // begin XDG_CONFIG_XXX |
1285 | QStringList xdgdirList; | 1290 | QStringList xdgdirList; |
1286 | QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); | 1291 | QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); |
1287 | if (!xdgdirs.isEmpty()) | 1292 | if (!xdgdirs.isEmpty()) |
1288 | { | 1293 | { |
1289 | tokenize(xdgdirList, xdgdirs, ":"); | 1294 | tokenize(xdgdirList, xdgdirs, ":"); |
1290 | } | 1295 | } |
1291 | else | 1296 | else |
1292 | { | 1297 | { |
1293 | xdgdirList.clear(); | 1298 | xdgdirList.clear(); |
1294 | xdgdirList.append("/etc/xdg"); | 1299 | xdgdirList.append("/etc/xdg"); |
1295 | } | 1300 | } |
1296 | 1301 | ||
1297 | QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); | 1302 | QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); |
1298 | if (!localXdgDir.isEmpty()) | 1303 | if (!localXdgDir.isEmpty()) |
1299 | { | 1304 | { |
1300 | if (localXdgDir.at(localXdgDir.length()-1) != '/') | 1305 | if (localXdgDir.at(localXdgDir.length()-1) != '/') |
1301 | localXdgDir += '/'; | 1306 | localXdgDir += '/'; |
1302 | } | 1307 | } |
1303 | else | 1308 | else |
1304 | { | 1309 | { |
1305 | //US if (getuid()) | 1310 | //US if (getuid()) |
1306 | if (true) | 1311 | if (true) |
1307 | { | 1312 | { |
1308 | localXdgDir = QDir::homeDirPath() + "/.config/"; | 1313 | localXdgDir = QDir::homeDirPath() + "/.config/"; |
1309 | } | 1314 | } |
1310 | else | 1315 | else |
1311 | { | 1316 | { |
1312 | //US struct passwd *pw = getpwuid(0); | 1317 | //US struct passwd *pw = getpwuid(0); |
1313 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; | 1318 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; |
1314 | qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); | 1319 | qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); |
1315 | } | 1320 | } |
1316 | } | 1321 | } |
1317 | 1322 | ||
1318 | localXdgDir = KShell::tildeExpand(localXdgDir); | 1323 | localXdgDir = KShell::tildeExpand(localXdgDir); |
1319 | addXdgConfigPrefix(localXdgDir); | 1324 | addXdgConfigPrefix(localXdgDir); |
1320 | 1325 | ||
1321 | for (QStringList::ConstIterator it = xdgdirList.begin(); | 1326 | for (QStringList::ConstIterator it = xdgdirList.begin(); |
1322 | it != xdgdirList.end(); it++) | 1327 | it != xdgdirList.end(); it++) |
1323 | { | 1328 | { |
1324 | QString dir = KShell::tildeExpand(*it); | 1329 | QString dir = KShell::tildeExpand(*it); |
1325 | addXdgConfigPrefix(dir); | 1330 | addXdgConfigPrefix(dir); |
1326 | } | 1331 | } |
1327 | // end XDG_CONFIG_XXX | 1332 | // end XDG_CONFIG_XXX |
1328 | 1333 | ||
1329 | // begin XDG_DATA_XXX | 1334 | // begin XDG_DATA_XXX |
1330 | xdgdirs = readEnvPath("XDG_DATA_DIRS"); | 1335 | xdgdirs = readEnvPath("XDG_DATA_DIRS"); |
1331 | if (!xdgdirs.isEmpty()) | 1336 | if (!xdgdirs.isEmpty()) |
1332 | { | 1337 | { |
1333 | tokenize(xdgdirList, xdgdirs, ":"); | 1338 | tokenize(xdgdirList, xdgdirs, ":"); |
1334 | } | 1339 | } |
1335 | else | 1340 | else |
1336 | { | 1341 | { |
1337 | xdgdirList.clear(); | 1342 | xdgdirList.clear(); |
1338 | for (QStringList::ConstIterator it = kdedirList.begin(); | 1343 | for (QStringList::ConstIterator it = kdedirList.begin(); |
1339 | it != kdedirList.end(); it++) | 1344 | it != kdedirList.end(); it++) |
1340 | { | 1345 | { |
1341 | QString dir = *it; | 1346 | QString dir = *it; |
1342 | if (dir.at(dir.length()-1) != '/') | 1347 | if (dir.at(dir.length()-1) != '/') |
1343 | dir += '/'; | 1348 | dir += '/'; |
1344 | xdgdirList.append(dir+"share/"); | 1349 | xdgdirList.append(dir+"share/"); |
1345 | } | 1350 | } |
1346 | 1351 | ||
1347 | xdgdirList.append("/usr/local/share/"); | 1352 | xdgdirList.append("/usr/local/share/"); |
1348 | xdgdirList.append("/usr/share/"); | 1353 | xdgdirList.append("/usr/share/"); |
1349 | } | 1354 | } |
1350 | 1355 | ||
1351 | localXdgDir = readEnvPath("XDG_DATA_HOME"); | 1356 | localXdgDir = readEnvPath("XDG_DATA_HOME"); |