FROM : April Gendill
DATE : Tue Dec 21 23:43:06 2004
Ok I copied the example code from Apple's site and then modified it for
my app. This code is suppose to step through a list of files and remove
only files not directories.
It does not work. It races through the loop never launching the helper
app at all. What am I doing wrong???
April.
OSStatus myStatus;
FILE *myCommunicationsPipe=NULL;
AuthorizationFlags myFlags = kAuthorizationFlagDefaults;
AuthorizationRef myAuthorizationRef;
myStatus = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment, myFlags, &myAuthorizationRef);
AuthorizationItem myItems = {kAuthorizationRightExecute, 0,NULL, 0};
AuthorizationRights myRights = {1, &myItems};
myFlags = kAuthorizationFlagDefaults |
kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize |
kAuthorizationFlagExtendRights;
myStatus = AuthorizationCopyRights (myAuthorizationRef,&myRights,
NULL, myFlags, NULL );
if (myStatus != errAuthorizationSuccess){
[progressWindow orderOut:self];
return;
}
while(current = [iter nextObject]){
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate
dateWithTimeIntervalSinceNow:0.01]];
BOOL fileThere = [[NSFileManager defaultManager]
fileExistsAtPath:current isDirectory:&isDir];
if (myStatus != errAuthorizationSuccess){
[progressWindow orderOut:self];
return;
}
if(fileThere && !isDir){
NSString * t = [[NSBundle mainBundle]resourcePath];
NSString * toolPath = [NSString stringWithFormat:@"%@/helper",t];
char *myArguments[] = { [current cString], NULL };
char * tp = [toolPath cString];
FILE *myCommunicationsPipe = NULL;
char myReadBuffer[128];
myFlags = kAuthorizationFlagDefaults;
myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef,
tp, myFlags,
myArguments,&myCommunicationsPipe);
if (myStatus == errAuthorizationSuccess){
[pi incrementBy:1.0];
}
}//end if there and not dir
else if (!fileThere || isDir){
[pi incrementBy:1.0];
}
}//end while
DATE : Tue Dec 21 23:43:06 2004
Ok I copied the example code from Apple's site and then modified it for
my app. This code is suppose to step through a list of files and remove
only files not directories.
It does not work. It races through the loop never launching the helper
app at all. What am I doing wrong???
April.
OSStatus myStatus;
FILE *myCommunicationsPipe=NULL;
AuthorizationFlags myFlags = kAuthorizationFlagDefaults;
AuthorizationRef myAuthorizationRef;
myStatus = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment, myFlags, &myAuthorizationRef);
AuthorizationItem myItems = {kAuthorizationRightExecute, 0,NULL, 0};
AuthorizationRights myRights = {1, &myItems};
myFlags = kAuthorizationFlagDefaults |
kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize |
kAuthorizationFlagExtendRights;
myStatus = AuthorizationCopyRights (myAuthorizationRef,&myRights,
NULL, myFlags, NULL );
if (myStatus != errAuthorizationSuccess){
[progressWindow orderOut:self];
return;
}
while(current = [iter nextObject]){
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate
dateWithTimeIntervalSinceNow:0.01]];
BOOL fileThere = [[NSFileManager defaultManager]
fileExistsAtPath:current isDirectory:&isDir];
if (myStatus != errAuthorizationSuccess){
[progressWindow orderOut:self];
return;
}
if(fileThere && !isDir){
NSString * t = [[NSBundle mainBundle]resourcePath];
NSString * toolPath = [NSString stringWithFormat:@"%@/helper",t];
char *myArguments[] = { [current cString], NULL };
char * tp = [toolPath cString];
FILE *myCommunicationsPipe = NULL;
char myReadBuffer[128];
myFlags = kAuthorizationFlagDefaults;
myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef,
tp, myFlags,
myArguments,&myCommunicationsPipe);
if (myStatus == errAuthorizationSuccess){
[pi incrementBy:1.0];
}
}//end if there and not dir
else if (!fileThere || isDir){
[pi incrementBy:1.0];
}
}//end while
| Related mails | Author | Date |
|---|---|---|
| April Gendill | Dec 21, 23:43 | |
| April Gendill | Dec 22, 01:46 | |
| m | Dec 22, 01:57 | |
| m | Dec 22, 02:03 | |
| April Gendill | Dec 22, 03:24 | |
| m | Dec 22, 07:48 |






Cocoa mail archive

