Using external data-files in programs
Michael Mauch
michael.mauch at gmx.de
Sun Jul 25 22:42:41 BST 2004
Erlend Hamberg wrote:
> If I make a small SDL/OpenGL program using external data files for
> textures and music, zip it and send it to my friends those running
> Windows can just unzip it and double-click the executable to run it. But
> those using Linux with KDE, or Gnome for that sake, has to open a
> terminal-emulator and 'cd' to the dir containing the executable file and
> then run it by typing './program' and pressing enter. If they
> double-click it in konqueror the program can't find the files in
> 'data/'.
Apparently konqueror starts all programs in the user's home directory,
not in the directory where the program is. This is generally good,
because normally you don't stuff your data into a program directory (you
don't want to end up with the same bloody mess like on Windows).
> > 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.
> How can I find out where the executable is located then?
You could try looking at argv[0]. Although this method is generally
considered unportable, unreliable and whatever, it seems to work here
with Konqueror (didn't try with Nautilus).
#include <stdio.h>
int main(int argc, char* argv[])
{
char cmd[1024];
sprintf(cmd,"xterm -e 'echo \"argv[0]: %s\"; read'",argv[0]);
system(cmd);
}
Regards...
Michael
___________________________________________________
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