Re: Installing elements from application bundle
Re: Installing elements from application bundle
- Subject: Re: Installing elements from application bundle
- From: Brian Ganninger <email@hidden>
- Date: Tue, 18 Feb 2003 11:57:33 -0600
I've been working with this exact situation and here's my two cents on how
you can easily accomplish it. It's made easier if you only want to target
the root hard drive (I've been working with all drives, so it complicated it
a bit)
Anyway, here's some sample code to accomplish your goal. It's not very
elegant but I hope it helps.
NSFileManager *manager = [NSFileManager defaultManager];
NSString *fileToAutoset = [[NSBundle mainBundle] pathForResource:@"filename"
ofType:@"tiff"]; // sets the path to the file inside the app
BOOL fileStatus = [manager copyPath:fileToAutoset
toPath:NSOpenStepRootDirectory() handler:self]; // tells manager to copy a
file at the copyPath to the toPath, self as handler (needed but unknown to
me as for it's purpose)
If(fileStatus == YES)
{
NSLog(@"Woohoo!");
}
else
{
NSLog(@"boo, this crap code didn't work");
}
Just change the toPath to wherever you want the file to go and give it an
actual filename and you should be all set. To have it run only once, at
startup, throw the above code in the awakeFromNib method :)
Hope this gets you started. Cheers!
- Brian Ganninger
Note: I haven't actually compiled and given the above code a whirl, but it's
a diluted version of how I'd do it if I didn't have all the other
restrictions. It should work though :-)
On 2/18/03 7:49 AM, "Stefan Wiesendanger" <email@hidden>
wrote:
>
Never did something like this, but have you had a look at NSWorkspace?
>
(especially performFileOperation:source:destination:files:tag:)
>
>
cheers
>
Stef
>
>
>
----
>
Stefan Wiesendanger
>
Switzerland
>
>
am 18.02.2003 14:29 Uhr schrieb Fridiric BLANC unter email@hidden:
>
>
> Hi!
>
>
>
> While I'm answering to last messages, I've got a new riddle to submit ;) !
>
>
>
> I need some help to figure how I could install elements from my app bundle.
>
> Actually, I wish to be able, at runtime, to copy one of my resources
>
> (included
>
> in my app bundle) at a predefined location on the user's startup volume.
>
>
>
> Ex. : Imagine my app wants my user to have a special .tiff in his/her
>
> "~/Documents" folder; Imagine this special .tiff is included in the installed
>
> and then launched app.
>
>
>
> Is there anyone here who's tried to do such a thing? Could this kind people
>
> share thoughts with us ;) ? Thanks in advance,
>
>
>
>
>
> - Fred
>
> _______________________________________________
>
> 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.
----
" An Apple a day keeps the PC away."
" Ever notice that Apples fall from the sky while computers get thrown out
Windows?"
_______________________________________________
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.