From f2a7b4b349c52ea366d11183ef041d454025ad93 Mon Sep 17 00:00:00 2001 From: August Joki Date: Sun, 14 Jun 2009 19:30:46 -0700 Subject: [PATCH] Fixed deprecated APIs to use replacements. --- SUAppcast.m | 4 ++-- SUBasicUpdateDriver.m | 10 +++++----- SUDiskImageUnarchiver.m | 10 +++++----- SUHost.m | 2 +- SUInstaller.m | 2 +- SUPipedUnarchiver.m | 2 +- SUPlainInstaller.h | 1 + SUPlainInstallerInternals.m | 6 +++--- SUUIBasedUpdateDriver.m | 2 +- Sparkle.xcodeproj/project.pbxproj | 4 +++- relaunch.m | 2 +- 11 files changed, 24 insertions(+), 21 deletions(-) diff --git a/SUAppcast.m b/SUAppcast.m index 6ce32cc53..2376186bd 100644 --- a/SUAppcast.m +++ b/SUAppcast.m @@ -60,7 +60,7 @@ - (void)downloadDidFinish:(NSURLDownload *)download NSArray *xmlItems = nil; NSMutableArray *appcastItems = [NSMutableArray array]; - [[NSFileManager defaultManager] removeFileAtPath:downloadFilename handler:nil]; + [[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:NULL]; [downloadFilename release]; downloadFilename = nil; @@ -177,7 +177,7 @@ - (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error { CFRelease(download); - [[NSFileManager defaultManager] removeFileAtPath:downloadFilename handler:nil]; + [[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:NULL]; [downloadFilename release]; downloadFilename = nil; diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index 463018935..e90b6df2b 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -144,7 +144,7 @@ - (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSSt int cnt=1; while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999) tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", prefix, cnt++]]; - BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir attributes:nil]; + BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:NULL]; if (!success) { // Okay, something's really broken with /tmp @@ -223,8 +223,8 @@ - (void)installUpdate NSString *relaunchPathToCopy = [[NSBundle bundleForClass:[self class]] pathForResource:@"relaunch" ofType:@""]; NSString *targetPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]]; // Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems - [[NSFileManager defaultManager] removeFileAtPath:targetPath handler:nil]; - if ([[NSFileManager defaultManager] copyPath:relaunchPathToCopy toPath:targetPath handler:nil]) + [[NSFileManager defaultManager] removeItemAtPath:targetPath error:NULL]; + if ([[NSFileManager defaultManager] copyItemAtPath:relaunchPathToCopy toPath:targetPath error:NULL]) relaunchPath = [targetPath retain]; [SUInstaller installFromUpdateFolder:[downloadPath stringByDeletingLastPathComponent] overHost:host delegate:self synchronously:[self shouldInstallSynchronously] versionComparator:[self _versionComparator]]; @@ -274,13 +274,13 @@ - (void)relaunchHostApp - (void)cleanUp { - [[NSFileManager defaultManager] removeFileAtPath:[downloadPath stringByDeletingLastPathComponent] handler:nil]; + [[NSFileManager defaultManager] removeItemAtPath:[downloadPath stringByDeletingLastPathComponent] error:NULL]; } - (void)installerForHost:(SUHost *)aHost failedWithError:(NSError *)error { if (aHost != host) { return; } - [[NSFileManager defaultManager] removeFileAtPath:relaunchPath handler:NULL]; // Clean up the copied relauncher. + [[NSFileManager defaultManager] removeItemAtPath:relaunchPath error:NULL]; // Clean up the copied relauncher. [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil), NSLocalizedDescriptionKey, [error localizedDescription], NSLocalizedFailureReasonErrorKey, nil]]]; } diff --git a/SUDiskImageUnarchiver.m b/SUDiskImageUnarchiver.m index 65ba89211..25b22cede 100644 --- a/SUDiskImageUnarchiver.m +++ b/SUDiskImageUnarchiver.m @@ -33,7 +33,7 @@ - (void)_extractDMG if ([[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError; // create mount point folder - [[NSFileManager defaultManager] createDirectoryAtPath:mountPoint attributes:nil]; + [[NSFileManager defaultManager] createDirectoryAtPath:mountPoint withIntermediateDirectories:YES attributes:nil error:NULL]; if (![[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError; NSArray* arguments = [NSArray arrayWithObjects:@"attach", archivePath, @"-mountpoint", mountPoint, @"-noverify", @"-nobrowse", @"-noautoopen", nil]; @@ -47,16 +47,16 @@ - (void)_extractDMG // Now that we've mounted it, we need to copy out its contents. NSString *targetPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[mountPoint lastPathComponent]]; - if (![[NSFileManager defaultManager] createDirectoryAtPath:targetPath attributes:nil]) goto reportError; + if (![[NSFileManager defaultManager] createDirectoryAtPath:targetPath withIntermediateDirectories:YES attributes:nil error:NULL]) goto reportError; // We can't just copyPath: from the volume root because that always fails. Seems to be a bug. - id subpathEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath:mountPoint] objectEnumerator], currentSubpath; + id subpathEnumerator = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:mountPoint error:NULL] objectEnumerator], currentSubpath; while ((currentSubpath = [subpathEnumerator nextObject])) { NSString *currentFullPath = [mountPoint stringByAppendingPathComponent:currentSubpath]; // Don't bother trying (and failing) to copy out files we can't read. That's not going to be the app anyway. if (![[NSFileManager defaultManager] isReadableFileAtPath:currentFullPath]) continue; - if (![[NSFileManager defaultManager] copyPath:currentFullPath toPath:[targetPath stringByAppendingPathComponent:currentSubpath] handler:nil]) + if (![[NSFileManager defaultManager] copyItemAtPath:currentFullPath toPath:[targetPath stringByAppendingPathComponent:currentSubpath] error:NULL]) goto reportError; } @@ -70,7 +70,7 @@ - (void)_extractDMG if (mountedSuccessfully) [NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"detach", mountPoint, @"-force", nil]]; else - [[NSFileManager defaultManager] removeFileAtPath:mountPoint handler:nil]; + [[NSFileManager defaultManager] removeItemAtPath:mountPoint error:NULL]; [pool drain]; } diff --git a/SUHost.m b/SUHost.m index 777fb8633..76f59b7d9 100644 --- a/SUHost.m +++ b/SUHost.m @@ -19,7 +19,7 @@ - (id)initWithBundle:(NSBundle *)aBundle { bundle = [aBundle retain]; if (![bundle bundleIdentifier]) - NSLog(@"Sparkle Error: the bundle being updated at %@ has no CFBundleIdentifier! This will cause preference read/write to not work properly."); + NSLog(@"Sparkle Error: the bundle being updated at %@ has no CFBundleIdentifier! This will cause preference read/write to not work properly.", bundle); } return self; } diff --git a/SUInstaller.m b/SUInstaller.m index 37f246df3..b35cdbac4 100644 --- a/SUInstaller.m +++ b/SUInstaller.m @@ -9,7 +9,7 @@ #import "SUInstaller.h" #import "SUPlainInstaller.h" #import "SUPackageInstaller.h" -#import "SUHost.h" +#import "SUHost.h" @implementation SUInstaller diff --git a/SUPipedUnarchiver.m b/SUPipedUnarchiver.m index e3481ff99..1a6b7ca1e 100644 --- a/SUPipedUnarchiver.m +++ b/SUPipedUnarchiver.m @@ -48,7 +48,7 @@ - (void)_extractArchivePipingDataToCommand:(NSString *)command FILE *fp = NULL, *cmdFP = NULL; // Get the file size. - NSNumber *fs = [[[NSFileManager defaultManager] fileAttributesAtPath:archivePath traverseLink:NO] objectForKey:NSFileSize]; + NSNumber *fs = [[[NSFileManager defaultManager] attributesOfItemAtPath:archivePath error:NULL] objectForKey:NSFileSize]; if (fs == nil) goto reportError; // Thank you, Allan Odgaard! diff --git a/SUPlainInstaller.h b/SUPlainInstaller.h index 61c83a76c..ded3b4ad2 100644 --- a/SUPlainInstaller.h +++ b/SUPlainInstaller.h @@ -11,6 +11,7 @@ #import "Sparkle.h" #import "SUInstaller.h" +#import "SUHost.h" #import "SUVersionComparisonProtocol.h" @interface SUPlainInstaller : SUInstaller { } diff --git a/SUPlainInstallerInternals.m b/SUPlainInstallerInternals.m index 3e66e619d..f5c752419 100644 --- a/SUPlainInstallerInternals.m +++ b/SUPlainInstallerInternals.m @@ -235,13 +235,13 @@ + (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst erro NSString *tmpPath = [self _temporaryCopyNameForPath:dst]; - if (![[NSFileManager defaultManager] movePath:dst toPath:tmpPath handler:self]) + if (![[NSFileManager defaultManager] moveItemAtPath:dst toPath:tmpPath error:NULL]) { if (error != NULL) *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]]; return NO; } - if (![[NSFileManager defaultManager] copyPath:src toPath:dst handler:self]) + if (![[NSFileManager defaultManager] copyItemAtPath:src toPath:dst error:NULL]) { if (error != NULL) *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't copy %@ to %@.", src, dst] forKey:NSLocalizedDescriptionKey]]; @@ -320,7 +320,7 @@ + (void)releaseFromQuarantine:(NSString*)root // Only recurse if it's actually a directory. Don't recurse into a // root-level symbolic link. NSDictionary* rootAttributes = - [[NSFileManager defaultManager] fileAttributesAtPath:root traverseLink:NO]; + [[NSFileManager defaultManager] attributesOfItemAtPath:root error:NULL]; NSString* rootType = [rootAttributes objectForKey:NSFileType]; if (rootType == NSFileTypeDirectory) { diff --git a/SUUIBasedUpdateDriver.m b/SUUIBasedUpdateDriver.m index d3fa81b2c..714acdfc8 100644 --- a/SUUIBasedUpdateDriver.m +++ b/SUUIBasedUpdateDriver.m @@ -122,7 +122,7 @@ - (void)unarchiver:(SUUnarchiver *)ua extractedLength:(long)length { // We do this here instead of in extractUpdate so that we only have a determinate progress bar for archives with progress. if ([statusController maxProgressValue] == 0) - [statusController setMaxProgressValue:[[[[NSFileManager defaultManager] fileAttributesAtPath:downloadPath traverseLink:NO] objectForKey:NSFileSize] doubleValue]]; + [statusController setMaxProgressValue:[[[[NSFileManager defaultManager] attributesOfItemAtPath:downloadPath error:NULL] objectForKey:NSFileSize] doubleValue]]; [statusController setProgressValue:[statusController progressValue] + length]; } diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 0be4f470c..17bc8139b 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -1022,6 +1022,7 @@ 1DEB91B208733DA50010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; WARNING_CFLAGS = "-Wundeclared-selector"; }; name = Debug; @@ -1029,6 +1030,7 @@ 1DEB91B308733DA50010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; WARNING_CFLAGS = "-Wundeclared-selector"; }; name = Release; @@ -1036,7 +1038,7 @@ 61072EAD0DF263BD008FE88B /* Release (GC dual-mode; 10.5-only) */ = { isa = XCBuildConfiguration; buildSettings = { - GCC_VERSION = ""; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; WARNING_CFLAGS = "-Wundeclared-selector"; }; name = "Release (GC dual-mode; 10.5-only)"; diff --git a/relaunch.m b/relaunch.m index b38d555ec..1bdd63adc 100644 --- a/relaunch.m +++ b/relaunch.m @@ -39,7 +39,7 @@ - (void)watchdog:(NSTimer *)timer - (void) relaunch { [[NSWorkspace sharedWorkspace] openFile:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:executablePath length:strlen(executablePath)]]; - [[NSFileManager defaultManager] removeFileAtPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"relaunch"] handler:nil]; + [[NSFileManager defaultManager] removeItemAtPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"relaunch"] error:NULL]; exit(0); }