osx - How can I programmatically detect what directory an executable is in when it is run? -


i've been playing around command line tools in xcode , have stumbled upon have no clue how handle.

if build tool, , put executable on desktop, possible run executable , have output directory 'self' in? meaning, can log 'hey in: /users/me/desktop'?

and if move file elsewhere, have change?

is there sort of environment variable use this?

thanks!

ok, wow. didn't think i'd able find answer quick here it is. turns out location of file 1 of arguments passed main.

here code:

    (int i=0; i<argc; i++)     {         nslog(@"argv[%d] = '%s'", i, argv[i]);     } 

interesting!


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -