From 6ee7d4f5119837f89ec534c8c5c73845d521e135 Mon Sep 17 00:00:00 2001 From: ulf69 Date: Thu, 05 Aug 2004 21:42:29 +0000 Subject: 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 --- (limited to 'microkde/kdecore/kstandarddirs.cpp') 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 @@ -62,10 +62,10 @@ template class QDict; #if 0 #include -void ddd( QString op ) +void ddd( QString op ) { static QTextEdit * dot = 0; - if ( ! dot ) + if ( ! dot ) dot = new QTextEdit(); dot->show(); @@ -91,9 +91,9 @@ public: static const char* const types[] = {"html", "icon", "apps", "sound", "data", "locale", "services", "mime", - "servicetypes", "config", "exe", - "wallpaper", "lib", "pixmap", "templates", - "module", "qtplugins", + "servicetypes", "config", "exe", "tmp", + "wallpaper", "lib", "pixmap", "templates", + "module", "qtplugins", "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; static int tokenize( QStringList& token, const QString& str, @@ -358,7 +358,7 @@ QString KStandardDirs::findResourceDir( const char *type, candidates.prepend( qApp->applicationDirPath () +"/"); #endif #endif - for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) + for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) { //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1()); if (exists(*it + filename)) @@ -368,7 +368,7 @@ QString KStandardDirs::findResourceDir( const char *type, #ifndef NDEBUG if(false && type != "locale") qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1()); - + #endif return QString::null; @@ -381,15 +381,15 @@ bool KStandardDirs::exists(const QString &fullPath) //US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) if (fullPathInfo.isReadable()) - { + { if (fullPath.at(fullPath.length() - 1) != '/') { //US if (S_ISREG( buff.st_mode )) if (fullPathInfo.isFile()) return true; - } + } else { -//US if (S_ISDIR( buff.st_mode )) - if (fullPathInfo.isDir()) +//US if (S_ISDIR( buff.st_mode )) + if (fullPathInfo.isDir()) return true; } } @@ -408,7 +408,7 @@ static void lookupDirectory(const QString& path, const QString &relPart, // We look for a set of files. //US DIR *dp = opendir( QFile::encodeName(path)); QDir dp(QFile::encodeName(path)); - + if (!dp.exists()) return; static int iii = 0; @@ -426,16 +426,16 @@ static void lookupDirectory(const QString& path, const QString &relPart, //US while( ( ep = readdir( dp ) ) != 0L ) QStringList direntries = dp.entryList(); QStringList::Iterator it = direntries.begin(); - + while ( it != list.end() ) // for each file... { - + //US QString fn( QFile::decodeName(ep->d_name)); QString fn = (*it); // dp.entryList already decodes it++; if ( fn.isNull() ) break; - + if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) continue; @@ -449,13 +449,13 @@ static void lookupDirectory(const QString& path, const QString &relPart, continue; // No match QString pathfn = path + fn; -/*US +/*US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; continue; // Couldn't stat (e.g. no read permissions) } - - if ( recursive ) + + if ( recursive ) { if ( S_ISDIR( buff.st_mode )) { lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); @@ -468,15 +468,15 @@ static void lookupDirectory(const QString& path, const QString &relPart, //US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; continue; // Couldn't stat (e.g. no read permissions) } - - if ( recursive ) + + if ( recursive ) { if ( pathfnInfo.isDir()) { lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); } - - -/*US + + +/*US if (!regexp.exactMatch(fn)) continue; // No match */ @@ -510,7 +510,7 @@ static void lookupDirectory(const QString& path, const QString &relPart, //US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) if ( pathfnInfo.isReadable() == false ) return; // File not found - + //US if ( S_ISREG( buff.st_mode)) if ( pathfnInfo.isFile()) { @@ -556,8 +556,8 @@ static void lookupPrefix(const QString& prefix, const QString& relpath, QRegExp pathExp(path, true, true); //US DIR *dp = opendir( QFile::encodeName(prefix) ); QDir dp(QFile::encodeName(prefix)); - -//US if (!dp) + +//US if (!dp) if (!dp.exists()) { return; @@ -571,13 +571,13 @@ static void lookupPrefix(const QString& prefix, const QString& relpath, //US while( ( ep = readdir( dp ) ) != 0L ) QStringList direntries = dp.entryList(); QStringList::Iterator it = direntries.begin(); - + while ( it != list.end() ) // for each file... { //US QString fn( QFile::decodeName(ep->d_name)); QString fn = (*it); // dp.entryList() already encodes the strings it++; - + if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~') continue; @@ -602,7 +602,7 @@ static void lookupPrefix(const QString& prefix, const QString& relpath, } //US if ( S_ISDIR( buff.st_mode )) if ( fnInfo.isDir() ) - + lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq); } @@ -671,7 +671,7 @@ KStandardDirs::findAllResources( const char *type, return findAllResources(type, filter, recursive, uniq, relList); } -QString +QString KStandardDirs::realPath(const QString &dirname) { #ifdef _WIN32_ @@ -732,7 +732,7 @@ QStringList KStandardDirs::resourceDirs(const char *type) const QStringList *candidates = dircache.find(type); if (!candidates) { // filling cache -/*US +/*US if (strcmp(type, "socket") == 0) const_cast(this)->createSpecialResource(type); else if (strcmp(type, "tmp") == 0) @@ -768,7 +768,7 @@ QStringList KStandardDirs::resourceDirs(const char *type) const prefixList = &(d->xdgconf_prefixes); else prefixList = &prefixes; - + for (QStringList::ConstIterator pit = prefixList->begin(); pit != prefixList->end(); pit++) @@ -835,7 +835,7 @@ QString KStandardDirs::findExe( const QString& appname, //US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname); QString p = QString("%1/%2").arg(appname).arg(appname); qDebug("KStandardDirs::findExe this is probably wrong"); - + info.setFile( p ); if( info.exists() && ( ignore || info.isExecutable() ) && ( info.isFile() || info.isSymLink() ) ) { @@ -1007,7 +1007,7 @@ QString KStandardDirs::saveLocation(const char *type, { QStringList *dirs = relatives.find(type); if (!dirs && ( - (strcmp(type, "socket") == 0) || + (strcmp(type, "socket") == 0) || (strcmp(type, "tmp") == 0) || (strcmp(type, "cache") == 0) )) { @@ -1030,17 +1030,17 @@ QString KStandardDirs::saveLocation(const char *type, qFatal("KStandardDirs: The resource type %s is not registered", type); pPath = new QString(realPath(dirs->last())); } - + savelocations.insert(type, pPath); } - + QString fullPath = *pPath + suffix; //US struct stat st; -//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) +//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) QFileInfo fullPathInfo(QFile::encodeName(fullPath)); - if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) - - + if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) + + { if(!create) { #ifndef NDEBUG @@ -1135,13 +1135,13 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode) // new code for WIN32 QDir dirObj; - + // we want an absolute path #ifndef _WIN32_ if (dir.at(0) != '/') return false; #endif - + QString target = dir; uint len = target.length(); #ifndef _WIN32_ @@ -1165,7 +1165,7 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode) return true; base += target.mid(i - 1, pos - i + 1); //QMessageBox::information( 0,"cap111", base, 1 ); -/*US +/*US QCString baseEncoded = QFile::encodeName(base); // bail out if we encountered a problem if (stat(baseEncoded, &st) != 0) @@ -1174,15 +1174,15 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode) // Or maybe a dangling symlink ? if (lstat(baseEncoded, &st) == 0) (void)unlink(baseEncoded); // try removing - + if ( mkdir(baseEncoded, (mode_t) mode) != 0) { perror("trying to create local folder"); return false; // Couldn't create it :-( } } -*/ - +*/ + if (dirObj.exists(base) == false) { //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); @@ -1233,7 +1233,7 @@ void KStandardDirs::addKDEDefaults() } } //US kdedirList.append(KDEDIR); -//US for embedded, add qtopia dir as kdedir +//US for embedded, add qtopia dir as kdedir #ifndef DESKTOP_VERSION kdedirList.append(readEnvPath("QPEDIR" )); @@ -1246,7 +1246,7 @@ void KStandardDirs::addKDEDefaults() #endif QString localKdeDir; - + //US if (getuid()) if (true) { @@ -1275,7 +1275,7 @@ void KStandardDirs::addKDEDefaults() { //US struct passwd *pw = getpwuid(0); //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; - qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); + qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); } } @@ -1283,7 +1283,7 @@ void KStandardDirs::addKDEDefaults() //US localKdeDir = appDir(); //US -// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); +// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); if (localKdeDir != "-/") { localKdeDir = KShell::tildeExpand(localKdeDir); @@ -1328,7 +1328,7 @@ void KStandardDirs::addKDEDefaults() { //US struct passwd *pw = getpwuid(0); //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; - qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); + qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); } } @@ -1360,7 +1360,7 @@ void KStandardDirs::addKDEDefaults() dir += '/'; xdgdirList.append(dir+"share/"); } - + xdgdirList.append("/usr/local/share/"); xdgdirList.append("/usr/share/"); } @@ -1382,7 +1382,7 @@ void KStandardDirs::addKDEDefaults() { //US struct passwd *pw = getpwuid(0); //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; - qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); + qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); } } @@ -1393,7 +1393,7 @@ void KStandardDirs::addKDEDefaults() it != xdgdirList.end(); it++) { QString dir = KShell::tildeExpand(*it); - + addXdgDataPrefix(dir); } // end XDG_DATA_XXX @@ -1410,7 +1410,7 @@ void KStandardDirs::addKDEDefaults() void KStandardDirs::checkConfig() const { -/*US +/*US if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) const_cast(this)->addCustomized(KGlobal::_instance->_config); */ @@ -1439,7 +1439,7 @@ bool KStandardDirs::addCustomized(KConfig *config) // iterating over all entries in the group Directories // to find entries that start with dir_$type -/*US +/*US QMap entries = config->entryMap("Directories"); QMap::ConstIterator it2; @@ -1501,13 +1501,13 @@ void KStandardDirs::setAppDir( const QString &appDir ) { mAppDir = appDir; - if ( mAppDir.right( 1 ) != "/" ) + if ( mAppDir.right( 1 ) != "/" ) mAppDir += "/"; } QString KStandardDirs::appDir() -{ - return mAppDir; +{ + return mAppDir; } // just to make code more readable without macros @@ -1523,7 +1523,7 @@ QString locateLocal( const char *type, { QString path = locateLocal(type, filename, true /*US, inst*/); - + /* static int ccc = 0; @@ -1537,7 +1537,7 @@ QString locateLocal( const char *type, /*US why do we put all files into one directory. It is quit complicated. why not staying with the original directorystructure ? - + QString escapedFilename = filename; escapedFilename.replace( QRegExp( "/" ), "_" ); @@ -1547,7 +1547,7 @@ why not staying with the original directorystructure ? qDebug("locate: %s" , path.latin1()); return path; */ -//US so my proposal is this: +//US so my proposal is this: // QString escapedFilename = filename; // escapedFilename.replace( QRegExp( "/" ), "_" ); @@ -1558,24 +1558,24 @@ why not staying with the original directorystructure ? #else QString path = KStandardDirs::appDir() + type + "/" + filename; #endif - + //US Create the containing dir if needed QFileInfo fi ( path ); - + // QString dir=pathurl.directory(); // QMessageBox::information( 0,"path", path, 1 ); - + #ifdef _WIN32_ KStandardDirs::makeDir(path); #else KStandardDirs::makeDir(fi.dirPath( true )); -#endif - +#endif + qDebug("locate22: %s" , path.latin1()); return path; #endif - + } QString locateLocal( const char *type, @@ -1600,7 +1600,7 @@ QString locateLocal( const char *type, /*US why do we put all files into one directory. It is quit complicated. why not staying with the original directorystructure ? - + QString escapedFilename = filename; escapedFilename.replace( QRegExp( "/" ), "_" ); @@ -1610,7 +1610,7 @@ why not staying with the original directorystructure ? qDebug("locate: %s" , path.latin1()); return path; */ -//US so my proposal is this: +//US so my proposal is this: // QString escapedFilename = filename; // escapedFilename.replace( QRegExp( "/" ), "_" ); @@ -1620,7 +1620,7 @@ why not staying with the original directorystructure ? #else QString path = KStandardDirs::appDir() + type + "/" + filename; #endif - + //US Create the containing dir if needed KURL pathurl; pathurl.setPath(path); @@ -1630,8 +1630,8 @@ why not staying with the original directorystructure ? KStandardDirs::makeDir(path); #else KStandardDirs::makeDir(dir); -#endif - +#endif + return path; #endif } -- cgit v0.9.0.2