\section{Locate Functions}
\label{group__locates}\index{Locate Functions@{Locate Functions}}
\subsection*{Functions}
\begin{CompactItemize}
\item 
KDECORE\_\-EXPORT {\bf QString} {\bf KStandard\-Dirs::locate} (const char $\ast$type, const {\bf QString} \&filename, const {\bf KInstance} $\ast$instance=KGlobal::instance())
\item 
KDECORE\_\-EXPORT {\bf QString} {\bf KStandard\-Dirs::locate\-Local} (const char $\ast$type, const {\bf QString} \&filename, const {\bf KInstance} $\ast$instance=KGlobal::instance())
\item 
KDECORE\_\-EXPORT {\bf QString} {\bf KStandard\-Dirs::locate\-Local} (const char $\ast$type, const {\bf QString} \&filename, bool create\-Dir, 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}KDECORE\_\-EXPORT {\bf QString} locate (const char $\ast$ {\em type}, const {\bf QString} \& {\em filename}, const {\bf KInstance} $\ast$ {\em instance} = {\tt KGlobal::instance()})\hspace{0.3cm}{\tt  [related, inherited]}}\label{group__locates_ga0}


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

Definition at line 1648 of file kstandarddirs.cpp.\index{locates@{locates}!locateLocal@{locateLocal}}
\index{locateLocal@{locateLocal}!locates@{locates}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KDECORE\_\-EXPORT {\bf QString} locate\-Local (const char $\ast$ {\em type}, const {\bf QString} \& {\em filename}, const {\bf KInstance} $\ast$ {\em instance} = {\tt KGlobal::instance()})\hspace{0.3cm}{\tt  [related, inherited]}}\label{group__locates_ga1}


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 1654 of file kstandarddirs.cpp.\index{locates@{locates}!locateLocal@{locateLocal}}
\index{locateLocal@{locateLocal}!locates@{locates}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KDECORE\_\-EXPORT {\bf QString} locate\-Local (const char $\ast$ {\em type}, const {\bf QString} \& {\em filename}, bool {\em create\-Dir}, const {\bf KInstance} $\ast$ {\em instance} = {\tt KGlobal::instance()})\hspace{0.3cm}{\tt  [related, inherited]}}\label{group__locates_ga2}


This function is much like locate. No check is made if the specified filename actually exists. Missing directories are created if {\tt create\-Dir} is true. If filename is only a directory, without a specific file, filename must have a trailing slash. 

Definition at line 1660 of file kstandarddirs.cpp.

References QString::find\-Rev(), QString::left(), and QString::mid().