need help with some directory paths

I did ask this on stack overflow but I cussed them out cause I hate that place.

Anyway here's my question I posted there and I rather have people here on cplusplus help me.

Im not sure what it is called but ill do my best to explain it. I did search here on stack exchange and found this answer for an allias for path but i dont want to set a variable for it and i already know that. create alias for path

What I need is and its been along time since I seen it but its used with a % or $ or something that when the program runs from the directory it knows where the directory for the game files are. It didn't matter what the directory the program is in as long as the directory 'gameFiles' is in that directory it will work.

Here's my path:

"/storage/emulated/0/MyGame/MyHackGame/jni/gameFiles/oscom.txt"

I think its something like:

"%or$/gameFiles/oscom.txt"

The main problem is I have a project on source forge and don't want my developers to have to change these paths like 100 times to run the program and then I'll have to change them back.

Also iam using aide for android to make the program and using the standard c++ libaray do this might be difficult to do. I'm not even sure if I can add libarays with aide and native code or how to do it.

After thinking about it this won't work on windows anyway. I guess I need a separate build. The windows paths are like C:\windows\directory. Right?
Last edited on
I'm pretty sure '.' is what you are looking for. It tells the system to use the current working directory. This will work on Windows as well.
So it would look like "./gameFiles/oscom.txt"
That looks right to me. Test it out, let us know if this is the one you were thinking of.
Ok sounds good
ifstream welfile ("./gameFiles/JsonWelcomeText.txt");
if (welfile.is_open())
{
for(int i=0; !welfile.eof(); i++)
{
getline (welfile,line1);
msleep(100);
cout << line1 << endl;

}
}
welfile.close();

Ok I tied it on this and it should bring up some ASCII art for the game at start. Well it didn't. Your answer maybe right but I don't know why it didn't work. There were no errors.
Maybe it didn't work cause I'm using aide in android. I just built the code and ran it in the console?
You think it would work if it was built in windows or Linux?
I'm pretty sure that it would. Do you have a VM or anything that you could try it out on?
No but I got other people working on the project and they can try it. I need to get a laptop with a windows/Linux boot on it.
This question was asked:

s there a platform-agnostic and filesystem-agnostic method to obtain the full path of the directory from where a program is running using C/C++? Not to be confused with the current working directory.

I think this is more long the lines of what I need. The problem seem to be that the answer will be is os specific. That's not good for me but expected. Most os systems handle files and directories different so I may be out of luck on this one.
Last edited on
Topic archived. No new replies allowed.