KStandardDirs Class Reference
Site-independent access to standard KDE directories. More...
#include <kstandarddirs.h>
Collaboration diagram for KStandardDirs:

Public Member Functions | |
KStandardDirs () | |
KStandardDirs' constructor. | |
virtual | ~KStandardDirs () |
KStandardDirs' destructor. | |
void | addPrefix (const QString &dir) |
Adds another search dir to front of the fsstnd list. | |
bool | addResourceType (const char *type, const QString &relativename) |
Adds suffixes for types. | |
bool | addResourceDir (const char *type, const QString &absdir) |
Adds absolute path at the end of the search path for particular types (for example in case of icons where the user specifies extra paths). | |
QString | findResource (const char *type, const QString &filename) const |
Tries to find a resource in the following order:
| |
bool | isRestrictedResource (const char *type, const QString &relPath=QString::null) const |
Checks whether a resource is restricted as part of the KIOSK framework. | |
Q_UINT32 | calcResourceHash (const char *type, const QString &filename, bool deep) const |
Returns a number that identifies this version of the resource. | |
QStringList | findDirs (const char *type, const QString &reldir) const |
Tries to find all directories whose names consist of the specified type and a relative path. | |
QString | findResourceDir (const char *type, const QString &filename) const |
Tries to find the directory the file is in. | |
QStringList | findAllResources (const char *type, const QString &filter=QString::null, bool recursive=false, bool uniq=false) const |
Tries to find all resources with the specified type. | |
QStringList | findAllResources (const char *type, const QString &filter, bool recursive, bool uniq, QStringList &relPaths) const |
Tries to find all resources with the specified type. | |
void | addKDEDefaults () |
This function adds the defaults that are used by the current KDE version. | |
bool | addCustomized (KConfig *config) |
Reads customized entries out of the given config object and add them via addResourceDirs(). | |
QStringList | resourceDirs (const char *type) const |
This function is used internally by almost all other function as it serves and fills the directories cache. | |
QStringList | allTypes () const |
This function will return a list of all the types that KStandardDirs supports. | |
QString | saveLocation (const char *type, const QString &suffix=QString::null, bool create=true) const |
Finds a location to save files into for the given type in the user's home directory. | |
QString | relativeLocation (const char *type, const QString &absPath) |
Converts an absolute path to a path relative to a certain resource. | |
QString | kfsstnd_prefixes () |
QString | localkdedir () const |
Returns the toplevel directory in which KStandardDirs will store things. | |
Static Public Member Functions | |
QString | findExe (const QString &appname, const QString &pathstr=QString::null, bool ignoreExecBit=false) |
Finds the executable in the system path. | |
int | findAllExe (QStringList &list, const QString &appname, const QString &pathstr=QString::null, bool ignoreExecBit=false) |
Finds all occurences of an executable in the system path. | |
bool | makeDir (const QString &dir, int mode=0755) |
Recursively creates still-missing directories in the given path. | |
QString | kde_default (const char *type) |
This returns a default relative path for the standard KDE resource types. | |
bool | exists (const QString &fullPath) |
Checks for existence and accessability. | |
QString | realPath (const QString &dirname) |
Expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in dirname and returns the canonicalized absolute pathname. | |
Related Functions | |
(Note that these are not member functions.) | |
QString | locate (const char *type, const QString &filename, const KInstance *instance=KGlobal::instance()) |
QString | locateLocal (const char *type, const QString &filename, const KInstance *instance=KGlobal::instance()) |
Detailed Description
Site-independent access to standard KDE directories.
- Author:
- Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org>
- Version:
- Id
- kstandarddirs.h,v 1.100.2.1 2003/01/08 16:15:51 waba Exp
To this end it insulates the application from all information and applications always refer to a file with a resource type (e.g. icon) and a filename (e.g. khexdit.xpm). In an ideal world the application would make no assumption where this file is and leave it up to KStandardDirs::findResource("apps", "Home.desktop") to apply this knowledge to return /opt/kde/share/applnk/Home.desktop or ::locate("data", "kgame/background.jpg") to return /opt/kde/share/apps/kgame/background.jpg
The main idea behind KStandardDirs is that there are several toplevel prefixes below which the files lie. One of these prefixes is the one where the user installed kdelibs, one is where the application was installed, and one is $HOME/.kde, but there may be even more. Under these prefixes there are several well defined suffixes where specific resource types are to be found. For example, for the resource type "html" the suffixes could be share/doc/HTML and share/doc/kde/HTML. So the search algorithm basicly appends to each prefix each registered suffix and tries to locate the file there. To make the thing even more complex, it's also possible to register absolute paths that KStandardDirs looks up after not finding anything in the former steps. They can be useful if the user wants to provide specific directories that aren't in his $HOME/.kde directory for, for example, icons.
Standard resources that kdelibs allocates are:
A type that is added by the class KApplication if you use it, is appdata. This one makes the use of the type data a bit easier as it appends the name of the application. So while you had to ::locate("data", "appname/filename") so you can also write ::locate("appdata", "filename") if your KApplication instance is called "appname" (as set via KApplication's constructor or KAboutData, if you use the global KStandardDirs object KGlobal::dirs()). Please note though that you cannot use the "appdata" type if you intend to use it in an applet for Kicker because 'appname' would be "Kicker" instead of the applet's name. Therefore, for applets, you've got to work around this by using ::locate("data", "appletname/filename").
KStandardDirs supports the following environment variables:
Definition at line 125 of file kstandarddirs.h.
Constructor & Destructor Documentation
|
KStandardDirs' constructor. It just initializes the caches. Definition at line 77 of file kstandarddirs.cpp. References addKDEDefaults(), QDict< QString >::setAutoDelete(), and QDict< QStringList >::setAutoDelete(). |
|
KStandardDirs' destructor.
Definition at line 86 of file kstandarddirs.cpp. |
Member Function Documentation
|
Adds another search dir to front of the
Definition at line 134 of file kstandarddirs.cpp. References QString::at(), QDict< QStringList >::clear(), QString::isNull(), and QString::length(). Referenced by addCustomized(), and addKDEDefaults(). |
|
Adds suffixes for types. You may add as many as you need, but it is advised that there is exactly one to make writing definite. All basic types (kde_default) are added by addKDEDefaults(), but for those you can add more relative paths as well. The later a suffix is added, the higher its priority. Note, that the suffix should end with / but doesn't have to start with one (as prefixes should end with one). So adding a suffix for app_pics would look like KGlobal::dirs()->addResourceType("app_pics", "share/app/pics");
Definition at line 154 of file kstandarddirs.cpp. References KStdAction::copy(), QDict< QStringList >::find(), QDict< QStringList >::insert(), QString::isNull(), and QDict< QStringList >::remove(). Referenced by addKDEDefaults(). |
|
Adds absolute path at the end of the search path for particular types (for example in case of icons where the user specifies extra paths). You shouldn't need this function in 99% of all cases besides adding user-given paths.
Definition at line 176 of file kstandarddirs.cpp. References KStdAction::copy(), QDict< QStringList >::find(), QDict< QStringList >::insert(), and QDict< QStringList >::remove(). Referenced by addCustomized(), and addKDEDefaults(). |
|
Tries to find a resource in the following order:
Definition at line 196 of file kstandarddirs.cpp. References QString::at(), findResourceDir(), and QString::isNull(). Referenced by KLibLoader::findLibrary(), and locate(). |
|
Checks whether a resource is restricted as part of the KIOSK framework. When a resource is restricted it means that user- specific files in the resource are ignored. E.g. by restricting the "wallpaper" resource, only system-wide installed wallpapers will be found by this class. Wallpapers installed under the $KDEHOME directory will be ignored.
Definition at line 92 of file kstandarddirs.cpp. Referenced by KConfigINIBackEnd::parseConfigFiles(). |
|
Returns a number that identifies this version of the resource. When a change is made to the resource this number will change.
Definition at line 231 of file kstandarddirs.cpp. References QString::at(), and resourceDirs(). |
|
Tries to find all directories whose names consist of the specified type and a relative path. So would findDirs("apps", "Settings") return
Definition at line 257 of file kstandarddirs.cpp. References QDir::absPath(), QDir::exists(), resourceDirs(), and QDir::setPath(). |
|
Tries to find the directory the file is in. It works the same as findResource(), but it doesn't return the filename but the name of the directory. This way the application can access a couple of files that have been installed into the same directory without having to look for each file. findResourceDir("lib", "libkdecore.la") would return the path of the subdir libkdecore.la is found first in (e.g. /opt/kde/lib/)
Definition at line 279 of file kstandarddirs.cpp. References exists(), QString::isEmpty(), and resourceDirs(). Referenced by findResource(). |
|
Tries to find all resources with the specified type. The function will look into all specified directories and return all filenames in these directories.
Definition at line 513 of file kstandarddirs.cpp. Referenced by KLocale::allCountriesTwoAlpha(), and KPalette::getPaletteList(). |
|
Tries to find all resources with the specified type. The function will look into all specified directories and return all filenames (full and relative paths) in these directories.
Definition at line 465 of file kstandarddirs.cpp. References QString::at(), QString::findRev(), QString::isEmpty(), QString::left(), QString::length(), QString::mid(), and resourceDirs(). |
|
Finds the executable in the system path. A valid executable must be a file and have its executable bit set.
Definition at line 672 of file kstandarddirs.cpp. References QString::arg(), QFileInfo::exists(), QString::find(), QString::fromLatin1(), QString::fromLocal8Bit(), QDir::homeDirPath(), QFileInfo::isExecutable(), QFileInfo::isFile(), QFileInfo::isSymLink(), QString::length(), QString::local8Bit(), QString::mid(), QString::replace(), QFileInfo::setFile(), and QString::startsWith(). Referenced by resourceDirs(). |
|
Finds all occurences of an executable in the system path.
Definition at line 742 of file kstandarddirs.cpp. References QFileInfo::exists(), QFileInfo::isExecutable(), QFileInfo::isFile(), and QFileInfo::setFile(). |
|
This function adds the defaults that are used by the current KDE version. It's a series of addResourceTypes() and addPrefix() calls. You normally wouldn't call this function because it's called for you from KGlobal. Definition at line 966 of file kstandarddirs.cpp. References addPrefix(), addResourceDir(), addResourceType(), QFile::decodeName(), QDir::homeDirPath(), QString::isEmpty(), kde_default(), and QString::length(). Referenced by KStandardDirs(). |
|
Reads customized entries out of the given config object and add them via addResourceDirs().
Definition at line 1056 of file kstandarddirs.cpp. References addPrefix(), addResourceDir(), QMap::begin(), QMap::end(), KConfig::entryMap(), KConfigBase::group(), KStdAccel::key(), QString::latin1(), KConfigBase::readBoolEntry(), KConfigBase::readListEntry(), QDict< QStringList >::remove(), resourceDirs(), KConfigBase::setGroup(), and QStringList::split(). Referenced by KInstance::config(), KInstance::dirs(), and KConfig::KConfig(). |
|
This function is used internally by almost all other function as it serves and fills the directories cache.
Definition at line 540 of file kstandarddirs.cpp. References QDir::cleanDirPath(), QFile::decodeName(), QFile::encodeName(), QDir::exists(), QDict< QStringList >::find(), findExe(), QString::fromLatin1(), QDict< QStringList >::insert(), QString::isEmpty(), localkdedir(), realPath(), and QDir::setPath(). Referenced by addCustomized(), KIconLoader::addExtraDesktopThemes(), calcResourceHash(), findAllResources(), findDirs(), findResourceDir(), KIconTheme::KIconTheme(), KLocale::langLookup(), KIconTheme::list(), relativeLocation(), and saveLocation(). |
|
This function will return a list of all the types that KStandardDirs supports.
Definition at line 126 of file kstandarddirs.cpp. References QString::fromLatin1(). |
|
Finds a location to save files into for the given type in the user's home directory.
Definition at line 840 of file kstandarddirs.cpp. References KStdAction::create(), QFile::encodeName(), QDict< QStringList >::find(), QDict< QString >::find(), QDict< QString >::insert(), localkdedir(), makeDir(), realPath(), QDict< QStringList >::remove(), and resourceDirs(). Referenced by KConfigBackEnd::changeFileName(), and locateLocal(). |
|
Converts an absolute path to a path relative to a certain resource. If "abs = ::locate(resource, rel)" then "rel = relativeLocation(resource, abs)" and vice versa.
Definition at line 888 of file kstandarddirs.cpp. References QString::findRev(), QString::left(), QString::mid(), realPath(), resourceDirs(), and QString::startsWith(). Referenced by KDesktopFile::isAuthorizedDesktopFile(). |
|
Recursively creates still-missing directories in the given path. The resulting permissions will depend on the current umask setting. permission = mode & ~umask.
Definition at line 910 of file kstandarddirs.cpp. References QString::at(), QFile::encodeName(), QString::find(), QString::length(), and QString::mid(). Referenced by KConfigINIBackEnd::parseConfigFiles(), saveLocation(), and KConfigINIBackEnd::sync(). |
|
This returns a default relative path for the standard KDE resource types. Below is a list of them so you get an idea of what this is all about.
Definition at line 799 of file kstandarddirs.cpp. Referenced by KIconLoader::addAppDir(), and addKDEDefaults(). |
|
Returns the toplevel directory in which KStandardDirs will store things. Most likely $HOME/.kde Don't use this function if you can use locateLocal
Definition at line 1121 of file kstandarddirs.cpp. Referenced by resourceDirs(), and saveLocation(). |
|
Checks for existence and accessability. Faster than creating a QFileInfo first.
Definition at line 307 of file kstandarddirs.cpp. References QFile::encodeName(). Referenced by KIconLoader::addExtraDesktopThemes(), findResourceDir(), KIconTheme::KIconTheme(), and KIconTheme::list(). |
|
Expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in The resulting path will have no symbolic link, '/./' or '/../' components.
Definition at line 523 of file kstandarddirs.cpp. References QFile::decodeName(), and QFile::encodeName(). Referenced by relativeLocation(), resourceDirs(), and saveLocation(). |
The documentation for this class was generated from the following files: