refactor: replace remaining NULL
with nullptr
(#40053)
refactor: use nullptr everywhere
This commit is contained in:
parent
9d0e6d09f0
commit
04b2ba84cd
34 changed files with 98 additions and 93 deletions
|
@ -63,8 +63,8 @@ NSString* ContainingDiskImageDevice(NSString* bundlePath) {
|
|||
NSDictionary* info =
|
||||
[NSPropertyListSerialization propertyListWithData:data
|
||||
options:NSPropertyListImmutable
|
||||
format:NULL
|
||||
error:NULL];
|
||||
format:nil
|
||||
error:nil];
|
||||
|
||||
if (![info isKindOfClass:[NSDictionary class]])
|
||||
return nil;
|
||||
|
@ -100,7 +100,7 @@ NSString* ContainingDiskImageDevice(NSString* bundlePath) {
|
|||
NSString* ResolvePath(NSString* path) {
|
||||
NSString* standardizedPath = [path stringByStandardizingPath];
|
||||
char resolved[PATH_MAX];
|
||||
if (realpath([standardizedPath UTF8String], resolved) == NULL)
|
||||
if (realpath([standardizedPath UTF8String], resolved) == nullptr)
|
||||
return path;
|
||||
return @(resolved);
|
||||
}
|
||||
|
@ -147,20 +147,20 @@ bool AuthorizedInstall(NSString* srcPath, NSString* dstPath, bool* canceled) {
|
|||
|
||||
// Get the authorization
|
||||
OSStatus err =
|
||||
AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,
|
||||
AuthorizationCreate(nullptr, kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults, &myAuthorizationRef);
|
||||
if (err != errAuthorizationSuccess)
|
||||
return false;
|
||||
|
||||
AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};
|
||||
AuthorizationItem myItems = {kAuthorizationRightExecute, 0, nullptr, 0};
|
||||
AuthorizationRights myRights = {1, &myItems};
|
||||
AuthorizationFlags myFlags =
|
||||
(AuthorizationFlags)(kAuthorizationFlagInteractionAllowed |
|
||||
kAuthorizationFlagExtendRights |
|
||||
kAuthorizationFlagPreAuthorize);
|
||||
|
||||
err = AuthorizationCopyRights(myAuthorizationRef, &myRights, NULL, myFlags,
|
||||
NULL);
|
||||
err = AuthorizationCopyRights(myAuthorizationRef, &myRights, nullptr, myFlags,
|
||||
nullptr);
|
||||
if (err != errAuthorizationSuccess) {
|
||||
if (err == errAuthorizationCanceled && canceled)
|
||||
*canceled = true;
|
||||
|
@ -170,7 +170,7 @@ bool AuthorizedInstall(NSString* srcPath, NSString* dstPath, bool* canceled) {
|
|||
static OSStatus (*security_AuthorizationExecuteWithPrivileges)(
|
||||
AuthorizationRef authorization, const char* pathToTool,
|
||||
AuthorizationFlags options, char* const* arguments,
|
||||
FILE** communicationsPipe) = NULL;
|
||||
FILE** communicationsPipe) = nullptr;
|
||||
if (!security_AuthorizationExecuteWithPrivileges) {
|
||||
// On 10.7, AuthorizationExecuteWithPrivileges is deprecated. We want to
|
||||
// still use it since there's no good alternative (without requiring code
|
||||
|
@ -188,9 +188,10 @@ bool AuthorizedInstall(NSString* srcPath, NSString* dstPath, bool* canceled) {
|
|||
// Delete the destination
|
||||
{
|
||||
char rf[] = "-rf";
|
||||
char* args[] = {rf, (char*)[dstPath fileSystemRepresentation], NULL};
|
||||
char* args[] = {rf, (char*)[dstPath fileSystemRepresentation], nullptr};
|
||||
err = security_AuthorizationExecuteWithPrivileges(
|
||||
myAuthorizationRef, "/bin/rm", kAuthorizationFlagDefaults, args, NULL);
|
||||
myAuthorizationRef, "/bin/rm", kAuthorizationFlagDefaults, args,
|
||||
nullptr);
|
||||
if (err != errAuthorizationSuccess)
|
||||
goto fail;
|
||||
|
||||
|
@ -205,9 +206,10 @@ bool AuthorizedInstall(NSString* srcPath, NSString* dstPath, bool* canceled) {
|
|||
{
|
||||
char pR[] = "-pR";
|
||||
char* args[] = {pR, (char*)[srcPath fileSystemRepresentation],
|
||||
(char*)[dstPath fileSystemRepresentation], NULL};
|
||||
(char*)[dstPath fileSystemRepresentation], nullptr};
|
||||
err = security_AuthorizationExecuteWithPrivileges(
|
||||
myAuthorizationRef, "/bin/cp", kAuthorizationFlagDefaults, args, NULL);
|
||||
myAuthorizationRef, "/bin/cp", kAuthorizationFlagDefaults, args,
|
||||
nullptr);
|
||||
if (err != errAuthorizationSuccess)
|
||||
goto fail;
|
||||
|
||||
|
@ -272,8 +274,8 @@ bool Trash(NSString* path) {
|
|||
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_8) {
|
||||
result = [[NSFileManager defaultManager]
|
||||
trashItemAtURL:[NSURL fileURLWithPath:path]
|
||||
resultingItemURL:NULL
|
||||
error:NULL];
|
||||
resultingItemURL:nil
|
||||
error:nil];
|
||||
}
|
||||
|
||||
// As a last resort try trashing with AppleScript.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue