Re: getcwd acts different in xcode/finder
Re: getcwd acts different in xcode/finder
- Subject: Re: getcwd acts different in xcode/finder
- From: Alastair Houghton <email@hidden>
- Date: Sun, 7 Dec 2003 16:32:54 +0000
On 7 Dec 2003, at 16:19, Brian Barnes wrote:
> On Dec 7, 2003, at 7:26 AM, Alastair Houghton wrote:
>
>> If you want to know where your program is in the filesystem, you can
>> use the CFBundle or NSBundle APIs (depending on whether you're using
>> Cocoa or not).
>
> That's what I use now, I just wanted to point out that this is a
> change from 10.2.x -- there, getcwd would always return the directory
> the app bundle was in, as it does when running under XCode.
Like I said, it would always return the current directory, which was
copied from the parent process. For example, if I go to Terminal and
enter
cd /etc
/Applications/TextEdit.app/Contents/MacOS/TextEdit
it starts TextEdit. But if TextEdit calls getcwd(), then, *even on
Jaguar*, it will get "/etc" and *not* "/Applications" or whatever you
were relying on. OK, most users don't start applications from the
command line like this (for one thing, it's usually easier to use the
"open" command), but the point is that using getcwd() has *never* been
a reliable way to determine the location of the application.
Even if you assumed that users aren't using Terminal, how about apps
started from the Dock? Or from third-party application launchers? I'm
sure many of them don't chdir() to the applications' directory before
running it.
Kind regards,
Alastair.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.