forked from sparkle-project/Sparkle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SUBinaryDeltaUnarchiver.m
48 lines (39 loc) · 1.24 KB
/
SUBinaryDeltaUnarchiver.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// SUBinaryDeltaUnarchiver.m
// Sparkle
//
// Created by Mark Rowe on 2009-06-03.
// Copyright 2009 Mark Rowe. All rights reserved.
//
#import "SUBinaryDeltaCommon.h"
#import "SUBinaryDeltaUnarchiver.h"
#import "SUBinaryDeltaApply.h"
#import "SUUnarchiver_Private.h"
#import "SUHost.h"
#import "NTSynchronousTask.h"
@implementation SUBinaryDeltaUnarchiver
+ (BOOL)canUnarchivePath:(NSString *)path
{
return binaryDeltaSupported() && [[path pathExtension] isEqualToString:@"delta"];
}
- (void)applyBinaryDelta
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *sourcePath = [[updateHost bundle] bundlePath];
NSString *targetPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
int result = applyBinaryDelta(sourcePath, targetPath, archivePath);
if (!result)
[self performSelectorOnMainThread:@selector(notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
else
[self performSelectorOnMainThread:@selector(notifyDelegateOfFailure) withObject:nil waitUntilDone:NO];
[pool drain];
}
- (void)start
{
[NSThread detachNewThreadSelector:@selector(applyBinaryDelta) toTarget:self withObject:nil];
}
+ (void)load
{
[self registerImplementation:self];
}
@end