• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Finding the executable path in a foundation tool.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Finding the executable path in a foundation tool.


  • Subject: Finding the executable path in a foundation tool.
  • From: James Quick <email@hidden>
  • Date: Tue, 8 Jul 2003 15:50:58 -0400

For a Cocoa application
[[NSBundle mainBundle] executablePath];

will return to path to the currently running executable.

Since there is no bundle for a foundation tool, what's the recommended approach.

Would I have to roll my own like this?:

const char *
findMyself(int argc, char **argv)
{
cost char *path = getenv(PATH);

if (argv[0][0] == '/') {
// we were called with an absolute path
// so stat ourselves or do other validation then return
return argv[0];
}
// break up path on colons
// then try to access(3) or stat(2) PathComponent/argv[0]
}

Is there some Macos X ism for this which I have not yet discovered?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Finding the executable path in a foundation tool.
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: Cocoa Command Line Application
  • Next by Date: 64-bit compilation
  • Previous by thread: Info.plist and InfoPlist.strings - how to use?
  • Next by thread: Re: Finding the executable path in a foundation tool.
  • Index(es):
    • Date
    • Thread