Looking for a way to get the executable's full path and filename. *nix solutions in particular, but Windows solutions, if you have them handy, would also be nice (though I have no immediate use for them). Using the commandline (argv) is okay, but alternatives welcome/preferred.
So far the only way I can think of to get the app name is via argv... and as for the path... the only way I've come up with is to take argv if it has a full path -- and if it doesn't, start searching each and every dir from getenv("PATH") until I find the first matching filename. Not exactly preferable, but I suppose it'd work.
If anyone has a simpler way I'd love to hear it! Thanks in advance.
Excellent! Thanks very much Duoas. The documentation linked to raises a few questions, but I can answer those myself by testing (that HP page is a nightmare!). Much appreciated!
@everyone, re: getcwd(). I thought about this too but I don't think it works if the app is in a PATH directory (ie /usr/share/) and is run via commandline without any path, since the cwd in that case would be whatever directory you were cd'd to at the time (and not necessarily the exe's directory)