summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore
authorulf69 <ulf69>2004-08-05 21:42:29 (UTC)
committer ulf69 <ulf69>2004-08-05 21:42:29 (UTC)
commit6ee7d4f5119837f89ec534c8c5c73845d521e135 (patch) (unidiff)
tree265d25e37da63a00ae3302059c2c628efb57b570 /microkde/kdecore
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 (limited to 'microkde/kdecore') (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
@@ -53,28 +53,28 @@
53#include "kshell.h" 53#include "kshell.h"
54//US#include <sys/param.h> 54//US#include <sys/param.h>
55//US#include <unistd.h> 55//US#include <unistd.h>
56 56
57//US 57//US
58QString KStandardDirs::mAppDir = QString::null; 58QString 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
75} 75}
76#endif 76#endif
77class KStandardDirs::KStandardDirsPrivate 77class KStandardDirs::KStandardDirsPrivate
78{ 78{
79public: 79public:
80 KStandardDirsPrivate() 80 KStandardDirsPrivate()
@@ -82,27 +82,27 @@ public:
82 dataRestrictionActive(false) 82 dataRestrictionActive(false)
83 { } 83 { }
84 84
85 bool restrictionsActive; 85 bool restrictionsActive;
86 bool dataRestrictionActive; 86 bool dataRestrictionActive;
87 QAsciiDict<bool> restrictions; 87 QAsciiDict<bool> restrictions;
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)
103{ 103{
104 d = new KStandardDirsPrivate; 104 d = new KStandardDirsPrivate;
105 dircache.setAutoDelete(true); 105 dircache.setAutoDelete(true);
106 relatives.setAutoDelete(true); 106 relatives.setAutoDelete(true);
107 absolutes.setAutoDelete(true); 107 absolutes.setAutoDelete(true);
108 savelocations.setAutoDelete(true); 108 savelocations.setAutoDelete(true);
@@ -349,143 +349,143 @@ QString KStandardDirs::findResourceDir( const char *type,
349 349
350 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 350 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
351 applyDataRestrictions(filename); 351 applyDataRestrictions(filename);
352 QStringList candidates = resourceDirs(type); 352 QStringList candidates = resourceDirs(type);
353 QString fullPath; 353 QString fullPath;
354#ifdef DESKTOP_VERSION 354#ifdef DESKTOP_VERSION
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
399static void lookupDirectory(const QString& path, const QString &relPart, 399static void lookupDirectory(const QString& path, const QString &relPart,
400 const QRegExp &regexp, 400 const QRegExp &regexp,
401 QStringList& list, 401 QStringList& list,
402 QStringList& relList, 402 QStringList& relList,
403 bool recursive, bool uniq) 403 bool recursive, bool uniq)
404{ 404{
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();
418 assert(path.at(path.length() - 1) == '/'); 418 assert(path.at(path.length() - 1) == '/');
419 419
420//US struct dirent *ep; 420//US struct dirent *ep;
421//US struct stat buff; 421//US struct stat buff;
422 422
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
445*/ 445*/
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)
486 continue; // No match 486 continue; // No match
487 } 487 }
488 488
489//US if ( S_ISREG( buff.st_mode)) 489//US if ( S_ISREG( buff.st_mode))
490 if ( pathfnInfo.isFile()) 490 if ( pathfnInfo.isFile())
491 { 491 {
@@ -501,25 +501,25 @@ static void lookupDirectory(const QString& path, const QString &relPart,
501 else 501 else
502 { 502 {
503 // We look for a single file. 503 // We look for a single file.
504 QString fn = pattern; 504 QString fn = pattern;
505 QString pathfn = path + fn; 505 QString pathfn = path + fn;
506//US struct stat buff; 506//US struct stat buff;
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 );
520 relList.append( relPart + fn ); 520 relList.append( relPart + fn );
521 } 521 }
522 } 522 }
523 } 523 }
524} 524}
525 525
@@ -547,71 +547,71 @@ static void lookupPrefix(const QString& prefix, const QString& relpath,
547 path = relpath.left(slash); 547 path = relpath.left(slash);
548 rest = relpath.mid(slash + 1); 548 rest = relpath.mid(slash + 1);
549 } 549 }
550 } 550 }
551 assert(prefix.at(prefix.length() - 1) == '/'); 551 assert(prefix.at(prefix.length() - 1) == '/');
552 552
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;
567 567
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)
587 continue; // No match 587 continue; // No match
588 588
589#else 589#else
590//US this should do the same: 590//US this should do the same:
591 if (pathExp.find(fn, 0) == -1) 591 if (pathExp.find(fn, 0) == -1)
592 continue; // No match 592 continue; // No match
593#endif 593#endif
594 QString rfn = relPart+fn; 594 QString rfn = relPart+fn;
595 fn = prefix + fn; 595 fn = prefix + fn;
596//US if ( stat( QFile::encodeName(fn), &buff ) != 0 ) 596//US if ( stat( QFile::encodeName(fn), &buff ) != 0 )
597 QFileInfo fnInfo(QFile::encodeName(fn)); 597 QFileInfo fnInfo(QFile::encodeName(fn));
598 if ( fnInfo.isReadable() == false ) 598 if ( fnInfo.isReadable() == false )
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
612 // when we try to open it. 612 // when we try to open it.
613 lookupPrefix(prefix + path + '/', rest, 613 lookupPrefix(prefix + path + '/', rest,
614 relPart + path + '/', regexp, list, 614 relPart + path + '/', regexp, list,
615 relList, recursive, uniq); 615 relList, recursive, uniq);
616 } 616 }
617} 617}
@@ -662,25 +662,25 @@ KStandardDirs::findAllResources( const char *type,
662} 662}
663 663
664QStringList 664QStringList
665KStandardDirs::findAllResources( const char *type, 665KStandardDirs::findAllResources( const char *type,
666 const QString& filter, 666 const QString& filter,
667 bool recursive, 667 bool recursive,
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];
681//US memset(realpath_buffer, 0, MAXPATHLEN + 1); 681//US memset(realpath_buffer, 0, MAXPATHLEN + 1);
682 char realpath_buffer[250 + 1]; 682 char realpath_buffer[250 + 1];
683 memset(realpath_buffer, 0, 250 + 1); 683 memset(realpath_buffer, 0, 250 + 1);
684 684
685 /* If the path contains symlinks, get the real name */ 685 /* If the path contains symlinks, get the real name */
686 if (realpath( QFile::encodeName(dirname).data(), realpath_buffer) != 0) { 686 if (realpath( QFile::encodeName(dirname).data(), realpath_buffer) != 0) {
@@ -723,25 +723,25 @@ void KStandardDirs::createSpecialResource(const char *type)
723 else 723 else
724 dir = QDir::cleanDirPath(dir+QFile::decodeName(link)); 724 dir = QDir::cleanDirPath(dir+QFile::decodeName(link));
725 } 725 }
726 addResourceDir(type, dir+'/'); 726 addResourceDir(type, dir+'/');
727} 727}
728*/ 728*/
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);
742*/ 742*/
743 QDir testdir; 743 QDir testdir;
744 744
745 candidates = new QStringList(); 745 candidates = new QStringList();
746 QStringList *dirs; 746 QStringList *dirs;
747 747
@@ -759,25 +759,25 @@ QStringList KStandardDirs::resourceDirs(const char *type) const
759 759
760 dirs = relatives.find(type); 760 dirs = relatives.find(type);
761 if (dirs) 761 if (dirs)
762 { 762 {
763 bool local = true; 763 bool local = true;
764 const QStringList *prefixList = 0; 764 const QStringList *prefixList = 0;
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) {
778 QString path = realPath(*pit + *it); 778 QString path = realPath(*pit + *it);
779 testdir.setPath(path); 779 testdir.setPath(path);
780 if (local && restrictionActive) 780 if (local && restrictionActive)
781 continue; 781 continue;
782 if ((local || testdir.exists()) && !candidates->contains(path)) 782 if ((local || testdir.exists()) && !candidates->contains(path))
783 candidates->append(path); 783 candidates->append(path);
@@ -826,25 +826,25 @@ QString KStandardDirs::findExe( const QString& appname,
826 { 826 {
827 info.setFile( appname ); 827 info.setFile( appname );
828 if( info.exists() && ( ignore || info.isExecutable() ) 828 if( info.exists() && ( ignore || info.isExecutable() )
829 && info.isFile() ) { 829 && info.isFile() ) {
830 return appname; 830 return appname;
831 } 831 }
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
845 QStringList tokens; 845 QStringList tokens;
846 p = pstr; 846 p = pstr;
847 847
848 if( p.isNull() ) { 848 if( p.isNull() ) {
849 p = getenv( "PATH" ); 849 p = getenv( "PATH" );
850 } 850 }
@@ -998,58 +998,58 @@ QString KStandardDirs::saveLocation(const char *type,
998 const QString& suffix, 998 const QString& suffix,
999 bool create) const 999 bool create) const
1000{ 1000{
1001 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); 1001 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() );
1002 //return ""; 1002 //return "";
1003 checkConfig(); 1003 checkConfig();
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 }
1017 if (dirs) 1017 if (dirs)
1018 { 1018 {
1019 // Check for existance of typed directory + suffix 1019 // Check for existance of typed directory + suffix
1020 if (strncmp(type, "xdgdata-", 8) == 0) 1020 if (strncmp(type, "xdgdata-", 8) == 0)
1021 pPath = new QString(realPath(localxdgdatadir() + dirs->last())); 1021 pPath = new QString(realPath(localxdgdatadir() + dirs->last()));
1022 else if (strncmp(type, "xdgconf-", 8) == 0) 1022 else if (strncmp(type, "xdgconf-", 8) == 0)
1023 pPath = new QString(realPath(localxdgconfdir() + dirs->last())); 1023 pPath = new QString(realPath(localxdgconfdir() + dirs->last()));
1024 else 1024 else
1025 pPath = new QString(realPath(localkdedir() + dirs->last())); 1025 pPath = new QString(realPath(localkdedir() + dirs->last()));
1026 } 1026 }
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;
1050 } 1050 }
1051 if(!makeDir(fullPath, 0700)) { 1051 if(!makeDir(fullPath, 0700)) {
1052 qWarning("failed to create %s", fullPath.latin1()); 1052 qWarning("failed to create %s", fullPath.latin1());
1053 return fullPath; 1053 return fullPath;
1054 } 1054 }
1055 dircache.remove(type); 1055 dircache.remove(type);
@@ -1126,72 +1126,72 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode)
1126 return false; // Couldn't create it :-( 1126 return false; // Couldn't create it :-(
1127 } 1127 }
1128 } 1128 }
1129 i = pos + 1; 1129 i = pos + 1;
1130 } 1130 }
1131 return true; 1131 return true;
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 += '/';
1151#endif 1151#endif
1152 1152
1153 QString base(""); 1153 QString base("");
1154 uint i = 1; 1154 uint i = 1;
1155 1155
1156 while( i < len ) 1156 while( i < len )
1157 { 1157 {
1158//US struct stat st; 1158//US struct stat st;
1159#ifndef _WIN32_ 1159#ifndef _WIN32_
1160 int pos = target.find('/', i); 1160 int pos = target.find('/', i);
1161#else 1161#else
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());
1192 return false; 1192 return false;
1193 } 1193 }
1194 } 1194 }
1195 1195
1196 i = pos + 1; 1196 i = pos + 1;
1197 } 1197 }
@@ -1224,38 +1224,38 @@ void KStandardDirs::addKDEDefaults()
1224 tokenize(kdedirList, kdedirs, ":"); 1224 tokenize(kdedirList, kdedirs, ":");
1225 } 1225 }
1226 else 1226 else
1227 { 1227 {
1228 QString kdedir = readEnvPath("MICROKDEDIR"); 1228 QString kdedir = readEnvPath("MICROKDEDIR");
1229 if (!kdedir.isEmpty()) 1229 if (!kdedir.isEmpty())
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 {
1256 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1256 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1257 localKdeDir += '/'; 1257 localKdeDir += '/';
1258 } 1258 }
1259 else 1259 else
1260 { 1260 {
1261 localKdeDir = QDir::homeDirPath() + "/kdepim/"; 1261 localKdeDir = QDir::homeDirPath() + "/kdepim/";
@@ -1266,33 +1266,33 @@ void KStandardDirs::addKDEDefaults()
1266 // We treat root different to prevent root messing up the 1266 // We treat root different to prevent root messing up the
1267 // file permissions in the users home directory. 1267 // file permissions in the users home directory.
1268 localKdeDir = readEnvPath("MICROKDEROOTHOME"); 1268 localKdeDir = readEnvPath("MICROKDEROOTHOME");
1269 if (!localKdeDir.isEmpty()) 1269 if (!localKdeDir.isEmpty())
1270 { 1270 {
1271 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1271 if (localKdeDir.at(localKdeDir.length()-1) != '/')
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
1293 for (QStringList::ConstIterator it = kdedirList.begin(); 1293 for (QStringList::ConstIterator it = kdedirList.begin();
1294 it != kdedirList.end(); it++) 1294 it != kdedirList.end(); it++)
1295 { 1295 {
1296 QString dir = KShell::tildeExpand(*it); 1296 QString dir = KShell::tildeExpand(*it);
1297 addPrefix(dir); 1297 addPrefix(dir);
1298 } 1298 }
@@ -1319,25 +1319,25 @@ void KStandardDirs::addKDEDefaults()
1319 } 1319 }
1320 else 1320 else
1321 { 1321 {
1322//US if (getuid()) 1322//US if (getuid())
1323 if (true) 1323 if (true)
1324 { 1324 {
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
1338 for (QStringList::ConstIterator it = xdgdirList.begin(); 1338 for (QStringList::ConstIterator it = xdgdirList.begin();
1339 it != xdgdirList.end(); it++) 1339 it != xdgdirList.end(); it++)
1340 { 1340 {
1341 QString dir = KShell::tildeExpand(*it); 1341 QString dir = KShell::tildeExpand(*it);
1342 addXdgConfigPrefix(dir); 1342 addXdgConfigPrefix(dir);
1343 } 1343 }
@@ -1351,75 +1351,75 @@ void KStandardDirs::addKDEDefaults()
1351 } 1351 }
1352 else 1352 else
1353 { 1353 {
1354 xdgdirList.clear(); 1354 xdgdirList.clear();
1355 for (QStringList::ConstIterator it = kdedirList.begin(); 1355 for (QStringList::ConstIterator it = kdedirList.begin();
1356 it != kdedirList.end(); it++) 1356 it != kdedirList.end(); it++)
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())
1370 { 1370 {
1371 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1371 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1372 localXdgDir += '/'; 1372 localXdgDir += '/';
1373 } 1373 }
1374 else 1374 else
1375 { 1375 {
1376//US if (getuid()) 1376//US if (getuid())
1377 if (true) 1377 if (true)
1378 { 1378 {
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;
1403 while (types[index] != 0) { 1403 while (types[index] != 0) {
1404 addResourceType(types[index], kde_default(types[index])); 1404 addResourceType(types[index], kde_default(types[index]));
1405 index++; 1405 index++;
1406 } 1406 }
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}
1420 1420
1421bool KStandardDirs::addCustomized(KConfig *config) 1421bool KStandardDirs::addCustomized(KConfig *config)
1422{ 1422{
1423 if (addedCustoms) // there are already customized entries 1423 if (addedCustoms) // there are already customized entries
1424 return false; // we just quite and hope they are the right ones 1424 return false; // we just quite and hope they are the right ones
1425 1425
@@ -1430,25 +1430,25 @@ bool KStandardDirs::addCustomized(KConfig *config)
1430 // reading the prefixes in 1430 // reading the prefixes in
1431 QString oldGroup = config->group(); 1431 QString oldGroup = config->group();
1432 config->setGroup("Directories"); 1432 config->setGroup("Directories");
1433 1433
1434 QStringList list; 1434 QStringList list;
1435 QStringList::ConstIterator it; 1435 QStringList::ConstIterator it;
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();
1449 if (key.left(4) == "dir_") { 1449 if (key.left(4) == "dir_") {
1450 // generate directory list, there may be more than 1. 1450 // generate directory list, there may be more than 1.
1451 QStringList dirs = QStringList::split(',', *it2); 1451 QStringList dirs = QStringList::split(',', *it2);
1452 QStringList::Iterator sIt(dirs.begin()); 1452 QStringList::Iterator sIt(dirs.begin());
1453 QString resType = key.mid(4, key.length()); 1453 QString resType = key.mid(4, key.length());
1454 for (; sIt != dirs.end(); ++sIt) { 1454 for (; sIt != dirs.end(); ++sIt) {
@@ -1492,146 +1492,146 @@ QString KStandardDirs::localxdgdatadir() const
1492} 1492}
1493 1493
1494QString KStandardDirs::localxdgconfdir() const 1494QString KStandardDirs::localxdgconfdir() const
1495{ 1495{
1496 // Return the prefix to use for saving 1496 // Return the prefix to use for saving
1497 return d->xdgconf_prefixes.first(); 1497 return d->xdgconf_prefixes.first();
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{
1517//US return inst->dirs()->findResource(type, filename); 1517//US return inst->dirs()->findResource(type, filename);
1518 return KGlobal::dirs()->findResource(type, filename); 1518 return KGlobal::dirs()->findResource(type, filename);
1519} 1519}
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();
1533*/ 1533*/
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
1585 // create the subdir first 1585 // create the subdir first
1586 int slash = filename.findRev('/')+1; 1586 int slash = filename.findRev('/')+1;
1587 if (!slash) // only one filename 1587 if (!slash) // only one filename
1588 //USreturn inst->dirs()->saveLocation(type, QString::null, createDir) + filename; 1588 //USreturn inst->dirs()->saveLocation(type, QString::null, createDir) + filename;
1589 return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename; 1589 return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename;
1590 1590
1591 // split path from filename 1591 // split path from filename
1592 QString dir = filename.left(slash); 1592 QString dir = filename.left(slash);
1593 QString file = filename.mid(slash); 1593 QString file = filename.mid(slash);
1594//US return inst->dirs()->saveLocation(type, dir, createDir) + file; 1594//US return inst->dirs()->saveLocation(type, dir, createDir) + file;
1595 return KGlobal::dirs()->saveLocation(type, dir, createDir) + file; 1595 return KGlobal::dirs()->saveLocation(type, dir, createDir) + file;
1596 1596
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}