Re: how to get the location of a program
Re: how to get the location of a program
- Subject: Re: how to get the location of a program
- From: Paul Forgey <email@hidden>
- Date: Tue, 19 Apr 2005 16:26:27 -0700
argv[0] usually gives the full path if you combine it with your initial
directory. That is, is you are in /this/path/here and you run
../there/that/program from the shell, you can infer
/this/path/here/../there/that/program. Despite some problems, realpath
(3) can normalize that into an absolute path.
The best way to read configuration data isn't necessarily from a path
relative to the program. This isn't Windows where you have an .ini
file next to the .exe.
On Apr 19, 2005, at 4:10 PM, w.o.b wrote:
Hi,
Is there a way in OS X to get the full path of a
program where it's being executed?
I need to know the location where the user stores my
program (along with some configuration files), to set
up its running environment.
Things like "getcwd" only work when you run the
program in a Terminal. When you run it from Desktop or
Finder, the "getcwd" gives the current user home
directory.. "argv[0]" sometimes gives full path, but
sometimes just gives the program's name itself..
Thank you very much for help!
Best,
Owen
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden