getting the current appl path

maccatalan

Registered
Hi.

How to get the current application (the one you are making) path ?
I tried to find something into NSApplication doc and I tried to call argv (but this last one isn't declared out from the main.c).

So how to do ?

Thank you.
 
You want getenv():

Code:
#include <stdio.h>
#include <stdlib.h>

int main()
{
   printf( "PATH is %s\n", getenv( "PATH" ) );

   return 0;
}
 
thank you for answering but you don't answer correctly to my question. Maybe I don't ask it correctly...

I have found since I posted the first message this partial solution :

[[NSFileManager defaultManager] currentDirectoryPath]

This returns the path as a NSString to acceed to the current application. This could be a solution for my problem.

So you understand that I'm programming in Cocoa(Objective-C). As I know/understand it, I can't acceed from my class to the argv variable. So the previous way I typed (using a NSFileManager) is a right solution. But if I'm trying to do it, is to execute a program with a NSPipe. This program is part of my project, so I will put them together. With this solution I must put it in the same folder than my application, but I would like to make it easier for the user, putting it into the application folder, so something like "/Applications/MyProgramFodler/MyProgram.app/theProgramToPipe". But you understand that someone can change the name of the program. So it is not a complete solution.

For now I only can put it into : "/Applications/MyProgramFodler/plugins/theProgramToPipe"

So can anybody help me ?
thank you,
Pierre.
 
Ah, I see what you're looking for now; it's probably this:

Code:
[ [ NSBundle mainBundle ] bundlePath ] ]

which should return the path to the .app part of the application's path (ie, /Applications/MyApp.app).
 
It's exactly what I was looking for.
Thank you very much.

I wish you a happy new year, and all the best you can imagine. :)

Have fun, (and thank you, again)
Pierre.
 
Back
Top