Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems launching an FLTK carbon application - slight thread drift...



This is going off-topic a bit, but might be pertinent?
I offer it here in the hope that others may find it useful, anyway...

>
> I discovered that I can run the tunneler from the Terminal. 
> I first cd
> to:
>
> /Applications/Tunneler.app/Contents/MacOS
>
>
> And then I run:
>
> data/metropipe_tunneler
>
>
> (I have to run it from above the data directory because that's where
> the tunnels.conf file is.)


A thing I have found handy in the past, is to use:

extern int _NSGetExecutablePath(char *buf, unsigned long *bufsize);

This (apparently undocumented) call allows you to find out the actual path to you executable, and since you "know" the layout of your bundle, that allows you to generate the "true" paths to all your related .conf files etc...

In this way, wherever (or however) the app is invoked, and whatever default environment or path it inherits, you can still figure out where your config and settings are stored.

Is it possible you app dies simply because, when clicking the icons, cwd() is set to "/" ?

Anyway, fwiw, something like this might help:

	int status = -1;
	char *given_path = malloc(MAXPATHLEN + 2);
	if (!given_path) return status;

	pathsize = MAXPATHLEN + 2;
	result = _NSGetExecutablePath(given_path, &pathsize);
	if (result == 0)
	{ /* OK, we got something - now try and resolve the real path... */
		if (realpath(given_path, pname) != NULL)
		{
			if ((access(pname, 0) == 0))
				status = 0; /* file exists, return OK */
		}
	}
	free (given_path);
	return status;

I wouldn't use this code as is, it's a bit sloppy, but you get the idea.

HTH,
--
Ian

********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/unix-porting/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.