Re: getcwd acts different in xcode/finder
Re: getcwd acts different in xcode/finder
- Subject: Re: getcwd acts different in xcode/finder
- From: Clark Cox <email@hidden>
- Date: Sun, 7 Dec 2003 15:55:30 -0500
On Dec 07, 2003, at 11:19, Brian Barnes wrote:
> On Dec 7, 2003, at 7:26 AM, Alastair Houghton wrote:
>
>> On 6 Dec 2003, at 22:04, Brian Barnes wrote:
>>
>>> I don't know if this happened because of xcode or 10.3; but that's
>>> when it changed for me.
>>>
>>> I'm building an application into a pre-build bundle in the directory
>>> /users/bbarnes/dim3. When running under XCode, getcwd returns
>>> "/users/bbarnes/dim3". When running from the finder, it returns
>>> "/"!
>>>
>>> This is driving me crazy :) Xcode gets it right but the finder
>>> doesn't?
>>
>> No, they're both right. getcwd() displays the process' current
>> directory. That has absolutely nothing whatsoever to do with where
>> the process' executable is in the filesystem. The current directory
>> is inherited from the parent process; it's just luck that means that
>> Xcode's current directory happens to be the one containing your
>> executable.
>>
>> 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. So this
> must be a change somewhere in the system. Maybe it's something I
> shouldn't have depended on, but it worked in earlier versions, so this
> is just a warning :)
Actually, it is not a change. I can assure you that in 10.2 (and
probably before), the Finder used "/" as the current working directory
when launching applications. And, of course, if you launch your app
from the command line, the current working directory is whatever
directory you were working in in the shell.
--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html
[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.