Re: Using external data-files in programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
Qt/KDE Developer, Debian User
www.mrunix.de - Unix/Linux programming forum
www.qtforum.org - Qt programming forum

Attachment: pgpf9eLTrbdPp.pgp
Description: signature

___________________________________________________
.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.

[Index of Archives]     [Trinity (TDE) Desktop Users]     [Fedora KDE]     [Fedora Desktop]     [Linux Kernel]     [Gimp]     [GIMP for Windows]     [Gnome]     [Yosemite Hiking]
  Powered by Linux