| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# Locate Functions

## Functions
KDECORE_EXPORT QString | KStandardDirs::locate (const char *type, const QString &filename, const KInstance *instance=KGlobal::instance())
KDECORE_EXPORT QString | KStandardDirs::locateLocal (const char *type, const QString &filename, const KInstance *instance=KGlobal::instance())
KDECORE_EXPORT QString | KStandardDirs::locateLocal (const char *type, const QString &filename, bool createDir, const KInstance *instance=KGlobal::instance())

## Detailed Description

On The Usage Of 'locate' and 'locateLocal'

Typical KDE 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:

        // Code example
        myFile = locate("appdata", "groups.lst");
        myData =  myReadGroups(myFile); // myFile may be null

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.

        // Code example
        myFile = locate("appdata", "groups.lst")
        myData =  myReadGroups(myFile);
        ...
        doSomething(myData);
        ...
        myFile = locateLocal("appdata", "groups.lst");
        myWriteGroups(myFile, myData);

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.

        // Code example
        myFile = locateLocal("appdata", "groups.lst");
        myData =  myReadGroups(myFile);
        ...
        doSomething(myData);
        ...
        myFile = locateLocal("appdata", "groups.lst");
        myWriteGroups(myFile, myData);

## Function Documentation

KDECORE_EXPORT QString locate | ( | const char * | type,
|  | const QString & | filename,
|  | const KInstance * | instance = `KGlobal::instance()`
| ) | `[related, inherited]`

| This function is just for convenience. It simply calls instance->dirs()->findResource(type, filename). Definition at line 1648 of file kstandarddirs.cpp.

KDECORE_EXPORT QString locateLocal | ( | const char * | type,
|  | const QString & | filename,
|  | const KInstance * | instance = `KGlobal::instance()`
| ) | `[related, inherited]`

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

KDECORE_EXPORT QString locateLocal | ( | const char * | type,
|  | const QString & | filename,
|  | bool | createDir,
|  | const KInstance * | instance = `KGlobal::instance()`
| ) | `[related, inherited]`

| This function is much like locate. No check is made if the specified filename actually exists. Missing directories are created if `createDir` 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::findRev(), QString::left(), and QString::mid().

This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:19:14 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003