Unusual problem with paths

Sorry to bother with kinda dumb question, but I was trying to load some “experimental stuff” from a file (a prototype of a homemade engine), but I got caught in action.

The question is: How to work with paths in Linux? I remember that in Windows I used to code something similar to Vb’s App.path, and working it out, but on Linux, I could only load my file writting in the source line the whole path (/home/mateus/dev/pocket2d/bg.bmp), a very non-portable way to do things…
Help!

Thanks in advance.

Take a look at

$ man setenv

You will probably have to do something like

#include <stdlib.h>

setenv( “PATH”, “/my/new/path”, 1 );

But if you’re executable is

/foo/exec

and you want to load

/foo/bg.bmp

you should be able to do something like

#include

ifstream fin(“bg.bmp”);

No, don’t add paths to the PATH env variable! that’s bad bad bad!

Just use the path from the main() arguments and load everything from pathvar + “/data/blah.png”

Or something like that, it’s easy.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.