Permalink
Browse files

added #ifdef's for Tiger support

  • Loading branch information...
August Joki
August Joki committed Jun 15, 2009
1 parent f2a7b4b commit 54299d766ae4514444f5f8e571186bb82b0a449e
Showing with 70 additions and 4 deletions.
  1. +8 −2 SUAppcast.m
  2. +18 −1 SUBasicUpdateDriver.m
  3. +20 −0 SUDiskImageUnarchiver.m
  4. +4 −0 SUPipedUnarchiver.m
  5. +12 −1 SUPlainInstallerInternals.m
  6. +4 −0 SUUIBasedUpdateDriver.m
  7. +4 −0 relaunch.m
View
@@ -59,8 +59,11 @@ - (void)downloadDidFinish:(NSURLDownload *)download
BOOL failed = NO;
NSArray *xmlItems = nil;
NSMutableArray *appcastItems = [NSMutableArray array];
-
+#ifndef MAC_OS_X_VERSION_10_5
+ [[NSFileManager defaultManager] removeFileAtPath:download handler:nil];
+#else
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:NULL];
+#endif
[downloadFilename release];
downloadFilename = nil;
@@ -176,8 +179,11 @@ - (void)downloadDidFinish:(NSURLDownload *)download
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error
{
CFRelease(download);
-
+#ifndef MAC_OS_X_VERSION_10_5
+ [[NSFileManager defaultManager] removeFileAtPath:downloadFilename handler:nil];
+#else
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:NULL];
+#endif
[downloadFilename release];
downloadFilename = nil;
View
@@ -144,7 +144,11 @@ - (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSSt
int cnt=1;
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", prefix, cnt++]];
+#ifndef MAC_OS_X_VERSION_10_5
+ BOOL BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir attributes:nil];
+#else
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
+#endif
if (!success)
{
// Okay, something's really broken with /tmp
@@ -223,8 +227,13 @@ - (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
+#ifndef MAC_OS_X_VERSION_10_5
+ [[NSFileManager defaultManager] removeFileAtPath:targetPath handler:nil];
+ if ([[NSFileManager defaultManager] copyPath:relaunchPathToCopy toPath:targetPath handler:nil])
+#else
[[NSFileManager defaultManager] removeItemAtPath:targetPath error:NULL];
if ([[NSFileManager defaultManager] copyItemAtPath:relaunchPathToCopy toPath:targetPath error:NULL])
+#endif
relaunchPath = [targetPath retain];
[SUInstaller installFromUpdateFolder:[downloadPath stringByDeletingLastPathComponent] overHost:host delegate:self synchronously:[self shouldInstallSynchronously] versionComparator:[self _versionComparator]];
@@ -274,13 +283,21 @@ - (void)relaunchHostApp
- (void)cleanUp
{
- [[NSFileManager defaultManager] removeItemAtPath:[downloadPath stringByDeletingLastPathComponent] error:NULL];
+#ifndef MAC_OS_X_VERSION_10_5
+ [[NSFileManager defaultManager] removeFileAtPath:[downloadPath stringByDeletingLastPathComponent] handler:nil];
+#else
+ [[NSFileManager defaultManager] removeItemAtPath:[downloadPath stringByDeletingLastPathComponent] error:NULL];
+#endif
}
- (void)installerForHost:(SUHost *)aHost failedWithError:(NSError *)error
{
if (aHost != host) { return; }
+#ifndef MAC_OS_X_VERSION_10_5
+ [[NSFileManager defaultManager] removeFileAtPath:relaunchPath handler:nil]; // Clean up the copied relauncher.
+#else
[[NSFileManager defaultManager] removeItemAtPath:relaunchPath error:NULL]; // Clean up the copied relauncher.
+#endif
[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]]];
}
View
@@ -33,7 +33,11 @@ - (void)_extractDMG
if ([[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError;
// create mount point folder
+#ifndef MAC_OS_X_VERSION_10_5
+ [[NSFileManager defaultManager] createDirectoryAtPath:mountPoint attributes:nil];
+#else
[[NSFileManager defaultManager] createDirectoryAtPath:mountPoint withIntermediateDirectories:YES attributes:nil error:NULL];
+#endif
if (![[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError;
NSArray* arguments = [NSArray arrayWithObjects:@"attach", archivePath, @"-mountpoint", mountPoint, @"-noverify", @"-nobrowse", @"-noautoopen", nil];
@@ -47,16 +51,28 @@ - (void)_extractDMG
// Now that we've mounted it, we need to copy out its contents.
NSString *targetPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[mountPoint lastPathComponent]];
+#ifndef MAC_OS_X_VERSION_10_5
+ if (![[NSFileManager defaultManager] createDirectoryAtPath:targetPath attributes:nil]) goto reportError;
+#else
if (![[NSFileManager defaultManager] createDirectoryAtPath:targetPath withIntermediateDirectories:YES attributes:nil error:NULL]) goto reportError;
+#endif
// We can't just copyPath: from the volume root because that always fails. Seems to be a bug.
+#ifndef MAC_OS_X_VERSION_10_5
+ id subpathEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath:mountPoint] objectEnumerator], currentSubpath;
+#else
id subpathEnumerator = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:mountPoint error:NULL] objectEnumerator], currentSubpath;
+#endif
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;
+#ifndef MAC_OS_X_VERSION_10_5
+ if (![[NSFileManager defaultManager] copyPath:currentFullPath toPath:[targetPath stringByAppendingPathComponent:currentSubpath handler:nil];
+#else
if (![[NSFileManager defaultManager] copyItemAtPath:currentFullPath toPath:[targetPath stringByAppendingPathComponent:currentSubpath] error:NULL])
+#endif
goto reportError;
}
@@ -70,7 +86,11 @@ - (void)_extractDMG
if (mountedSuccessfully)
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"detach", mountPoint, @"-force", nil]];
else
+#ifndef MAC_OS_X_VERSION_10_5
+ [[NSFileManager defaultManager] removeFileAtPath:mountPoint handler:nil];
+#else
[[NSFileManager defaultManager] removeItemAtPath:mountPoint error:NULL];
+#endif
[pool drain];
}
View
@@ -48,7 +48,11 @@ - (void)_extractArchivePipingDataToCommand:(NSString *)command
FILE *fp = NULL, *cmdFP = NULL;
// Get the file size.
+#ifndef MAC_OS_X_VERSION_10_5
+ NSNumber *fs = [[[NSFileManager defaultManager] fileAttributesAtPath:archivePath traverseLink:NO] objectForKey:NSFileSize];
+#else
NSNumber *fs = [[[NSFileManager defaultManager] attributesOfItemAtPath:archivePath error:NULL] objectForKey:NSFileSize];
+#endif
if (fs == nil) goto reportError;
// Thank you, Allan Odgaard!
@@ -234,14 +234,21 @@ + (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst erro
return [self _copyPathWithForcedAuthentication:src toPath:dst error:error];
NSString *tmpPath = [self _temporaryCopyNameForPath:dst];
-
+#ifndef MAC_OS_X_VERSION_10_5
+ if (![[NSFileManager defaultManager] movePath:dst toPath:tmpPath handler:self])
+#else
if (![[NSFileManager defaultManager] moveItemAtPath:dst toPath:tmpPath error:NULL])
+#endif
{
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]];
return NO;
}
+#ifndef MAC_OS_X_VERSION_10_5
+ if (![[NSFileManager defaultManager] copyPath:src toPath:dst handler:self])
+#else
if (![[NSFileManager defaultManager] copyItemAtPath:src toPath:dst error:NULL])
+#endif
{
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't copy %@ to %@.", src, dst] forKey:NSLocalizedDescriptionKey]];
@@ -320,7 +327,11 @@ + (void)releaseFromQuarantine:(NSString*)root
// Only recurse if it's actually a directory. Don't recurse into a
// root-level symbolic link.
NSDictionary* rootAttributes =
+#ifndef MAC_OS_X_VERSION_10_5
+ [[NSFileManager defaultManager] fileAttributesAtPath:root traverseLink:NO];
+#else
[[NSFileManager defaultManager] attributesOfItemAtPath:root error:NULL];
+#endif
NSString* rootType = [rootAttributes objectForKey:NSFileType];
if (rootType == NSFileTypeDirectory) {
View
@@ -122,7 +122,11 @@ - (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)
+#ifndef MAC_OS_X_VERSION_10_5
+ [statusController setMaxProgressValue:[[[[NSFileManager defaultManager] fileAttributesAtPath:downloadPath traverseLink:NO] objectForKey:NSFileSize] doubleValue]];
+#else
[statusController setMaxProgressValue:[[[[NSFileManager defaultManager] attributesOfItemAtPath:downloadPath error:NULL] objectForKey:NSFileSize] doubleValue]];
+#endif
[statusController setProgressValue:[statusController progressValue] + length];
}
View
@@ -39,7 +39,11 @@ - (void)watchdog:(NSTimer *)timer
- (void) relaunch
{
[[NSWorkspace sharedWorkspace] openFile:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:executablePath length:strlen(executablePath)]];
+#ifndef MAC_OS_X_VERSION_10_5
+ [[NSFileManager defaultManager] removeFileAtPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"relaunch"] handler:nil];
+#else
[[NSFileManager defaultManager] removeItemAtPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"relaunch"] error:NULL];
+#endif
exit(0);
}

0 comments on commit 54299d7

Please sign in to comment.