Re: how to get the location of a program
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/paulf%40aphrodite.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... 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. This email sent to paulf@aphrodite.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Paul Forgey