Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [A5] Getting directory exe is running in

Credits go to Arthur Kalliokoski for helping out!
This thread is locked; no one can reply to it. rss feed Print
[A5] Getting directory exe is running in
Neil Roy
Member #2,229
April 2002
avatar

I just wanted to store the path that the executable is running in. When I try and check for a file, it shows it as not being there even though it is in the same folder as the executable, so I am uncertain where it is looking.

When I used some code I found in some of the other posts in these forums, all I got was "\" which is definitely wrong. Now, I can look at argv[0] and that gives me the full path, but it includes the exe filename, also, I doubt this is very cross platform friendly (although I am mainly working with Windows at the moment).

Is there an Allegro 5 function to provide this, or should I parse argv[0] myself?

Thanks.

Thomas Fjellstrom
Member #476
June 2000
avatar

take a look at al_get_standard_path.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Arthur Kalliokoski
Second in Command
February 2005
avatar

  ALLEGRO_PATH *path;
  path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
  al_change_directory(al_path_cstr(path,ALLEGRO_NATIVE_PATH_SEP));

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

jmasterx
Member #11,410
October 2009

Neil Roy
Member #2,229
April 2002
avatar

ALLEGRO_PATH *path;
path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
al_change_directory(al_path_cstr(path,ALLEGRO_NATIVE_PATH_SEP));

Thanks.

That worked.

Edit: I'll create a new thread for my next problem.

Go to: