<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://techbase.kde.org/skins/common/feed.css?0.2"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://techbase.kde.org/index.php?title=Development/Architecture/KDE3/Standard_Resources/en&amp;feed=atom&amp;action=history</id>
		<title>Development/Architecture/KDE3/Standard Resources/en - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://techbase.kde.org/index.php?title=Development/Architecture/KDE3/Standard_Resources/en&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/index.php?title=Development/Architecture/KDE3/Standard_Resources/en&amp;action=history"/>
		<updated>2013-06-20T08:38:44Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.2</generator>

	<entry>
		<id>http://techbase.kde.org/index.php?title=Development/Architecture/KDE3/Standard_Resources/en&amp;diff=74038&amp;oldid=prev</id>
		<title>FuzzyBot: Updating to match new version of source page</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/index.php?title=Development/Architecture/KDE3/Standard_Resources/en&amp;diff=74038&amp;oldid=prev"/>
				<updated>2012-07-26T19:18:39Z</updated>
		
		<summary type="html">&lt;p&gt;Updating to match new version of source page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''KDE Architecture - Accessing Standard Resource Directories'''&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
KDE offers several ways to access the files that your application&lt;br /&gt;
installed on your user's hard disc while making it transparent&lt;br /&gt;
to you where the data really are. To allow the user (or adminstrator&lt;br /&gt;
in most cases) to move files where he sees them fit best, KDE offers&lt;br /&gt;
a list of different resource types for which a different search path&lt;br /&gt;
is assigned to. You may have heard of the environment variable &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;&lt;br /&gt;
to lookup executables or &amp;lt;tt&amp;gt;MANPATH&amp;lt;/tt&amp;gt; for looking up man pages. You wouldn't&lt;br /&gt;
expect ''man'' to lookup man pages in &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Similiar to that concept KDE seperates search paths for different&lt;br /&gt;
things to make it simpler to add paths for a specific resource without&lt;br /&gt;
making a lookup for another resource unnecessary slower and without&lt;br /&gt;
requiring you to put everything into one directory.&lt;br /&gt;
&lt;br /&gt;
The types of resources KDE offers are&lt;br /&gt;
&lt;br /&gt;
* apps - applications menu (.desktop files)&lt;br /&gt;
* cgi - CGIs to run from khelpcenter* config - configuration files&lt;br /&gt;
* data - where applications store data* exe - executables installed privatly for KDE's use&lt;br /&gt;
* html - HTML documentation* icon - application icons to appear in the window manager or the panel&lt;br /&gt;
* lib - libraries and to be dlopened modules* locale - translation files for KLocale&lt;br /&gt;
* mime - mime types* sound - application sounds&lt;br /&gt;
* toolbar - toolbar pictures&lt;br /&gt;
* wallpaper - wallpapers&lt;br /&gt;
&lt;br /&gt;
For all of them exist also Makefile aliases that configures created by the development&lt;br /&gt;
tools provided for KDE (e.g. kdevelop) will know about.&lt;br /&gt;
&lt;br /&gt;
== KStandardDirs ==&lt;br /&gt;
&lt;br /&gt;
This is one of the most central classes in kdelibs as&lt;br /&gt;
it provides a basic service: it knows where the files&lt;br /&gt;
reside on the user's harddisk. And it's meant to be the&lt;br /&gt;
only one that knows - to make the real location as&lt;br /&gt;
transparent as possible to both the user and the applications.&lt;br /&gt;
&lt;br /&gt;
For this it encapsulates all informations from the application&lt;br /&gt;
and applications always refer to a file with a resource type&lt;br /&gt;
(e.g. apps) and a filename (e.g. {{path|Home.desktop}}). In an ideal world&lt;br /&gt;
the application would make no assumption where this file is and&lt;br /&gt;
leaves it up to &amp;lt;tt&amp;gt;KStandardDirs::findResource(&amp;quot;apps&amp;quot;, &amp;quot;Home.desktop&amp;quot;)&amp;lt;/tt&amp;gt;&lt;br /&gt;
to apply this knowledge.&lt;br /&gt;
&lt;br /&gt;
The main idea behind {{class|KStandardDirs}} is that there are several&lt;br /&gt;
toplevel prefixes where files are below. One of this prefixes is&lt;br /&gt;
the one where the user installed kdelibs into, one where the&lt;br /&gt;
application has been installed to and one is {{path|$HOME/.kde}}, but there&lt;br /&gt;
may be even more. Under these prefixes there are several well&lt;br /&gt;
defined suffixes where specific resource types are to be found.&lt;br /&gt;
For example for toolbar icons that is {{path|share/toolbar}} and&lt;br /&gt;
{{path|share/apps/&amp;amp;lt;appname&amp;amp;gt;/pics}}.&lt;br /&gt;
&lt;br /&gt;
So the search algorithm basicly appends to each prefix each registered&lt;br /&gt;
suffix and tries to locate the file there.&lt;br /&gt;
To make the thing even more complex, it's also possible to register&lt;br /&gt;
absolute paths that KStandardDirs looks up after not finding anything&lt;br /&gt;
in the former steps. They can be useful if the user wants to provide&lt;br /&gt;
specific directories that aren't in his {{path|$HOME/.kde}} directory as&lt;br /&gt;
example for icons.&lt;br /&gt;
&lt;br /&gt;
=== On the usage of &amp;lt;tt&amp;gt;locate&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;locateLocal&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
locate and locateLocal are both convenient functions that make the use of&lt;br /&gt;
KStandardDirs as simple as possible. You have however the possibility to&lt;br /&gt;
use the full power of KStandardDirs without them.&lt;br /&gt;
&lt;br /&gt;
Typical KDE applications use resource files in one out of three ways:&lt;br /&gt;
&lt;br /&gt;
* A resource file is read but is never written. A system default is supplied but the user can override this default in his local .kde directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp-qt&amp;quot;&amp;gt;&lt;br /&gt;
// Code example&lt;br /&gt;
myFile = locate(&amp;quot;appdata&amp;quot;, &amp;quot;groups.lst&amp;quot;)&lt;br /&gt;
myData = myReadGroups(myFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* A resource file is read and written. If the user has no local version of the file the system default is used. The resource file is always written to the users local .kde directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp-qt&amp;quot;&amp;gt;&lt;br /&gt;
// Code example&lt;br /&gt;
myFile = locate(&amp;quot;appdata&amp;quot;, &amp;quot;groups.lst&amp;quot;)&lt;br /&gt;
myData = myReadGroups(myFile);&lt;br /&gt;
...&lt;br /&gt;
doSomething(myData);&lt;br /&gt;
...&lt;br /&gt;
myFile = locateLocal(&amp;quot;appdata&amp;quot;, &amp;quot;groups.lst&amp;quot;);&lt;br /&gt;
myWriteGroups(myFile, myData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* A resource file is read and written. No system default is used if the user has no local version of the file. The resource file is always written to the users local {{path|.kde}} directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp-qt&amp;quot;&amp;gt;&lt;br /&gt;
// Code example&lt;br /&gt;
myFile = locateLocal(&amp;quot;appdata&amp;quot;, &amp;quot;groups.lst&amp;quot;);&lt;br /&gt;
myData =  myReadGroups(myFile);&lt;br /&gt;
...&lt;br /&gt;
doSomething(myData);&lt;br /&gt;
...&lt;br /&gt;
myFile = locateLocal(&amp;quot;appdata&amp;quot;, &amp;quot;groups.lst&amp;quot;);&lt;br /&gt;
myWriteGroups(myFile, myData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Initial Author:'' Stephan Kulow [mailto:coolo@kde.org (coolo@kde.org)]&lt;br /&gt;
&lt;br /&gt;
[[Category:KDE3]]&lt;br /&gt;
[[Category:Architecture]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>	</entry>

	</feed>