summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-08-05 21:42:29 (UTC)
committer ulf69 <ulf69>2004-08-05 21:42:29 (UTC)
commit6ee7d4f5119837f89ec534c8c5c73845d521e135 (patch) (unidiff)
tree265d25e37da63a00ae3302059c2c628efb57b570
parentc3a704f5acda9cf9fee66e5c0b1b864f3b7dd852 (diff)
downloadkdepimpi-6ee7d4f5119837f89ec534c8c5c73845d521e135.zip
kdepimpi-6ee7d4f5119837f89ec534c8c5c73845d521e135.tar.gz
kdepimpi-6ee7d4f5119837f89ec534c8c5c73845d521e135.tar.bz2
added tmp as a resourcetype. KDE handled tmp differently, but we do not need
the special handling. So i simply added it as standard resource type
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/kstandarddirs.cpp146
1 files changed, 73 insertions, 73 deletions
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp
index e1c78f6..75205d6 100644
--- a/microkde/kdecore/kstandarddirs.cpp
+++ b/microkde/kdecore/kstandarddirs.cpp
@@ -59,16 +59,16 @@ QString KStandardDirs::mAppDir = QString::null;
59 59
60 60
61template class QDict<QStringList>; 61template class QDict<QStringList>;
62 62
63#if 0 63#if 0
64#include <qtextedit.h> 64#include <qtextedit.h>
65void ddd( QString op ) 65void ddd( QString op )
66{ 66{
67 static QTextEdit * dot = 0; 67 static QTextEdit * dot = 0;
68 if ( ! dot ) 68 if ( ! dot )
69 dot = new QTextEdit(); 69 dot = new QTextEdit();
70 70
71 dot->show(); 71 dot->show();
72 72
73 dot->append( op ); 73 dot->append( op );
74 74
@@ -88,15 +88,15 @@ public:
88 QStringList xdgdata_prefixes; 88 QStringList xdgdata_prefixes;
89 QStringList xdgconf_prefixes; 89 QStringList xdgconf_prefixes;
90}; 90};
91 91
92static const char* const types[] = {"html", "icon", "apps", "sound", 92static const char* const types[] = {"html", "icon", "apps", "sound",
93 "data", "locale", "services", "mime", 93 "data", "locale", "services", "mime",
94 "servicetypes", "config", "exe", 94 "servicetypes", "config", "exe", "tmp",
95 "wallpaper", "lib", "pixmap", "templates", 95 "wallpaper", "lib", "pixmap", "templates",
96 "module", "qtplugins", 96 "module", "qtplugins",
97 "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; 97 "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 };
98 98
99static int tokenize( QStringList& token, const QString& str, 99static int tokenize( QStringList& token, const QString& str,
100 const QString& delim ); 100 const QString& delim );
101 101
102KStandardDirs::KStandardDirs( ) : addedCustoms(false) 102KStandardDirs::KStandardDirs( ) : addedCustoms(false)
@@ -355,44 +355,44 @@ QString KStandardDirs::findResourceDir( const char *type,
355#ifdef _WIN32_ 355#ifdef _WIN32_
356 candidates.prepend( qApp->applicationDirPath () +"\\"); 356 candidates.prepend( qApp->applicationDirPath () +"\\");
357#else 357#else
358 candidates.prepend( qApp->applicationDirPath () +"/"); 358 candidates.prepend( qApp->applicationDirPath () +"/");
359#endif 359#endif
360#endif 360#endif
361 for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) 361 for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++)
362 { 362 {
363 //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1()); 363 //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1());
364 if (exists(*it + filename)) 364 if (exists(*it + filename))
365 return *it; 365 return *it;
366 } 366 }
367 367
368#ifndef NDEBUG 368#ifndef NDEBUG
369 if(false && type != "locale") 369 if(false && type != "locale")
370 qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1()); 370 qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1());
371 371
372#endif 372#endif
373 373
374 return QString::null; 374 return QString::null;
375} 375}
376 376
377bool KStandardDirs::exists(const QString &fullPath) 377bool KStandardDirs::exists(const QString &fullPath)
378{ 378{
379//US struct stat buff; 379//US struct stat buff;
380 QFileInfo fullPathInfo(QFile::encodeName(fullPath)); 380 QFileInfo fullPathInfo(QFile::encodeName(fullPath));
381 381
382//US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) 382//US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable())
383 if (fullPathInfo.isReadable()) 383 if (fullPathInfo.isReadable())
384 { 384 {
385 if (fullPath.at(fullPath.length() - 1) != '/') { 385 if (fullPath.at(fullPath.length() - 1) != '/') {
386 //US if (S_ISREG( buff.st_mode )) 386 //US if (S_ISREG( buff.st_mode ))
387 if (fullPathInfo.isFile()) 387 if (fullPathInfo.isFile())
388 return true; 388 return true;
389 } 389 }
390 else { 390 else {
391 //US if (S_ISDIR( buff.st_mode )) 391 //US if (S_ISDIR( buff.st_mode ))
392 if (fullPathInfo.isDir()) 392 if (fullPathInfo.isDir())
393 return true; 393 return true;
394 } 394 }
395 } 395 }
396 return false; 396 return false;
397} 397}
398 398
@@ -405,13 +405,13 @@ static void lookupDirectory(const QString& path, const QString &relPart,
405 QString pattern = regexp.pattern(); 405 QString pattern = regexp.pattern();
406 if (recursive || pattern.contains('?') || pattern.contains('*')) 406 if (recursive || pattern.contains('?') || pattern.contains('*'))
407 { 407 {
408 // We look for a set of files. 408 // We look for a set of files.
409//US DIR *dp = opendir( QFile::encodeName(path)); 409//US DIR *dp = opendir( QFile::encodeName(path));
410 QDir dp(QFile::encodeName(path)); 410 QDir dp(QFile::encodeName(path));
411 411
412 if (!dp.exists()) 412 if (!dp.exists())
413 return; 413 return;
414 static int iii = 0; 414 static int iii = 0;
415 ++iii; 415 ++iii;
416 if ( iii == 5 ) 416 if ( iii == 5 )
417 abort(); 417 abort();
@@ -423,22 +423,22 @@ static void lookupDirectory(const QString& path, const QString &relPart,
423 QString _dot("."); 423 QString _dot(".");
424 QString _dotdot(".."); 424 QString _dotdot("..");
425 425
426//US while( ( ep = readdir( dp ) ) != 0L ) 426//US while( ( ep = readdir( dp ) ) != 0L )
427 QStringList direntries = dp.entryList(); 427 QStringList direntries = dp.entryList();
428 QStringList::Iterator it = direntries.begin(); 428 QStringList::Iterator it = direntries.begin();
429 429
430 while ( it != list.end() ) // for each file... 430 while ( it != list.end() ) // for each file...
431 { 431 {
432 432
433//US QString fn( QFile::decodeName(ep->d_name)); 433//US QString fn( QFile::decodeName(ep->d_name));
434 QString fn = (*it); // dp.entryList already decodes 434 QString fn = (*it); // dp.entryList already decodes
435 it++; 435 it++;
436 if ( fn.isNull() ) 436 if ( fn.isNull() )
437 break; 437 break;
438 438
439 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) 439 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' )
440 continue; 440 continue;
441 441
442/*US 442/*US
443 if (!recursive && !regexp.exactMatch(fn)) 443 if (!recursive && !regexp.exactMatch(fn))
444 continue; // No match 444 continue; // No match
@@ -446,40 +446,40 @@ static void lookupDirectory(const QString& path, const QString &relPart,
446//US this should do the same: 446//US this should do the same:
447 int pos = regexp.match(fn); 447 int pos = regexp.match(fn);
448 if (!recursive && !pos == 0) 448 if (!recursive && !pos == 0)
449 continue; // No match 449 continue; // No match
450 450
451 QString pathfn = path + fn; 451 QString pathfn = path + fn;
452/*US 452/*US
453 if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { 453 if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) {
454 kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; 454 kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl;
455 continue; // Couldn't stat (e.g. no read permissions) 455 continue; // Couldn't stat (e.g. no read permissions)
456 } 456 }
457 457
458 if ( recursive ) 458 if ( recursive )
459 { 459 {
460 if ( S_ISDIR( buff.st_mode )) { 460 if ( S_ISDIR( buff.st_mode )) {
461 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); 461 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq);
462 } 462 }
463*/ 463*/
464//US replacement: 464//US replacement:
465 QFileInfo pathfnInfo(QFile::encodeName(pathfn)); 465 QFileInfo pathfnInfo(QFile::encodeName(pathfn));
466 if ( pathfnInfo.isReadable() == false ) 466 if ( pathfnInfo.isReadable() == false )
467 { 467 {
468//US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; 468//US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl;
469 continue; // Couldn't stat (e.g. no read permissions) 469 continue; // Couldn't stat (e.g. no read permissions)
470 } 470 }
471 471
472 if ( recursive ) 472 if ( recursive )
473 { 473 {
474 if ( pathfnInfo.isDir()) { 474 if ( pathfnInfo.isDir()) {
475 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); 475 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq);
476 } 476 }
477 477
478 478
479/*US 479/*US
480 if (!regexp.exactMatch(fn)) 480 if (!regexp.exactMatch(fn))
481 continue; // No match 481 continue; // No match
482*/ 482*/
483//US this should do the same: 483//US this should do the same:
484 pos = regexp.match(fn); 484 pos = regexp.match(fn);
485 if (!pos == 0) 485 if (!pos == 0)
@@ -507,13 +507,13 @@ static void lookupDirectory(const QString& path, const QString &relPart,
507 QFileInfo pathfnInfo(QFile::encodeName(pathfn)); 507 QFileInfo pathfnInfo(QFile::encodeName(pathfn));
508 508
509 509
510//US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) 510//US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 )
511 if ( pathfnInfo.isReadable() == false ) 511 if ( pathfnInfo.isReadable() == false )
512 return; // File not found 512 return; // File not found
513 513
514//US if ( S_ISREG( buff.st_mode)) 514//US if ( S_ISREG( buff.st_mode))
515 if ( pathfnInfo.isFile()) 515 if ( pathfnInfo.isFile())
516 { 516 {
517 if (!uniq || !relList.contains(relPart + fn)) 517 if (!uniq || !relList.contains(relPart + fn))
518 { 518 {
519 list.append( pathfn ); 519 list.append( pathfn );
@@ -553,14 +553,14 @@ static void lookupPrefix(const QString& prefix, const QString& relpath,
553//US struct stat buff; 553//US struct stat buff;
554 554
555 if (path.contains('*') || path.contains('?')) { 555 if (path.contains('*') || path.contains('?')) {
556 QRegExp pathExp(path, true, true); 556 QRegExp pathExp(path, true, true);
557 //USDIR *dp = opendir( QFile::encodeName(prefix) ); 557 //USDIR *dp = opendir( QFile::encodeName(prefix) );
558 QDir dp(QFile::encodeName(prefix)); 558 QDir dp(QFile::encodeName(prefix));
559 559
560 //USif (!dp) 560 //USif (!dp)
561 if (!dp.exists()) 561 if (!dp.exists())
562 { 562 {
563 return; 563 return;
564 } 564 }
565 565
566 //USstruct dirent *ep; 566 //USstruct dirent *ep;
@@ -568,19 +568,19 @@ static void lookupPrefix(const QString& prefix, const QString& relpath,
568 QString _dot("."); 568 QString _dot(".");
569 QString _dotdot(".."); 569 QString _dotdot("..");
570 570
571 //USwhile( ( ep = readdir( dp ) ) != 0L ) 571 //USwhile( ( ep = readdir( dp ) ) != 0L )
572 QStringList direntries = dp.entryList(); 572 QStringList direntries = dp.entryList();
573 QStringList::Iterator it = direntries.begin(); 573 QStringList::Iterator it = direntries.begin();
574 574
575 while ( it != list.end() ) // for each file... 575 while ( it != list.end() ) // for each file...
576 { 576 {
577//US QString fn( QFile::decodeName(ep->d_name)); 577//US QString fn( QFile::decodeName(ep->d_name));
578 QString fn = (*it); // dp.entryList() already encodes the strings 578 QString fn = (*it); // dp.entryList() already encodes the strings
579 it++; 579 it++;
580 580
581 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~') 581 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~')
582 continue; 582 continue;
583 583
584#ifdef DESKTOP_VERSION 584#ifdef DESKTOP_VERSION
585 585
586 if (pathExp.search(fn) == -1) 586 if (pathExp.search(fn) == -1)
@@ -599,13 +599,13 @@ static void lookupPrefix(const QString& prefix, const QString& relpath,
599 { 599 {
600//US kdDebug() << "Error statting " << fn << " : " << perror << endl; 600//US kdDebug() << "Error statting " << fn << " : " << perror << endl;
601 continue; // Couldn't stat (e.g. no permissions) 601 continue; // Couldn't stat (e.g. no permissions)
602 } 602 }
603 //US if ( S_ISDIR( buff.st_mode )) 603 //US if ( S_ISDIR( buff.st_mode ))
604 if ( fnInfo.isDir() ) 604 if ( fnInfo.isDir() )
605 605
606 lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq); 606 lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq);
607 } 607 }
608 608
609 //USclosedir( dp ); 609 //USclosedir( dp );
610 } else { 610 } else {
611 // Don't stat, if the dir doesn't exist we will find out 611 // Don't stat, if the dir doesn't exist we will find out
@@ -668,13 +668,13 @@ KStandardDirs::findAllResources( const char *type,
668 bool uniq) const 668 bool uniq) const
669{ 669{
670 QStringList relList; 670 QStringList relList;
671 return findAllResources(type, filter, recursive, uniq, relList); 671 return findAllResources(type, filter, recursive, uniq, relList);
672} 672}
673 673
674QString 674QString
675KStandardDirs::realPath(const QString &dirname) 675KStandardDirs::realPath(const QString &dirname)
676{ 676{
677#ifdef _WIN32_ 677#ifdef _WIN32_
678 return dirname; 678 return dirname;
679#else 679#else
680//US char realpath_buffer[MAXPATHLEN + 1]; 680//US char realpath_buffer[MAXPATHLEN + 1];
@@ -729,13 +729,13 @@ void KStandardDirs::createSpecialResource(const char *type)
729 729
730QStringList KStandardDirs::resourceDirs(const char *type) const 730QStringList KStandardDirs::resourceDirs(const char *type) const
731{ 731{
732 QStringList *candidates = dircache.find(type); 732 QStringList *candidates = dircache.find(type);
733 733
734 if (!candidates) { // filling cache 734 if (!candidates) { // filling cache
735/*US 735/*US
736 if (strcmp(type, "socket") == 0) 736 if (strcmp(type, "socket") == 0)
737 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 737 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
738 else if (strcmp(type, "tmp") == 0) 738 else if (strcmp(type, "tmp") == 0)
739 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 739 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
740 else if (strcmp(type, "cache") == 0) 740 else if (strcmp(type, "cache") == 0)
741 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 741 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
@@ -765,13 +765,13 @@ QStringList KStandardDirs::resourceDirs(const char *type) const
765 if (strncmp(type, "xdgdata-", 8) == 0) 765 if (strncmp(type, "xdgdata-", 8) == 0)
766 prefixList = &(d->xdgdata_prefixes); 766 prefixList = &(d->xdgdata_prefixes);
767 else if (strncmp(type, "xdgconf-", 8) == 0) 767 else if (strncmp(type, "xdgconf-", 8) == 0)
768 prefixList = &(d->xdgconf_prefixes); 768 prefixList = &(d->xdgconf_prefixes);
769 else 769 else
770 prefixList = &prefixes; 770 prefixList = &prefixes;
771 771
772 for (QStringList::ConstIterator pit = prefixList->begin(); 772 for (QStringList::ConstIterator pit = prefixList->begin();
773 pit != prefixList->end(); 773 pit != prefixList->end();
774 pit++) 774 pit++)
775 { 775 {
776 for (QStringList::ConstIterator it = dirs->begin(); 776 for (QStringList::ConstIterator it = dirs->begin();
777 it != dirs->end(); ++it) { 777 it != dirs->end(); ++it) {
@@ -832,13 +832,13 @@ QString KStandardDirs::findExe( const QString& appname,
832 return QString::null; 832 return QString::null;
833 } 833 }
834 834
835//US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname); 835//US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname);
836 QString p = QString("%1/%2").arg(appname).arg(appname); 836 QString p = QString("%1/%2").arg(appname).arg(appname);
837 qDebug("KStandardDirs::findExe this is probably wrong"); 837 qDebug("KStandardDirs::findExe this is probably wrong");
838 838
839 info.setFile( p ); 839 info.setFile( p );
840 if( info.exists() && ( ignore || info.isExecutable() ) 840 if( info.exists() && ( ignore || info.isExecutable() )
841 && ( info.isFile() || info.isSymLink() ) ) { 841 && ( info.isFile() || info.isSymLink() ) ) {
842 return p; 842 return p;
843 } 843 }
844 844
@@ -1004,13 +1004,13 @@ QString KStandardDirs::saveLocation(const char *type,
1004 1004
1005 QString *pPath = savelocations.find(type); 1005 QString *pPath = savelocations.find(type);
1006 if (!pPath) 1006 if (!pPath)
1007 { 1007 {
1008 QStringList *dirs = relatives.find(type); 1008 QStringList *dirs = relatives.find(type);
1009 if (!dirs && ( 1009 if (!dirs && (
1010 (strcmp(type, "socket") == 0) || 1010 (strcmp(type, "socket") == 0) ||
1011 (strcmp(type, "tmp") == 0) || 1011 (strcmp(type, "tmp") == 0) ||
1012 (strcmp(type, "cache") == 0) )) 1012 (strcmp(type, "cache") == 0) ))
1013 { 1013 {
1014 (void) resourceDirs(type); // Generate socket|tmp|cache resource. 1014 (void) resourceDirs(type); // Generate socket|tmp|cache resource.
1015 dirs = relatives.find(type); // Search again. 1015 dirs = relatives.find(type); // Search again.
1016 } 1016 }
@@ -1027,23 +1027,23 @@ QString KStandardDirs::saveLocation(const char *type,
1027 else { 1027 else {
1028 dirs = absolutes.find(type); 1028 dirs = absolutes.find(type);
1029 if (!dirs) 1029 if (!dirs)
1030 qFatal("KStandardDirs: The resource type %s is not registered", type); 1030 qFatal("KStandardDirs: The resource type %s is not registered", type);
1031 pPath = new QString(realPath(dirs->last())); 1031 pPath = new QString(realPath(dirs->last()));
1032 } 1032 }
1033 1033
1034 savelocations.insert(type, pPath); 1034 savelocations.insert(type, pPath);
1035 } 1035 }
1036 1036
1037 QString fullPath = *pPath + suffix; 1037 QString fullPath = *pPath + suffix;
1038//US struct stat st; 1038//US struct stat st;
1039//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) 1039//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode)))
1040 QFileInfo fullPathInfo(QFile::encodeName(fullPath)); 1040 QFileInfo fullPathInfo(QFile::encodeName(fullPath));
1041 if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) 1041 if (fullPathInfo.isReadable() || !fullPathInfo.isDir())
1042 1042
1043 1043
1044 { 1044 {
1045 if(!create) { 1045 if(!create) {
1046#ifndef NDEBUG 1046#ifndef NDEBUG
1047 qDebug("save location %s doesn't exist", fullPath.latin1()); 1047 qDebug("save location %s doesn't exist", fullPath.latin1());
1048#endif 1048#endif
1049 return fullPath; 1049 return fullPath;
@@ -1132,19 +1132,19 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode)
1132#endif 1132#endif
1133 1133
1134 // ******************************************** 1134 // ********************************************
1135 // new code for WIN32 1135 // new code for WIN32
1136 QDir dirObj; 1136 QDir dirObj;
1137 1137
1138 1138
1139 // we want an absolute path 1139 // we want an absolute path
1140#ifndef _WIN32_ 1140#ifndef _WIN32_
1141 if (dir.at(0) != '/') 1141 if (dir.at(0) != '/')
1142 return false; 1142 return false;
1143#endif 1143#endif
1144 1144
1145 QString target = dir; 1145 QString target = dir;
1146 uint len = target.length(); 1146 uint len = target.length();
1147#ifndef _WIN32_ 1147#ifndef _WIN32_
1148 // append trailing slash if missing 1148 // append trailing slash if missing
1149 if (dir.at(len - 1) != '/') 1149 if (dir.at(len - 1) != '/')
1150 target += '/'; 1150 target += '/';
@@ -1162,30 +1162,30 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode)
1162 int pos = target.find('\\', i); 1162 int pos = target.find('\\', i);
1163#endif 1163#endif
1164 if ( pos < 0 ) 1164 if ( pos < 0 )
1165 return true; 1165 return true;
1166 base += target.mid(i - 1, pos - i + 1); 1166 base += target.mid(i - 1, pos - i + 1);
1167 //QMessageBox::information( 0,"cap111", base, 1 ); 1167 //QMessageBox::information( 0,"cap111", base, 1 );
1168/*US 1168/*US
1169 QCString baseEncoded = QFile::encodeName(base); 1169 QCString baseEncoded = QFile::encodeName(base);
1170 // bail out if we encountered a problem 1170 // bail out if we encountered a problem
1171 if (stat(baseEncoded, &st) != 0) 1171 if (stat(baseEncoded, &st) != 0)
1172 { 1172 {
1173 // Directory does not exist.... 1173 // Directory does not exist....
1174 // Or maybe a dangling symlink ? 1174 // Or maybe a dangling symlink ?
1175 if (lstat(baseEncoded, &st) == 0) 1175 if (lstat(baseEncoded, &st) == 0)
1176 (void)unlink(baseEncoded); // try removing 1176 (void)unlink(baseEncoded); // try removing
1177 1177
1178 1178
1179 if ( mkdir(baseEncoded, (mode_t) mode) != 0) { 1179 if ( mkdir(baseEncoded, (mode_t) mode) != 0) {
1180 perror("trying to create local folder"); 1180 perror("trying to create local folder");
1181 return false; // Couldn't create it :-( 1181 return false; // Couldn't create it :-(
1182 } 1182 }
1183 } 1183 }
1184*/ 1184*/
1185 1185
1186 if (dirObj.exists(base) == false) 1186 if (dirObj.exists(base) == false)
1187 { 1187 {
1188 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); 1188 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1());
1189 if (dirObj.mkdir(base) != true) 1189 if (dirObj.mkdir(base) != true)
1190 { 1190 {
1191 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); 1191 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1());
@@ -1230,26 +1230,26 @@ void KStandardDirs::addKDEDefaults()
1230 { 1230 {
1231 kdedir = KShell::tildeExpand(kdedir); 1231 kdedir = KShell::tildeExpand(kdedir);
1232 kdedirList.append(kdedir); 1232 kdedirList.append(kdedir);
1233 } 1233 }
1234 } 1234 }
1235//US kdedirList.append(KDEDIR); 1235//US kdedirList.append(KDEDIR);
1236//US for embedded, add qtopia dir as kdedir 1236//US for embedded, add qtopia dir as kdedir
1237 1237
1238#ifndef DESKTOP_VERSION 1238#ifndef DESKTOP_VERSION
1239 kdedirList.append(readEnvPath("QPEDIR" )); 1239 kdedirList.append(readEnvPath("QPEDIR" ));
1240#endif 1240#endif
1241 1241
1242#ifdef __KDE_EXECPREFIX 1242#ifdef __KDE_EXECPREFIX
1243 QString execPrefix(__KDE_EXECPREFIX); 1243 QString execPrefix(__KDE_EXECPREFIX);
1244 if (execPrefix!="NONE") 1244 if (execPrefix!="NONE")
1245 kdedirList.append(execPrefix); 1245 kdedirList.append(execPrefix);
1246#endif 1246#endif
1247 1247
1248 QString localKdeDir; 1248 QString localKdeDir;
1249 1249
1250//US if (getuid()) 1250//US if (getuid())
1251 if (true) 1251 if (true)
1252 { 1252 {
1253 localKdeDir = readEnvPath("MICROKDEHOME"); 1253 localKdeDir = readEnvPath("MICROKDEHOME");
1254 if (!localKdeDir.isEmpty()) 1254 if (!localKdeDir.isEmpty())
1255 { 1255 {
@@ -1272,21 +1272,21 @@ void KStandardDirs::addKDEDefaults()
1272 localKdeDir += '/'; 1272 localKdeDir += '/';
1273 } 1273 }
1274 else 1274 else
1275 { 1275 {
1276//US struct passwd *pw = getpwuid(0); 1276//US struct passwd *pw = getpwuid(0);
1277//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; 1277//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/";
1278 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); 1278 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed");
1279 } 1279 }
1280 1280
1281 } 1281 }
1282 1282
1283//US localKdeDir = appDir(); 1283//US localKdeDir = appDir();
1284 1284
1285//US 1285//US
1286// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); 1286// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1());
1287 if (localKdeDir != "-/") 1287 if (localKdeDir != "-/")
1288 { 1288 {
1289 localKdeDir = KShell::tildeExpand(localKdeDir); 1289 localKdeDir = KShell::tildeExpand(localKdeDir);
1290 addPrefix(localKdeDir); 1290 addPrefix(localKdeDir);
1291 } 1291 }
1292 1292
@@ -1325,13 +1325,13 @@ void KStandardDirs::addKDEDefaults()
1325 localXdgDir = QDir::homeDirPath() + "/.config/"; 1325 localXdgDir = QDir::homeDirPath() + "/.config/";
1326 } 1326 }
1327 else 1327 else
1328 { 1328 {
1329//US struct passwd *pw = getpwuid(0); 1329//US struct passwd *pw = getpwuid(0);
1330//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; 1330//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/";
1331 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); 1331 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed");
1332 } 1332 }
1333 } 1333 }
1334 1334
1335 localXdgDir = KShell::tildeExpand(localXdgDir); 1335 localXdgDir = KShell::tildeExpand(localXdgDir);
1336 addXdgConfigPrefix(localXdgDir); 1336 addXdgConfigPrefix(localXdgDir);
1337 1337
@@ -1357,13 +1357,13 @@ void KStandardDirs::addKDEDefaults()
1357 { 1357 {
1358 QString dir = *it; 1358 QString dir = *it;
1359 if (dir.at(dir.length()-1) != '/') 1359 if (dir.at(dir.length()-1) != '/')
1360 dir += '/'; 1360 dir += '/';
1361 xdgdirList.append(dir+"share/"); 1361 xdgdirList.append(dir+"share/");
1362 } 1362 }
1363 1363
1364 xdgdirList.append("/usr/local/share/"); 1364 xdgdirList.append("/usr/local/share/");
1365 xdgdirList.append("/usr/share/"); 1365 xdgdirList.append("/usr/share/");
1366 } 1366 }
1367 1367
1368 localXdgDir = readEnvPath("XDG_DATA_HOME"); 1368 localXdgDir = readEnvPath("XDG_DATA_HOME");
1369 if (!localXdgDir.isEmpty()) 1369 if (!localXdgDir.isEmpty())
@@ -1379,24 +1379,24 @@ void KStandardDirs::addKDEDefaults()
1379 localXdgDir = QDir::homeDirPath() + "/.local/share/"; 1379 localXdgDir = QDir::homeDirPath() + "/.local/share/";
1380 } 1380 }
1381 else 1381 else
1382 { 1382 {
1383//US struct passwd *pw = getpwuid(0); 1383//US struct passwd *pw = getpwuid(0);
1384//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; 1384//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/";
1385 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); 1385 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed");
1386 } 1386 }
1387 } 1387 }
1388 1388
1389 localXdgDir = KShell::tildeExpand(localXdgDir); 1389 localXdgDir = KShell::tildeExpand(localXdgDir);
1390 addXdgDataPrefix(localXdgDir); 1390 addXdgDataPrefix(localXdgDir);
1391 1391
1392 for (QStringList::ConstIterator it = xdgdirList.begin(); 1392 for (QStringList::ConstIterator it = xdgdirList.begin();
1393 it != xdgdirList.end(); it++) 1393 it != xdgdirList.end(); it++)
1394 { 1394 {
1395 QString dir = KShell::tildeExpand(*it); 1395 QString dir = KShell::tildeExpand(*it);
1396 1396
1397 addXdgDataPrefix(dir); 1397 addXdgDataPrefix(dir);
1398 } 1398 }
1399 // end XDG_DATA_XXX 1399 // end XDG_DATA_XXX
1400 1400
1401 1401
1402 uint index = 0; 1402 uint index = 0;
@@ -1407,13 +1407,13 @@ void KStandardDirs::addKDEDefaults()
1407 1407
1408 addResourceDir("home", QDir::homeDirPath()); 1408 addResourceDir("home", QDir::homeDirPath());
1409} 1409}
1410 1410
1411void KStandardDirs::checkConfig() const 1411void KStandardDirs::checkConfig() const
1412{ 1412{
1413/*US 1413/*US
1414 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) 1414 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config)
1415 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); 1415 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config);
1416*/ 1416*/
1417 if (!addedCustoms && KGlobal::config()) 1417 if (!addedCustoms && KGlobal::config())
1418 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); 1418 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config());
1419} 1419}
@@ -1436,13 +1436,13 @@ bool KStandardDirs::addCustomized(KConfig *config)
1436 list = config->readListEntry("prefixes"); 1436 list = config->readListEntry("prefixes");
1437 for (it = list.begin(); it != list.end(); it++) 1437 for (it = list.begin(); it != list.end(); it++)
1438 addPrefix(*it); 1438 addPrefix(*it);
1439 1439
1440 // iterating over all entries in the group Directories 1440 // iterating over all entries in the group Directories
1441 // to find entries that start with dir_$type 1441 // to find entries that start with dir_$type
1442/*US 1442/*US
1443 QMap<QString, QString> entries = config->entryMap("Directories"); 1443 QMap<QString, QString> entries = config->entryMap("Directories");
1444 1444
1445 QMap<QString, QString>::ConstIterator it2; 1445 QMap<QString, QString>::ConstIterator it2;
1446 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1446 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1447 { 1447 {
1448 QString key = it2.key(); 1448 QString key = it2.key();
@@ -1498,19 +1498,19 @@ QString KStandardDirs::localxdgconfdir() const
1498} 1498}
1499 1499
1500void KStandardDirs::setAppDir( const QString &appDir ) 1500void KStandardDirs::setAppDir( const QString &appDir )
1501{ 1501{
1502 mAppDir = appDir; 1502 mAppDir = appDir;
1503 1503
1504 if ( mAppDir.right( 1 ) != "/" ) 1504 if ( mAppDir.right( 1 ) != "/" )
1505 mAppDir += "/"; 1505 mAppDir += "/";
1506} 1506}
1507 1507
1508QString KStandardDirs::appDir() 1508QString KStandardDirs::appDir()
1509{ 1509{
1510 return mAppDir; 1510 return mAppDir;
1511} 1511}
1512 1512
1513// just to make code more readable without macros 1513// just to make code more readable without macros
1514QString locate( const char *type, 1514QString locate( const char *type,
1515 const QString& filename/*US , const KInstance* inst*/ ) 1515 const QString& filename/*US , const KInstance* inst*/ )
1516{ 1516{
@@ -1520,13 +1520,13 @@ QString locate( const char *type,
1520 1520
1521QString locateLocal( const char *type, 1521QString locateLocal( const char *type,
1522 const QString& filename/*US , const KInstance* inst*/ ) 1522 const QString& filename/*US , const KInstance* inst*/ )
1523{ 1523{
1524 1524
1525 QString path = locateLocal(type, filename, true /*US, inst*/); 1525 QString path = locateLocal(type, filename, true /*US, inst*/);
1526 1526
1527 1527
1528/* 1528/*
1529 static int ccc = 0; 1529 static int ccc = 0;
1530 ++ccc; 1530 ++ccc;
1531 if ( ccc > 13 ) 1531 if ( ccc > 13 )
1532 abort(); 1532 abort();
@@ -1534,51 +1534,51 @@ QString locateLocal( const char *type,
1534 qDebug("locatelocal: %s" , path.latin1()); 1534 qDebug("locatelocal: %s" , path.latin1());
1535 return path; 1535 return path;
1536 1536
1537/*US why do we put all files into one directory. It is quit complicated. 1537/*US why do we put all files into one directory. It is quit complicated.
1538why not staying with the original directorystructure ? 1538why not staying with the original directorystructure ?
1539 1539
1540 1540
1541 QString escapedFilename = filename; 1541 QString escapedFilename = filename;
1542 escapedFilename.replace( QRegExp( "/" ), "_" ); 1542 escapedFilename.replace( QRegExp( "/" ), "_" );
1543 1543
1544 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; 1544 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename;
1545 1545
1546 kdDebug() << "locate: '" << path << "'" << endl; 1546 kdDebug() << "locate: '" << path << "'" << endl;
1547 qDebug("locate: %s" , path.latin1()); 1547 qDebug("locate: %s" , path.latin1());
1548 return path; 1548 return path;
1549*/ 1549*/
1550//US so my proposal is this: 1550//US so my proposal is this:
1551 1551
1552// QString escapedFilename = filename; 1552// QString escapedFilename = filename;
1553// escapedFilename.replace( QRegExp( "/" ), "_" ); 1553// escapedFilename.replace( QRegExp( "/" ), "_" );
1554 1554
1555#if 0 1555#if 0
1556#ifdef _WIN32_ 1556#ifdef _WIN32_
1557 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); 1557 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename);
1558#else 1558#else
1559 QString path = KStandardDirs::appDir() + type + "/" + filename; 1559 QString path = KStandardDirs::appDir() + type + "/" + filename;
1560#endif 1560#endif
1561 1561
1562 //US Create the containing dir if needed 1562 //US Create the containing dir if needed
1563 QFileInfo fi ( path ); 1563 QFileInfo fi ( path );
1564 1564
1565 // QString dir=pathurl.directory(); 1565 // QString dir=pathurl.directory();
1566 //QMessageBox::information( 0,"path", path, 1 ); 1566 //QMessageBox::information( 0,"path", path, 1 );
1567 1567
1568#ifdef _WIN32_ 1568#ifdef _WIN32_
1569 KStandardDirs::makeDir(path); 1569 KStandardDirs::makeDir(path);
1570#else 1570#else
1571 KStandardDirs::makeDir(fi.dirPath( true )); 1571 KStandardDirs::makeDir(fi.dirPath( true ));
1572#endif 1572#endif
1573 1573
1574 qDebug("locate22: %s" , path.latin1()); 1574 qDebug("locate22: %s" , path.latin1());
1575 return path; 1575 return path;
1576 1576
1577#endif 1577#endif
1578 1578
1579} 1579}
1580 1580
1581QString locateLocal( const char *type, 1581QString locateLocal( const char *type,
1582 const QString& filename, bool createDir/*US , const KInstance* inst*/ ) 1582 const QString& filename, bool createDir/*US , const KInstance* inst*/ )
1583{ 1583{
1584 // try to find slashes. If there are some, we have to 1584 // try to find slashes. If there are some, we have to
@@ -1597,41 +1597,41 @@ QString locateLocal( const char *type,
1597 // *************************************************************** 1597 // ***************************************************************
1598#if 0 1598#if 0
1599 1599
1600/*US why do we put all files into one directory. It is quit complicated. 1600/*US why do we put all files into one directory. It is quit complicated.
1601why not staying with the original directorystructure ? 1601why not staying with the original directorystructure ?
1602 1602
1603 1603
1604 QString escapedFilename = filename; 1604 QString escapedFilename = filename;
1605 escapedFilename.replace( QRegExp( "/" ), "_" ); 1605 escapedFilename.replace( QRegExp( "/" ), "_" );
1606 1606
1607 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; 1607 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename;
1608 1608
1609 kdDebug() << "locate: '" << path << "'" << endl; 1609 kdDebug() << "locate: '" << path << "'" << endl;
1610 qDebug("locate: %s" , path.latin1()); 1610 qDebug("locate: %s" , path.latin1());
1611 return path; 1611 return path;
1612*/ 1612*/
1613//US so my proposal is this: 1613//US so my proposal is this:
1614 1614
1615// QString escapedFilename = filename; 1615// QString escapedFilename = filename;
1616// escapedFilename.replace( QRegExp( "/" ), "_" ); 1616// escapedFilename.replace( QRegExp( "/" ), "_" );
1617 1617
1618#ifdef _WIN32_ 1618#ifdef _WIN32_
1619 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); 1619 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename);
1620#else 1620#else
1621 QString path = KStandardDirs::appDir() + type + "/" + filename; 1621 QString path = KStandardDirs::appDir() + type + "/" + filename;
1622#endif 1622#endif
1623 1623
1624 //US Create the containing dir if needed 1624 //US Create the containing dir if needed
1625 KURL pathurl; 1625 KURL pathurl;
1626 pathurl.setPath(path); 1626 pathurl.setPath(path);
1627 QString dir=pathurl.directory(); 1627 QString dir=pathurl.directory();
1628 //QMessageBox::information( 0,"path", path, 1 ); 1628 //QMessageBox::information( 0,"path", path, 1 );
1629#ifdef _WIN32_ 1629#ifdef _WIN32_
1630 KStandardDirs::makeDir(path); 1630 KStandardDirs::makeDir(path);
1631#else 1631#else
1632 KStandardDirs::makeDir(dir); 1632 KStandardDirs::makeDir(dir);
1633#endif 1633#endif
1634 1634
1635 return path; 1635 return path;
1636#endif 1636#endif
1637} 1637}