summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore/kstandarddirs.cpp
Unidiff
Diffstat (limited to 'microkde/kdecore/kstandarddirs.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/kstandarddirs.cpp24
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,136 +1,138 @@
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
59QString KStandardDirs::mAppDir = QString::null; 61QString KStandardDirs::mAppDir = QString::null;
60 62
61 63
62template class QDict<QStringList>; 64template class Q3Dict<QStringList>;
63 65
64#if 0 66#if 0
65#include <qtextedit.h> 67#include <q3textedit.h>
66void ddd( QString op ) 68void 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
78class KStandardDirs::KStandardDirsPrivate 80class KStandardDirs::KStandardDirsPrivate
79{ 81{
80public: 82public:
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
93static const char* const types[] = {"html", "icon", "apps", "sound", 95static 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
100static int tokenize( QStringList& token, const QString& str, 102static int tokenize( QStringList& token, const QString& str,
101 const QString& delim ); 103 const QString& delim );
102 104
103KStandardDirs::KStandardDirs( ) : addedCustoms(false) 105KStandardDirs::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
113KStandardDirs::~KStandardDirs() 115KStandardDirs::~KStandardDirs()
114{ 116{
115 delete d; 117 delete d;
116} 118}
117 119
118bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const 120bool 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}
@@ -400,134 +402,134 @@ bool KStandardDirs::exists(const QString &fullPath)
400static void lookupDirectory(const QString& path, const QString &relPart, 402static void lookupDirectory(const QString& path, const QString &relPart,
401 const QRegExp &regexp, 403 const QRegExp &regexp,
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
527static void lookupPrefix(const QString& prefix, const QString& relpath, 529static void lookupPrefix(const QString& prefix, const QString& relpath,
528 const QString& relPart, 530 const QString& relPart,
529 const QRegExp &regexp, 531 const QRegExp &regexp,
530 QStringList& list, 532 QStringList& list,
531 QStringList& relList, 533 QStringList& relList,
532 bool recursive, bool uniq) 534 bool recursive, bool uniq)
533{ 535{
@@ -1063,97 +1065,97 @@ QString KStandardDirs::saveLocation(const char *type,
1063 1065
1064QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) 1066QString 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
1086bool KStandardDirs::makeDir(const QString& dir2, int mode) 1088bool 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
@@ -1163,97 +1165,97 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode)
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
1206QString readEnvPath(const char *env) 1208QString 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
1221void KStandardDirs::addKDEDefaults() 1223void 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