• 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
Re: getcwd acts different in xcode/finder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getcwd acts different in xcode/finder


  • Subject: Re: getcwd acts different in xcode/finder
  • From: Thomas Dibble <email@hidden>
  • Date: Mon, 8 Dec 2003 10:44:36 -0800

Correct, the Finder (Puma, Jaguar, AND Panther) always starts processes in root (/), which is different from Windows certainly (which starts apps in their executable directories by default I believe) but not too different from several other *nix's (KDE and Gnome, I believe, default to starting with a / working folder). You should be able to change the debugger/run settings in the IDE to mimic this behavior (just set the starting directory to / instead of the output or project folders). Programatically, think of the GUI as always sitting in the root directory and starting your app by executing /Applications/MyApp.app/Contents/MacOS/MyApp.

Generally, if you rely on your app's location on hard disk I believe you should get that info from argv[0] or the related Mac OS system calls, not from getcwd. You may *change* the cwd programatically and then use getcwd for whatever reason, but it's not a useful tool for determining the location of your app (it is useful for command-line tools, of course).

I have an app which needs to get it's directory; it starts in root on 10.1, 10.2, and 10.3 (I have all three sitting here running and just verified this). If your app behaved differently the only thing I can think of is that you had a chunk of code in the main() (or somewhere else which got called during app startup) which set the cwd to the app folder. This could have been in any of the frameworks you might have called into before using getcwd. Personally, my app is a C++/ObjC app which uses POSIX libraries for the most part (Cocoa, Foundation, CoreServices and AppKit are linked in; I make just enough calls prior to where I have getcwd() to bring up a window), so it's quite possible that your app called into a bit of code which had changed the cwd in an earlier release and does not any longer, while mine never hit on any such "unexpected feature".

				---- Tom Dibble

On Saturday, December 6, 2003, at 02:04 PM, 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?

What's going on here?

[>] Brian
_______________________________________________
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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: getcwd acts different in xcode/finder
      • From: Alastair Houghton <email@hidden>
  • Prev by Date: J2EE Build weirdness
  • Next by Date: Re: getcwd acts different in xcode/finder
  • Previous by thread: Re: getcwd acts different in xcode/finder
  • Next by thread: Re: getcwd acts different in xcode/finder
  • Index(es):
    • Date
    • Thread