• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
how to delete the current user's directory?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: how to delete the current user's directory?
      • From: Chris Hanson <email@hidden>
    • Re: how to delete the current user's directory?
      • From: "Michael Ash" <email@hidden>
  • Prev by Date: Increasing NSTextView's height
  • Next by Date: Re: Increasing NSTextView's height
  • Previous by thread: Re: Increasing NSTextView's height
  • Next by thread: Re: how to delete the current user's directory?
  • Index(es):
    • Date
    • Thread