locate

Locate Functions(3)         Library Functions Manual         Locate Functions(3)



NAME
       Locate Functions -

   Functions
       QString KStandardDirs::locate (const char *type, const QString &filename,
           const KInstance *instance=KGlobal::instance())
       QString KStandardDirs::locateLocal (const char *type, const QString
           &filename, 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
   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 1128
       of file kstandarddirs.cpp.

       References KInstance::dirs(), and KStandardDirs::findResource().

   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 1134 of file kstandarddirs.cpp.

       References KInstance::dirs(), QString::findRev(), QString::left(),
       QString::mid(), and KStandardDirs::saveLocation().




kdecore Library                    28 Jan 2004               Locate Functions(3)