Re: How to change path where Cocoa App is runnin?
Re: How to change path where Cocoa App is runnin?
- Subject: Re: How to change path where Cocoa App is runnin?
- From: Alberto <email@hidden>
- Date: Tue, 26 Mar 2002 02:39:44 -0300
On 25.03.2002 19:18, "Andy Lee" <email@hidden> wrote:
>
Alberto, it looks like Ondra and Jim have just given you the
>
information you need, but I think they're assuming you know more than
>
you do. Please don't take offense if I'm wrong about this, but it
>
sounds like you are new to C programming and possibly Unix concepts.
>
So in case the answer is still not clear, let me try to break it down
>
for you.
>
You are completly right Jim.. and I am using this simple project to know a
little more about Cocoa.
I was programmer, but a long time I do not develop anything!! And I used
Pascal, Basic, Cobol and others old languages...
Java and C/C++ I am begginer. I understand what I need and how my app must
work... but not exactly the C language or Cocoa (I'm trying... but I never
found good documentation for begginers in Cocoa or Carbon).
>
You cannot change where the Cocoa app defaults to when it launches.
>
This will always be "/". Trying to change this is not the answer.
>
>
Do you understand the concept of "cwd" (Current Working Directory)?
>
This is very important. At any time during a program's execution, it
>
is "in" a particular directory location called the current working
>
directory. This location *can change* throughout the execution of
>
the program. So although your Cocoa app *starts* with a cwd of "/",
>
there are ways to make the Unix app it calls run in "/Library/Eref/"
>
(or whatever you want).
>
>
One way, which Ondra suggested, is to use NSFileManager's
>
-changeCurrentDirectoryPath: method before you launch the Unix app,
>
like this:
>
>
[[NSFileManager defaultManager]
>
changeCurrentDirectoryPath:@"/Library/Eref/"];
>
// ...NOW launch the Unix app...
>
>
This will change the Cocoa app's working directory from whatever it
>
was (presumably "/") to "/Library/Eref/". When the Cocoa app
>
launches the Unix app, the Unix app will have the same working
>
directory as the Cocoa app had *at that time*.
>
>
Another way, which Jim suggested, assumes you are using an instance
>
of NSTask to launch the Unix app. If this is the case, you can use
>
NSTask's -setCurrentDirectoryPath: method, like this:
>
>
[myTask setCurrentDirectoryPath:@"/Library/Eref/"];
>
// ...NOW launch the Unix app using myTask...
>
>
If you try either (or both) of these approaches and still don't get
>
the result you want, there is a deeper problem.
>
I tried argv[0], because anybody replied me here that in Cocoa this was how
to solve my CWD problem.
But now it's working, and I have:
[[NSFileManager defaultManager]
changeCurrentDirectoryPath:@"/Library/Eref/"];
showTask=[[TaskWrapper alloc] initWithController:self
arguments:[NSArray arrayWithObjects:@"/Library/Eref/runref",nil]];
>
I saw the code you posted using argv[0]. It tells me you are new to
>
C. Fortunately, for the immediate purposes of your Cocoa app, argc
>
and argv are irrelevant. However, I recommend you take some time
>
when you can to learn the meaning of the main() function and the
>
arguments passed to it, as well as how C declarations work. You
>
*must* understand the C language to program effectively in
>
Objective-C. You must also understand concepts like the cwd. In
>
general, as a programmer you must understand what every line of code
>
you type *does*. Otherwise, you are just typing in uninformed
>
guesses, which is a waste of your time, not to mention frustrating.
>
People will also respond more positively when you ask for help if you
>
demonstrate knowledge of the fundamentals that lead up to your
>
question.
>
>
--Andy
Thank you very much for all your attention and help.
I was looking for something in NSFileManager, as Ondra replied me.
I continue looking for good documentation and examples...
Ohhh... as begginer... I think as begginer, and I can tell that the project
I am doing is good for begginers!! I found lots of people interested to
develop a Aqua GUI (using Cocoa or any other language) for UNIX apps in OS
X, but I never found a complete project.
My last project were QuickTime Streaming Server for Mac OS Classic (8.x and
9.x), and it works perfectly!! And lots replied me that this was not
necessary.. because I could run QTSS over OS X, but thousand of Mac users
that are not able to use OS X downloaded my QTSC (QTSS for Mac OS Classic),
and some people used it as sample for Conferences about Video Streaming.
So... what is not interesting for lots.. can be interesting for some...
but it is interestig.
Best regards... and thanx again.
Alberto V. M.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.