mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Fixes 236695
Refactored Sparkle's unarchiving system into SUUnarchiver, a factory for SUPipedUnarchiver and SUDiskImageUnarchiver. I removed that nasty cleanUp call by now copying out the contents of the DMG into the /tmp directory and unmounting. Nice! This changed a fair amount so please test with your build and let me know if it explodes things. Works in my tests, though.
This commit is contained in:
1 parent
06bda29f7a
commit
93ea93dd38
12 files changed
+387
-173
No files matched your search
@@ -62,7 +62,6 @@
|
||||
- (void)installerFinishedForHostBundle:(NSBundle *)hb
|
||||
{
|
||||
if (hb != hostBundle) { return; }
|
||||
[unarchiver cleanUp];
|
||||
if (!postponingInstallation)
|
||||
[self relaunchHostApp];
|
||||
}
|
||||
|
||||
@@ -162,9 +162,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
unarchiver = [[SUUnarchiver alloc] init];
|
||||
unarchiver = [[SUUnarchiver unarchiverForURL:[[[NSURL alloc] initFileURLWithPath:downloadPath] autorelease]] retain];
|
||||
#warning check for nonexistant unarchiver
|
||||
[unarchiver setDelegate:self];
|
||||
[unarchiver unarchivePath:downloadPath];
|
||||
[unarchiver start];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
|
||||
@@ -197,7 +198,6 @@
|
||||
- (void)installerFinishedForHostBundle:(NSBundle *)hb
|
||||
{
|
||||
if (hb != hostBundle) { return; }
|
||||
[unarchiver cleanUp];
|
||||
[self relaunchHostApp];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// SUDiskImageUnarchiver.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 6/16/08.
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUDISKIMAGEUNARCHIVER_H
|
||||
#define SUDISKIMAGEUNARCHIVER_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUUnarchiver.h"
|
||||
|
||||
@interface SUDiskImageUnarchiver : SUUnarchiver {
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// SUDiskImageUnarchiver.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 6/16/08.
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUDiskImageUnarchiver.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
#import "NTSynchronousTask.h"
|
||||
|
||||
@implementation SUDiskImageUnarchiver
|
||||
|
||||
+ (BOOL)_canUnarchiveURL:(NSURL *)URL
|
||||
{
|
||||
return [URL conformsToType:@"public.disk-image"];
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
[NSThread detachNewThreadSelector:@selector(_extractDMG) toTarget:self withObject:nil];
|
||||
}
|
||||
|
||||
- (void)_extractDMG
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSString *archivePath = [archiveURL path];
|
||||
BOOL mountedSuccessfully = NO;
|
||||
|
||||
// get a unique mount point path
|
||||
NSString *mountPrefix = [@"/Volumes" stringByAppendingPathComponent:[[archivePath lastPathComponent] stringByDeletingPathExtension]];
|
||||
NSString *mountPoint = [mountPrefix stringByAppendingString:[[NSProcessInfo processInfo] globallyUniqueString]];
|
||||
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError;
|
||||
|
||||
// create mount point folder
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:mountPoint attributes:nil];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError;
|
||||
|
||||
NSArray* arguments = [NSArray arrayWithObjects:@"attach", archivePath, @"-mountpoint", mountPoint, @"-noverify", @"-nobrowse", @"-noautoopen", nil];
|
||||
// set up a pipe and push "yes" (y works too), this will accept any license agreement crap
|
||||
// not every .dmg needs this, but this will make sure it works with everyone
|
||||
NSData* yesData = [[[NSData alloc] initWithBytes:"yes\n" length:4] autorelease];
|
||||
|
||||
NSData *result = [NTSynchronousTask task:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:yesData];
|
||||
if (!result) goto reportError;
|
||||
mountedSuccessfully = YES;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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;
|
||||
while ((currentSubpath = [subpathEnumerator nextObject]))
|
||||
{
|
||||
if (![[NSFileManager defaultManager] copyPath:[mountPoint stringByAppendingPathComponent:currentSubpath] toPath:[targetPath stringByAppendingPathComponent:currentSubpath] handler:nil])
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(_notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
|
||||
goto finally;
|
||||
|
||||
reportError:
|
||||
[self performSelectorOnMainThread:@selector(_notifyDelegateOfFailure) withObject:nil waitUntilDone:NO];
|
||||
|
||||
finally:
|
||||
if (mountedSuccessfully)
|
||||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"detach", mountPoint, @"-force", nil]];
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[self _registerImplementation:self];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// SUPipedUnarchiver.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 6/16/08.
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUPIPEDUNARCHIVER_H
|
||||
#define SUPIPEDUNARCHIVER_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUUnarchiver.h"
|
||||
|
||||
@interface SUPipedUnarchiver : SUUnarchiver {
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// SUPipedUnarchiver.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 6/16/08.
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUPipedUnarchiver.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
|
||||
@implementation SUPipedUnarchiver
|
||||
|
||||
+ (SEL)_selectorConformingToTypeOfURL:(NSURL *)URL
|
||||
{
|
||||
static NSDictionary *typeSelectorDictionary;
|
||||
if (!typeSelectorDictionary)
|
||||
typeSelectorDictionary = [[NSDictionary dictionaryWithObjectsAndKeys:@"_extractZIP", @"public.zip-archive", @"_extractTGZ", @"org.gnu.gnu-zip-tar-archive", @"_extractTBZ", @"org.bzip.bzip2-tar-archive", @"_extractTAR", @"public.tar-archive", nil] retain];
|
||||
|
||||
NSEnumerator *typeEnumerator = [typeSelectorDictionary keyEnumerator];
|
||||
id currentType;
|
||||
while ((currentType = [typeEnumerator nextObject]))
|
||||
{
|
||||
if ([URL conformsToType:currentType])
|
||||
return NSSelectorFromString([typeSelectorDictionary objectForKey:currentType]);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
[NSThread detachNewThreadSelector:[[self class] _selectorConformingToTypeOfURL:archiveURL] toTarget:self withObject:nil];
|
||||
}
|
||||
|
||||
+ (BOOL)_canUnarchiveURL:(NSURL *)URL
|
||||
{
|
||||
return ([self _selectorConformingToTypeOfURL:URL] != nil);
|
||||
}
|
||||
|
||||
// This method abstracts the types that use a command line tool piping data from stdin.
|
||||
- (void)_extractArchivePipingDataToCommand:(NSString *)command
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSString *archivePath = [archiveURL path];
|
||||
|
||||
// Get the file size.
|
||||
NSNumber *fs = [[[NSFileManager defaultManager] fileAttributesAtPath:archivePath traverseLink:NO] objectForKey:NSFileSize];
|
||||
if (fs == nil) goto reportError;
|
||||
|
||||
// Thank you, Allan Odgaard!
|
||||
// (who wrote the following extraction alg.)
|
||||
|
||||
long current = 0;
|
||||
FILE *fp, *cmdFP;
|
||||
if ((fp = fopen([archivePath fileSystemRepresentation], "r")))
|
||||
{
|
||||
setenv("DESTINATION", [[archivePath stringByDeletingLastPathComponent] UTF8String], 1);
|
||||
if ((cmdFP = popen([command fileSystemRepresentation], "w")))
|
||||
{
|
||||
char buf[32*1024];
|
||||
long len;
|
||||
while((len = fread(buf, 1, 32*1024, fp)))
|
||||
{
|
||||
current += len;
|
||||
fwrite(buf, 1, len, cmdFP);
|
||||
[self performSelectorOnMainThread:@selector(_notifyDelegateOfExtractedLength:) withObject:[NSNumber numberWithLong:len] waitUntilDone:NO];
|
||||
}
|
||||
pclose(cmdFP);
|
||||
}
|
||||
else goto reportError;
|
||||
}
|
||||
else goto reportError;
|
||||
|
||||
[self performSelectorOnMainThread:@selector(_notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
|
||||
goto finally;
|
||||
|
||||
reportError:
|
||||
[self performSelectorOnMainThread:@selector(_notifyDelegateOfFailure) withObject:nil waitUntilDone:NO];
|
||||
|
||||
finally:
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
- (void)_extractTAR
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"tar -xC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (void)_extractTGZ
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"tar -zxC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (void)_extractTBZ
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"tar -jxC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (void)_extractZIP
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"ditto -x -k - \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[self _registerImplementation:self];
|
||||
}
|
||||
|
||||
@end
|
||||
+4
-3
@@ -11,12 +11,13 @@
|
||||
|
||||
@interface SUUnarchiver : NSObject {
|
||||
id delegate;
|
||||
NSString *archivePath;
|
||||
NSURL *archiveURL;
|
||||
}
|
||||
|
||||
- (void)unarchivePath:(NSString *)path;
|
||||
+ (SUUnarchiver *)unarchiverForURL:(NSURL *)URL;
|
||||
- (void)setDelegate:delegate;
|
||||
- (void)cleanUp;
|
||||
|
||||
- (void)start;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+12
-165
@@ -9,147 +9,22 @@
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
|
||||
@implementation SUUnarchiver
|
||||
|
||||
// This method abstracts the types that use a command line tool piping data from stdin.
|
||||
- (BOOL)_extractArchivePipingDataToCommand:(NSString *)command
|
||||
extern NSMutableArray *__unarchiverImplementations;
|
||||
|
||||
+ (SUUnarchiver *)unarchiverForURL:(NSURL *)URL
|
||||
{
|
||||
// Get the file size.
|
||||
NSNumber *fs = [[[NSFileManager defaultManager] fileAttributesAtPath:archivePath traverseLink:NO] objectForKey:NSFileSize];
|
||||
if (fs == nil) { return NO; }
|
||||
|
||||
// Thank you, Allan Odgaard!
|
||||
// (who wrote the following extraction alg.)
|
||||
|
||||
long current = 0;
|
||||
FILE *fp, *cmdFP;
|
||||
if ((fp = fopen([archivePath fileSystemRepresentation], "r")))
|
||||
NSEnumerator *implementationEnumerator = [[self _unarchiverImplementations] objectEnumerator];
|
||||
id current;
|
||||
while ((current = [implementationEnumerator nextObject]))
|
||||
{
|
||||
setenv("DESTINATION", [[archivePath stringByDeletingLastPathComponent] UTF8String], 1);
|
||||
if ((cmdFP = popen([command fileSystemRepresentation], "w")))
|
||||
{
|
||||
char buf[32*1024];
|
||||
long len;
|
||||
while((len = fread(buf, 1, 32 * 1024, fp)))
|
||||
{
|
||||
current += len;
|
||||
|
||||
NSEvent *event;
|
||||
while((event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]))
|
||||
[NSApp sendEvent:event];
|
||||
|
||||
fwrite(buf, 1, len, cmdFP);
|
||||
|
||||
[self performSelectorOnMainThread:@selector(notifyDelegateOfExtractedLength:) withObject:[NSNumber numberWithLong:len] waitUntilDone:NO];
|
||||
}
|
||||
pclose(cmdFP);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)_extractTAR
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"tar -xC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (BOOL)_extractTGZ
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"tar -zxC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (BOOL)_extractTBZ
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"tar -jxC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (BOOL)_extractZIP
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"ditto -x -k - \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (BOOL)_extractDMG
|
||||
{
|
||||
// get a unique mount point path
|
||||
NSString *mountPoint = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"mp"];
|
||||
int cnt=1;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:mountPoint] && cnt <= 999)
|
||||
mountPoint = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"mp%d", cnt++]];
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:mountPoint])
|
||||
{
|
||||
// create mount point folder
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:mountPoint attributes:nil];
|
||||
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:mountPoint])
|
||||
{
|
||||
NSArray* arguments = [NSArray arrayWithObjects:@"attach", archivePath, @"-mountpoint", mountPoint, @"-noverify", @"-nobrowse", @"-noautoopen", nil];
|
||||
// set up a pipe and push "yes" (y works too), this will accept any license agreement crap
|
||||
// not every .dmg needs this, but this will make sure it works with everyone
|
||||
NSData* yesData = [[[NSData alloc] initWithBytes:"yes\n" length:4] autorelease];
|
||||
|
||||
[NTSynchronousTask task:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:yesData];
|
||||
}
|
||||
if ([current _canUnarchiveURL:URL])
|
||||
return [[[current alloc] _initWithURL:URL] autorelease];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)_unarchive
|
||||
{
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
// This dictionary associates names of methods responsible for extraction with file extensions.
|
||||
// The methods take the path of the archive to extract. They return a BOOL indicating whether
|
||||
// we should continue with the update; returns NO if an error occurred.
|
||||
NSDictionary *commandDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"_extractTBZ", @".tbz",
|
||||
@"_extractTBZ", @".tar.bz2",
|
||||
@"_extractTGZ", @".tgz",
|
||||
@"_extractTGZ", @".tar.gz",
|
||||
@"_extractTAR", @".tar",
|
||||
@"_extractZIP", @".zip",
|
||||
@"_extractDMG", @".dmg",
|
||||
nil];
|
||||
SEL command = NULL;
|
||||
NSString *theLastPathComponent = [[archivePath lastPathComponent] lowercaseString];
|
||||
NSEnumerator *theEnumerator = [[commandDictionary allKeys] objectEnumerator];
|
||||
NSString *theExtension = NULL;
|
||||
while ((theExtension = [theEnumerator nextObject]) != NULL)
|
||||
{
|
||||
if ([[theLastPathComponent substringFromIndex:[theLastPathComponent length] - [theExtension length]] isEqualToString:theExtension])
|
||||
{
|
||||
command = NSSelectorFromString([commandDictionary objectForKey:theExtension]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL result;
|
||||
if (command)
|
||||
{
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:command]];
|
||||
[invocation setSelector:command];
|
||||
[invocation invokeWithTarget:self];
|
||||
[invocation getReturnValue:&result];
|
||||
}
|
||||
else
|
||||
result = NO;
|
||||
|
||||
if (result)
|
||||
[self performSelectorOnMainThread:@selector(notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
|
||||
else
|
||||
[self performSelectorOnMainThread:@selector(notifyDelegateOfFailure) withObject:nil waitUntilDone:NO];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
- (void)unarchivePath:(NSString *)path
|
||||
{
|
||||
archivePath = [path copy];
|
||||
[NSThread detachNewThreadSelector:@selector(_unarchive) toTarget:self withObject:nil];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setDelegate:del
|
||||
@@ -157,37 +32,9 @@
|
||||
delegate = del;
|
||||
}
|
||||
|
||||
- (void)cleanUp
|
||||
- (void)start
|
||||
{
|
||||
if ([[archivePath pathExtension] isEqualToString:@".dmg"])
|
||||
{
|
||||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"detach", [archivePath stringByDeletingLastPathComponent], @"-force", nil]];
|
||||
}
|
||||
[[NSFileManager defaultManager] removeFileAtPath:archivePath handler:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[archivePath release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOfExtractedLength:(long)length
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiver:extractedLength:)])
|
||||
[delegate unarchiver:self extractedLength:length];
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOfSuccess
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiverDidFinish:)])
|
||||
[delegate performSelector:@selector(unarchiverDidFinish:) withObject:self];
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOfFailure
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiverDidFail:)])
|
||||
[delegate performSelector:@selector(unarchiverDidFail:) withObject:self];
|
||||
// No-op
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// SUUnarchiver_Private.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 6/17/08.
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUUNARCHIVER_PRIVATE_H
|
||||
#define SUUNARCHIVER_PRIVATE_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUUnarchiver.h"
|
||||
|
||||
@interface SUUnarchiver (Private)
|
||||
+ (void)_registerImplementation:(Class)implementation;
|
||||
+ (NSArray *)_unarchiverImplementations;
|
||||
+ (BOOL)_canUnarchiveURL:(NSURL *)URL;
|
||||
- _initWithURL:(NSURL *)URL;
|
||||
|
||||
- (void)_notifyDelegateOfExtractedLength:(long)length;
|
||||
- (void)_notifyDelegateOfSuccess;
|
||||
- (void)_notifyDelegateOfFailure;
|
||||
@end
|
||||
|
||||
@interface NSURL (SUTypeDetection)
|
||||
- (BOOL)conformsToType:(NSString *)type;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// SUUnarchiver_Private.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 6/17/08.
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUUnarchiver_Private.h"
|
||||
|
||||
@implementation SUUnarchiver (Private)
|
||||
|
||||
- _initWithURL:(NSURL *)URL
|
||||
{
|
||||
if ((self = [super init]))
|
||||
archiveURL = [URL copy];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[archiveURL release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
+ (BOOL)_canUnarchiveURL:(NSURL *)URL
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)_notifyDelegateOfExtractedLength:(long)length
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiver:extractedLength:)])
|
||||
[delegate unarchiver:self extractedLength:length];
|
||||
}
|
||||
|
||||
- (void)_notifyDelegateOfSuccess
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiverDidFinish:)])
|
||||
[delegate performSelector:@selector(unarchiverDidFinish:) withObject:self];
|
||||
}
|
||||
|
||||
- (void)_notifyDelegateOfFailure
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiverDidFail:)])
|
||||
[delegate performSelector:@selector(unarchiverDidFail:) withObject:self];
|
||||
}
|
||||
|
||||
static NSMutableArray *__unarchiverImplementations;
|
||||
|
||||
+ (void)_registerImplementation:(Class)implementation
|
||||
{
|
||||
if (!__unarchiverImplementations)
|
||||
__unarchiverImplementations = [[NSMutableArray array] retain];
|
||||
[__unarchiverImplementations addObject:implementation];
|
||||
}
|
||||
|
||||
+ (NSArray *)_unarchiverImplementations
|
||||
{
|
||||
//return [NSArray arrayWithObjects:NSClassFromString(@"SUPipedUnarchiver"), NSClassFromString(@"SUDiskImageUnarchiver"), nil];
|
||||
return [NSArray arrayWithArray:__unarchiverImplementations];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSURL (SUTypeDetection)
|
||||
- (NSString *)__UTI
|
||||
{
|
||||
FSRef fsRefToItem;
|
||||
FSPathMakeRef((UInt8 *)[[self path] UTF8String], &fsRefToItem, NULL );
|
||||
|
||||
NSString *UTI = nil;
|
||||
LSCopyItemAttribute(&fsRefToItem, kLSRolesAll, kLSItemContentType, (CFTypeRef *)(&UTI));
|
||||
return [UTI autorelease];
|
||||
}
|
||||
|
||||
- (BOOL)conformsToType:(NSString *)type
|
||||
{
|
||||
return UTTypeConformsTo((CFStringRef)[self __UTI], (CFStringRef)type);
|
||||
}
|
||||
@end
|
||||
@@ -14,6 +14,7 @@
|
||||
#define SPARKLE_H
|
||||
|
||||
#define SULocalizedString(key,comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", [NSBundle bundleForClass:[self class]], comment)
|
||||
#define SUAbstractFail() NSAssert2(nil, @"Can't call %@ on an instance of %@; this is an abstract method!", __PRETTY_FUNCTION__, [self class]);
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
610134780DD252E60049ACDF /* NSWorkspace+SystemVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = 610134760DD252E60049ACDF /* NSWorkspace+SystemVersion.m */; };
|
||||
6101347B0DD2541A0049ACDF /* SUProbingUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6101347A0DD2541A0049ACDF /* SUProbingUpdateDriver.m */; };
|
||||
6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
6102FE470E077FCE00F85D09 /* SUPipedUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE450E077FCE00F85D09 /* SUPipedUnarchiver.m */; };
|
||||
6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */; };
|
||||
6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
6102FE5C0E08C7EC00F85D09 /* SUUnarchiver_Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */; };
|
||||
61072EB30DF2640C008FE88B /* ConfigFrameworkReleaseGCSupport.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 61072EB20DF2640C008FE88B /* ConfigFrameworkReleaseGCSupport.xcconfig */; };
|
||||
610D5A1A0A1661B8004AAD9C /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; };
|
||||
610D5A750A1670A4004AAD9C /* SUStatus.nib in Resources */ = {isa = PBXBuildFile; fileRef = 610D5A740A1670A4004AAD9C /* SUStatus.nib */; };
|
||||
@@ -97,7 +103,7 @@
|
||||
61C46F340D9C54F300B06326 /* SUUpdatePermissionPrompt.nib in Resources */ = {isa = PBXBuildFile; fileRef = 61C46F330D9C54F300B06326 /* SUUpdatePermissionPrompt.nib */; };
|
||||
61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; };
|
||||
61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
784590C10DE0429F00D0D64B /* NSNumber+Units.h in Headers */ = {isa = PBXBuildFile; fileRef = 784590BF0DE0429F00D0D64B /* NSNumber+Units.h */; };
|
||||
784590C10DE0429F00D0D64B /* NSNumber+Units.h in Headers */ = {isa = PBXBuildFile; fileRef = 784590BF0DE0429F00D0D64B /* NSNumber+Units.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
784590C20DE0429F00D0D64B /* NSNumber+Units.m in Sources */ = {isa = PBXBuildFile; fileRef = 784590C00DE0429F00D0D64B /* NSNumber+Units.m */; };
|
||||
DAAEFC9B0DA5722F0051E0D0 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
|
||||
DAAEFD4E0DA572330051E0D0 /* relaunch.m in Sources */ = {isa = PBXBuildFile; fileRef = 613242130CD06CEF00106AA4 /* relaunch.m */; };
|
||||
@@ -161,6 +167,12 @@
|
||||
610134760DD252E60049ACDF /* NSWorkspace+SystemVersion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSWorkspace+SystemVersion.m"; sourceTree = "<group>"; };
|
||||
610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUProbingUpdateDriver.h; sourceTree = "<group>"; };
|
||||
6101347A0DD2541A0049ACDF /* SUProbingUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUProbingUpdateDriver.m; sourceTree = "<group>"; };
|
||||
6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUPipedUnarchiver.h; sourceTree = "<group>"; };
|
||||
6102FE450E077FCE00F85D09 /* SUPipedUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUPipedUnarchiver.m; sourceTree = "<group>"; };
|
||||
6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUDiskImageUnarchiver.h; sourceTree = "<group>"; };
|
||||
6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDiskImageUnarchiver.m; sourceTree = "<group>"; };
|
||||
6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUnarchiver_Private.h; sourceTree = "<group>"; };
|
||||
6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUnarchiver_Private.m; sourceTree = "<group>"; };
|
||||
61072EB20DF2640C008FE88B /* ConfigFrameworkReleaseGCSupport.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigFrameworkReleaseGCSupport.xcconfig; sourceTree = "<group>"; };
|
||||
610D5A740A1670A4004AAD9C /* SUStatus.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = SUStatus.nib; sourceTree = "<group>"; };
|
||||
610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NTSynchronousTask.m; sourceTree = "<group>"; };
|
||||
@@ -394,6 +406,12 @@
|
||||
children = (
|
||||
61299A8B09CA790200B7442F /* SUUnarchiver.h */,
|
||||
61299A8C09CA790200B7442F /* SUUnarchiver.m */,
|
||||
6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */,
|
||||
6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */,
|
||||
6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */,
|
||||
6102FE450E077FCE00F85D09 /* SUPipedUnarchiver.m */,
|
||||
6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */,
|
||||
6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */,
|
||||
610EC1C00CF3914D00AE239E /* NTSynchronousTask.h */,
|
||||
610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */,
|
||||
);
|
||||
@@ -600,6 +618,9 @@
|
||||
61699BCC0DDB92BD005878A4 /* SUVersionComparisonTest.h in Headers */,
|
||||
784590C10DE0429F00D0D64B /* NSNumber+Units.h in Headers */,
|
||||
61A354550DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.h in Headers */,
|
||||
6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */,
|
||||
6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */,
|
||||
6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -859,6 +880,9 @@
|
||||
6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */,
|
||||
784590C20DE0429F00D0D64B /* NSNumber+Units.m in Sources */,
|
||||
61A354560DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.m in Sources */,
|
||||
6102FE470E077FCE00F85D09 /* SUPipedUnarchiver.m in Sources */,
|
||||
6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */,
|
||||
6102FE5C0E08C7EC00F85D09 /* SUUnarchiver_Private.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user