[kde-edu]: findResource() vs. locate()

Albert Astals Cid aacid at kde.org
Mon Mar 26 20:30:18 CEST 2007


A Dilluns 26 Març 2007, Jason Harris va escriure:
> Hello,
>
> I'm sure this is some silly misunderstanding on my part.  Consider the
> following code:
>
>   KStandardDirs ksd;
>   kDebug() << "findResource(): " << ksd.findResource( "appdata",
> "clines.dat" ) << endl;
>   kDebug() << "locate(): " << KStandardDirs::locate( "appdata",
> "clines.dat" ) << endl;
>
> The output of this is:
>
>   kstars: findResource():
>   kstars: locate(): /opt/kde4/share/apps/kstars/clines.dat
>
> Does anyone know why findResource() returns an empty string here, rather
> than the path to clines.dat ?

Seems a bug as "appdata" is only defined in 
KStandardDirs *KComponentData::dirs() const
that is used by locate() but not by the KStandardDirs constructor. 

You maybe should notify the authors of those classes that there is a strange 
behaviour when using appdata.

On the other hand appdata is not defined on the types "supported" by 
kstandarddirs.h 

 * apps - Applications menu (.desktop files).
 * cache - Cached information (e.g. favicons, web-pages)
 * cgi - CGIs to run from kdehelp.
 * config - Configuration files.
 * data - Where applications store data.
 * emoticons - Emoticons themes
 * exe - Executables in $prefix/bin. 
 * html - HTML documentation.
 * icon - Icons, see KIconLoader.
 * kcfg - KConfigXT config files.
 * lib - Libraries.
 * locale - Translation files for KLocale.
 * mime - Mime types defined by KDE-specific .desktop files.
 * module - Module (dynamically loaded library).
 * qtplugins - Qt plugins (dynamically loaded objects for Qt)
 * services - Services.
 * servicetypes - Service types.
 * sound - Application sounds.
 * templates - Templates for the "Create new file" functionality.
 * wallpaper - Wallpapers.
 * tmp - Temporary files (specific for both current host and current user)
 * socket - UNIX Sockets (specific for both current host and current user)
 * xdgconf-menu - Freedesktop.org standard location for menu layout (.menu) 
files.
 * xdgdata-apps - Freedesktop.org standard location for application desktop 
files.
 * xdgdata-dirs - Freedesktop.org standard location for menu descriptions 
(.directory files).
 * xdgdata-mime - Freedesktop.org standard location for MIME type definitions.
 * xdgdata-icon - Freedesktop.org standard location for icons.
 * xdgdata-pixmap - Gnome-compatibility location for pixmaps.

So it may well not be a bug. And only that it should be clearly stated that 
appdata only can be used though locate?

If you change to

ksd.findResource( "data/MyAppName", "clines.dat" );
KStandardDirs::locate( "data/MyAppName", "clines.dat" );

it will work on both.

Albert


>
> thanks,
> Jason
> _______________________________________________
> kde-edu mailing list
> kde-edu at mail.kde.org
> https://mail.kde.org/mailman/listinfo/kde-edu




More information about the kde-edu mailing list