 |
 |
copyPath:toPath:handler:
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
Im writing a prefpane that will have the ability to create a startup item for the daemon that the prefPane controls. This startup item is a folder included in the prefPane bundle. At this point im just trying to get the folder and its contents to copy to my desktop but it never works. No files are copied. Here is my code thus far:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> - (void) createStartupItem {
NSString *source = [[NSBundle bundleForClass:[self class]] pathForResource:@"theStartupItemFolderWit hStuffInIt" ofType:@"nil"];
NSString *destination = NSHomeDirectory();
[[NSFileManager defaultManager] copyPath:source toPath:destination handler:nil];
}
Where have I strayed?
</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">
|
3R1C
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by 3R1C:
<strong> NSString *source = [[NSBundle bundleForClass:[self class]] pathForResource:@"theStartupItemFolderWithStuffInI t" ofType:@"nil"];
</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">this mmight be the offending line. @"nil" is a string containing "nil", what you most probably mean is "...ofType:nil", a "real" nil-object.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
You're right about the error you found (I should have caught that one) but it still doesn't copy.
|
3R1C
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Why don't you implement a handler? That might tell you something.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
just had a look at the apis... looks as if the source would have to include a filename; so instead of copying it to "~", try [@"~/Desktop/theStartupItemFolderWithStuffInIt" stringByExpandingTildeInPath] and let us know whether that did it.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
Yup. that did it. Now on to the meat of the matter. How can I use the security framework to execute this command? I already am able to use the security framework to execute shell commands to do commands but how do I execute an [NSFileManager defaultManager] copyPath ?do I need to include cpMac in my bundle and execute the path copy with it using priveleges?
|
3R1C
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
why re-invent the wheel?
why not create an installer package with packagemaker, put it inside your bundle and then use nsworkspace to open it which would launch the installer?
the installer knows how to put stuff where, can ask for authorization, you could supply an additinal readme in it,... also, personally i'd rather trust the installer -- sorry, nothing personal.
plus, it's way easier <img border="0" title="" alt="[Wink]" src="wink.gif" />
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
Well, because the startup item that is written, needs to be generated on the fly, depending upon who's library, the prefpane is in. if its in a user prefpane folder, then a startup item must be written out that points to that users item to startup. and I cant use $HOME in the startup item because, the startup item runs as root, and also because there is no user yet. startup items load before there is a user. Not to mention that it wouldn't be very user friendly if every time my user checks the "create startup item' in my prefpane, they run installer. Right now, im using the BLAuthentication object, I found at stepwise. It works like a champ but it only seems to authorize NSTasks, not actual obj c commands in my code. Im not sure if startup items have a resource fork or not. If they do, i need to use the BLAuthenticate object to authorize a cpMac to put my on the fly generated startup item where it needs to go. If this is true I'll need to put cpMac in my bundle. If my startup item does not have a resource fork, I can just use the cp command that the user already has on his box. All of this could be avoided if I could just use the authorization Services framework to do obj c commands instead of an NSTask.
whew.
|
3R1C
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by 3R1C:
<strong>Yup. that did it. Now on to the meat of the matter. How can I use the security framework to execute this command? I already am able to use the security framework to execute shell commands to do commands but how do I execute an [NSFileManager defaultManager] copyPath ?do I need to include cpMac in my bundle and execute the path copy with it using priveleges?</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Any admin user should be able to write to /Library/StartupItems.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
a .pkg is nothing but a package, you could easily assemble it on the fly.
but i don't see anything wrong with invoking cp and using the shell to copy stuff -- as you like. the question is not "do startup items have a resource fork?" but "does *your* startup item have a resource fork?"
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|