Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Prefect

getexename(): Get the actual name of current executable

This topic is 5533 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I distribute a game, I want it to be simple for the user: just untar an archive into a single directory, run the executable inside that directory. The thing that troubled me was how to find out where the game data files are once the game is running, and I thought I''d share my findings. The two obious, well-known possibilities are: Use paths relative to the current working directory. Unfortunately, the user has to set the CWD explicitly, and this usually fails when the game is started from a GUI. Second possibility is to use argv[0] as a basis, but that might now work, especially when symlinks are involved. I searched around a bit and noticed /proc//exe, a link that points to the actual executable filename of the program running in process . This link cannot be fooled by symlinks, scripts or messing with the args array when calling execve(). So I''ve written a small function to read out that link, you can find it here. Unfortunately, I don''t think it''s too portable to anything that''s not Linux, but it can serve as a nice fallback when the other two methods fail. cu, Prefect

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!