KStandardDirs Class Reference
#include <kstandarddirs.h>
Detailed Description
Site-independent access to standard KDE directories.
- Author:
- Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org>
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 basically 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:
- apps - Applications menu (.desktop files).
- cache - Cached information (e.g. favicons, web-pages)
- cgi - CGIs to run from kdehelp.
- config - Configuration files.
- data - Where applications store data.
- exe - Executables in $prefix/bin. findExe() for a function that takes $PATH into account.
- html - HTML documentation.
- icon - Icons, see KIconLoader.
- lib - Libraries.
- locale - Translation files for KLocale.
- mime - Mime types.
- module - Module (dynamically loaded library).
- qtplugins - Qt plugins (dynamically loaded objects for Qt)
- services - Services.
- servicetypes - Service types.
- scripts - Application scripting additions.
- sound - Application sounds.
- templates - Templates
- wallpaper - Wallpapers.
- tmp - Temporary files (specific for both current host and current user)
- socket - UNIX Sockets (specific for both current host and current user)
- emoticons - Emoticons themes (Since KDE 3.4)
KStandardDirs supports the following environment variables:
- KDEDIRS: This may set an additional number of directory prefixes to search for resources. The directories should be separated by ':'. The directories are searched in the order they are specified.
- KDEDIR: Used for backwards compatibility. As KDEDIRS but only a single directory may be specified. If KDEDIRS is set KDEDIR is ignored.
- KDEHOME: The directory where changes are saved to. This directory is used to search for resources first. If KDEHOME is not specified it defaults to "$HOME/.kde"
- KDEROOTHOME: Like KDEHOME, but used for the root user. If KDEROOTHOME is not set it defaults to the .kde directory in the home directory of root, usually "/root/.kde". Note that the setting of $HOME is ignored in this case.
- See also:
- KGlobalSettings
Definition at line 125 of file kstandarddirs.h.
Public Member Functions | |
KStandardDirs () | |
virtual | ~KStandardDirs () |
void | addPrefix (const QString &dir) |
void | addXdgConfigPrefix (const QString &dir) |
void | addXdgDataPrefix (const QString &dir) |
bool | addResourceType (const char *type, const QString &relativename) |
bool | addResourceDir (const char *type, const QString &absdir) |
QString | findResource (const char *type, const QString &filename) const |
bool | isRestrictedResource (const char *type, const QString &relPath=QString::null) const |
Q_UINT32 | calcResourceHash (const char *type, const QString &filename, bool deep) const |
QStringList | findDirs (const char *type, const QString &reldir) const |
QString | findResourceDir (const char *type, const QString &filename) const |
QStringList | findAllResources (const char *type, const QString &filter=QString::null, bool recursive=false, bool unique=false) const |
QStringList | findAllResources (const char *type, const QString &filter, bool recursive, bool unique, QStringList &relPaths) const |
void | addKDEDefaults () |
bool | addCustomized (KConfig *config) |
QStringList | resourceDirs (const char *type) const |
QStringList | allTypes () const |
QString | saveLocation (const char *type, const QString &suffix=QString::null, bool create=true) const |
QString | relativeLocation (const char *type, const QString &absPath) |
QString | kfsstnd_prefixes () |
QString | kfsstnd_xdg_conf_prefixes () |
QString | kfsstnd_xdg_data_prefixes () |
QString | localkdedir () const |
QString | localxdgdatadir () const |
QString | localxdgconfdir () const |
Static Public Member Functions | |
static QStringList | systemPaths (const QString &pstr=QString::null) |
static QString | findExe (const QString &appname, const QString &pathstr=QString::null, bool ignoreExecBit=false) |
static int | findAllExe (QStringList &list, const QString &appname, const QString &pathstr=QString::null, bool ignoreExecBit=false) |
static bool | makeDir (const QString &dir, int mode=0755) |
static QString | kde_default (const char *type) |
static QString | kfsstnd_defaultprefix () |
static QString | kfsstnd_defaultbindir () |
static bool | exists (const QString &fullPath) |
static QString | realPath (const QString &dirname) |
static QString | realFilePath (const QString &filename) |
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()) |
QString | locateLocal (const char *type, const QString &filename, bool createDir, const KInstance *instance=KGlobal::instance()) |
Constructor & Destructor Documentation
|
KStandardDirs' constructor. It just initializes the caches. Definition at line 108 of file kstandarddirs.cpp. |
|
KStandardDirs' destructor.
Definition at line 118 of file kstandarddirs.cpp. |
Member Function Documentation
|
Reads customized entries out of the given config object and add them via addResourceDirs().
Definition at line 1508 of file kstandarddirs.cpp. |
|
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 1272 of file kstandarddirs.cpp. |
|
Adds another search dir to front of the
Definition at line 180 of file kstandarddirs.cpp. |
|
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 286 of file kstandarddirs.cpp. |
|
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 255 of file kstandarddirs.cpp. |
|
Adds another search dir to front of the XDG_CONFIG_XXX list of prefixes. This prefix is only used for resources that start with "xdgconf-"
Definition at line 200 of file kstandarddirs.cpp. |
|
Adds another search dir to front of the XDG_DATA_XXX list of prefixes. This prefix is only used for resources that start with "xdgdata-"
Definition at line 220 of file kstandarddirs.cpp. |
|
This function will return a list of all the types that KStandardDirs supports.
Definition at line 157 of file kstandarddirs.cpp. |
|
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 352 of file kstandarddirs.cpp. |
|
Checks for existence and accessability of a file or directory. Faster than creating a QFileInfo first.
Definition at line 450 of file kstandarddirs.cpp. |
|
Finds all occurrences of an executable in the system path.
Definition at line 968 of file kstandarddirs.cpp. |
|
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 619 of file kstandarddirs.cpp. |
|
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 675 of file kstandarddirs.cpp. |
|
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 378 of file kstandarddirs.cpp. |
|
Finds the executable in the system path. A valid executable must be a file and have its executable bit set.
Definition at line 919 of file kstandarddirs.cpp. |
|
Tries to find a resource in the following order:.
Definition at line 317 of file kstandarddirs.cpp. |
|
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 412 of file kstandarddirs.cpp. |
|
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 123 of file kstandarddirs.cpp. |
|
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 1023 of file kstandarddirs.cpp. |
|
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 1640 of file kstandarddirs.cpp. |
|
Definition at line 1652 of file kstandarddirs.cpp. |
|
Definition at line 1646 of file kstandarddirs.cpp. |
|
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 1155 of file kstandarddirs.cpp. |
|
Expands all symbolic links and resolves references to '/.
/', '/../' and extra '/' characters in
Definition at line 703 of file kstandarddirs.cpp. |
|
Expands all symbolic links and resolves references to '/.
/', '/../' and extra '/' characters in
Definition at line 685 of file kstandarddirs.cpp. |
|
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 1133 of file kstandarddirs.cpp. |
|
This function is used internally by almost all other function as it serves and fills the directories cache.
Definition at line 782 of file kstandarddirs.cpp. |
|
Finds a location to save files into for the given type in the user's home directory.
Definition at line 1076 of file kstandarddirs.cpp. |
|
Returns a QStringList list of pathnames in the system path.
Definition at line 873 of file kstandarddirs.cpp. |
The documentation for this class was generated from the following files: