Re: How to control relative paths in Unix task?
Re: How to control relative paths in Unix task?
- Subject: Re: How to control relative paths in Unix task?
- From: Philip George <email@hidden>
- Date: Mon, 22 Jul 2002 16:43:09 -0500
If you want to refer to the user's home folder, you can use
NSHomeDirectory(), which returns an NSString representation of the unix
path to the user's home dir. If you want to use relative paths, that
works fine, provided that you first explicitly set the "current"
directory. To do this you use NSFileManager's
changeCurrentDirectoryPath: method, which takes an NSString
representation of the unix path you want to set as the current path. If
you want to refer to the directory in which the xxx.app bundle is
sitting, you can use NSBundle's mainBundle class method to return the
path up to ***and including*** (watch out for that) your xxx.app bundle
folder. You can then use ".." somehow I think to move "up" a directory
just as you do at the command line. That last ("..") part I'm not sure
about though. You'll have to experiment with that one.
Good luck.
- Philip
On Monday, July 22, 2002, at 04:20 PM, John Nairn wrote:
>
*This message was transferred with a trial version of CommuniGate(tm)
>
Pro*
>
I am writing some scientific software to launch c++ processes and it
>
works almost as a I need.
>
>
I have embedded the unix executable in the bundle of my application
>
(for portability). My specific process, however, creates directories
>
and writes data to files. It creates the files with
>
>
fp=fopen(fname,"w")
>
>
where fname is something like "results/data/archive.data". I tried it
>
out and found that the folder and files were created in the same folder
>
as my ".app" (which at this time is the "build" folder with my project).
>
>
My question: I expect the relative path used in the unix process is
>
building off the unix working directory and that directory is set to
>
the application's directory by default. How can I control that location
>
and thereby control how the unix process resolves relative paths when
>
it creates file?
>
>
----------------
>
John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
>
Web page: http://www.mse.utah.edu/~nairn
>
_______________________________________________
>
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.
_______________________________________________
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.