Using external data-files in programs

Kevin Krammer kevin.krammer at gmx.at
Sun Jul 25 15:20:07 BST 2004


On Saturday 24 July 2004 20:38, Erlend Hamberg wrote:
> How can I write programs that use external data-files which can be run
> from konqueror by (double) clicking on them?
> I usually have sounds and images in a directory called "data" and open
> the files from my program using a relative path, but when I run them
> from konqueror the program can't open the files in "data/". So
> whenever I give a program to some friends or something they have to
> open a terminal and browse to the directory containing the executable
> file before they can run the program.

Not sure if I understood you right.
You ask about how to manage standard data files of an application, for example 
icons, etc.

KDE programs do this through the KStandardDirs class or the convenience 
function locate() (also declared in kstandarddirs.h)

A program not using kdelibs can use the freedesktop.org base dir specification
http://freedesktop.org/Standards/basedir-spec
to install its data files into locations where it can find them at runtime.

Another option is to start a wrapper script instead of the real application 
executable and have the wrapper script switch the workign directory so that 
paths to resources can be relative.

Other options would be to search standard paths like /usr/share/appname or 
/usr/local/share/appname or read the base path from a config file.

Cheers,
Kevin

-- 
Kevin Krammer <kevin.krammer at gmx.at>
Qt/KDE Developer, Debian User
www.mrunix.de - Unix/Linux programming forum
www.qtforum.org - Qt programming forum
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
URL: <http://mail.kde.org/pipermail/kde/attachments/20040725/5c6daba9/attachment.sig>
-------------- next part --------------
___________________________________________________
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.


More information about the kde mailing list