how to delete the current user's directory?
how to delete the current user's directory?
- Subject: how to delete the current user's directory?
- From: "XiaoGang Li" <email@hidden>
- Date: Mon, 1 Sep 2008 18:46:41 +0800
hi, list, I have an uninstaller application , which is used to delete
the files installed; and also i have a file which located in the current
user's directory, like the ~/Library/LaunchAgents/com.****.plist. and how
can i delete this kind of file, i have tried the
AuthorizationExecuteWithPrivileges
API, it seems not workable, do i give a wrong flag value or something else?
here is my code piece, any comments will be appreciated.
AuthorizationRef myAuthorizationRef;
AuthorizationFlags myFlags = kAuthorizationFlagDefaults;
AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,myFlags,
&myAuthorizationRef);
AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};
AuthorizationRights myRights = {1, &myItems};
myFlags = kAuthorizationFlagDefaults |
kAuthorizationFlagInteractionAllowed |
kAuthorizationFlagPreAuthorize |
kAuthorizationFlagExtendRights;
AuthorizationCopyRights (myAuthorizationRef, &myRights, NULL, myFlags, NULL);
char *fileDir = "~/Library/LaunchAgents/com.hp.printerAgent.plist";
char* args[3];
args[0]= "-Rf";
args[1]= fileDir;
args[2]= NULL;
myFlags = kAuthorizationFlagDefaults;
OSStatus res = AuthorizationExecuteWithPrivileges(myAuthorizationRef,
"/bin/rm",myFlags,args,NULL);
AuthorizationFree(myAuthorizationRef, myFlags);
and the res value is -60032. and by the way, how can i get the current
user's name string? which cocoa API can get it?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden