RE: FW: NSFileManager
RE: FW: NSFileManager
- Subject: RE: FW: NSFileManager
- From: "Tommy Braas" <email@hidden>
- Date: Sun, 24 Jun 2001 11:17:02 -0700
Thank you!
Although I beg to differ ( maybe ) on what is passed in from the Finder. I think this is a bug and I will report it as such.
I proceeded to read what is passed in into the main function. argv[0] contains the full path to the executable inside the bundle ( not suprising ). I was toying with the thought of tokenizing it to get what I wanted. Thanks to your and Aaron's help I don't have to!
I am trying to learn Cocoa using the O'Reilly book. As you have probably already realized, I am experiencing that book's shortcomings... sigh...
Thanks guys!!!
\tommy
>
-----Original Message-----
>
From: Greg Titus [mailto:email@hidden]
>
Sent: Sunday, 24 June, 2001 11:04 AM
>
To: Tommy Braas
>
Cc: Cocoa-Dev
>
Subject: Re: FW: NSFileManager
>
>
>
>
On Sunday, June 24, 2001, at 10:40 AM, Aaron Tuller wrote:
>
>
> an easier way to get to files in your Resources directory is [[NSBundle
>
> mainBundle] resourcePath]
>
>
>
> -aaron
>
>
>
> At 10:08 AM -0700 6/24/01, Tommy Braas wrote:
>
>> I am trying to use NSFileManager to get the current working directory
>
>> path from a Cocoa application. I don't want to throw up a file chooser
>
>> as I am trying to read a preferences file from within my application
>
>> package. Whenever I use the following code the output is "/" when I
>
>> run the application by double-clicking.
>
>
Aaron is right, but to explain a little more what is happening:
>
>
The NSFileManager -currentDirectoryPath method returns the current
>
working directory that is passed in to the app as part of its
>
environment when it is started up. This has nothing to do with where the
>
Application is actually installed. ProjectBuilder explicitly sets this
>
to the app directory, Finder explicitly sets this to "/", if you started
>
the app from the command-line, the result from this method would be
>
whatever directory you were currently in in the shell when you started
>
the app.
>
>
Since you say you are trying to read a preferences file inside your app,
>
you should use [[NSBundle mainBundle] pathForResource:ofType:], which
>
will return the correct path inside your application, and also do the
>
correct thing (look inside language directories) if the file you are
>
looking for can be localized for different languages.
>
>
Hoep this helps,
>
--Greg