\section{Locate Functions}
\label{group__locates}\index{Locate Functions@{Locate Functions}}
\subsection*{Functions}
\begin{CompactItemize}
\item 
{\bf QString} {\bf KStandard\-Dirs::locate} (const char $\ast$type, const {\bf QString} \&filename, const {\bf KInstance} $\ast$instance=KGlobal::instance())
\item 
{\bf QString} {\bf KStandard\-Dirs::locate\-Local} (const char $\ast$type, const {\bf QString} \&filename, const {\bf KInstance} $\ast$instance=KGlobal::instance())
\end{CompactItemize}


\subsection{Detailed Description}
On The Usage Of 'locate' and 'locate\-Local'

Typical {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} applications use resource files in one out of three ways:

1) 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:



\footnotesize\begin{verbatim}    // Code example
    myFile = locate("appdata", "groups.lst");
    myData =  myReadGroups(myFile); // myFile may be null
\end{verbatim}\normalsize


2) 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.



\footnotesize\begin{verbatim}    // Code example
    myFile = locate("appdata", "groups.lst")
    myData =  myReadGroups(myFile);
    ...
    doSomething(myData);
    ...
    myFile = locateLocal("appdata", "groups.lst");
    myWriteGroups(myFile, myData);
\end{verbatim}\normalsize


3) 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 .kde directory.



\footnotesize\begin{verbatim}    // Code example
    myFile = locateLocal("appdata", "groups.lst");
    myData =  myReadGroups(myFile);
    ...
    doSomething(myData);
    ...
    myFile = locateLocal("appdata", "groups.lst");
    myWriteGroups(myFile, myData);
\end{verbatim}\normalsize


\subsection{Function Documentation}
\index{locates@{locates}!locate@{locate}}
\index{locate@{locate}!locates@{locates}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} locate (const char $\ast$ {\em type}, const {\bf QString} \& {\em filename}, const {\bf KInstance} $\ast$ {\em instance} = KGlobal::instance())\hspace{0.3cm}{\tt  [related, inherited]}}\label{group__locates_a0}


This function is just for convenience. It simply calls instance-$>$dirs()-$>${\bf find\-Resource}{\rm (p.\,\pageref{classKStandardDirs_a5})}(type, filename). 

Definition at line 1128 of file kstandarddirs.cpp.

References KInstance::dirs(), and KStandard\-Dirs::find\-Resource().\index{locates@{locates}!locateLocal@{locateLocal}}
\index{locateLocal@{locateLocal}!locates@{locates}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} locate\-Local (const char $\ast$ {\em type}, const {\bf QString} \& {\em filename}, const {\bf KInstance} $\ast$ {\em instance} = KGlobal::instance())\hspace{0.3cm}{\tt  [related, inherited]}}\label{group__locates_a1}


This function is much like locate. However it returns a filename suitable for writing to. No check is made if the specified filename actually exists. Missing directories are created. If filename is only a directory, without a specific file, filename must have a trailing slash. 

Definition at line 1134 of file kstandarddirs.cpp.

References KInstance::dirs(), QString::find\-Rev(), QString::left(), QString::mid(), and KStandard\-Dirs::save\-Location().