forked from sparkle-project/Sparkle
/
SUUnarchiver_Private.m
80 lines (65 loc) · 1.76 KB
/
SUUnarchiver_Private.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// 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 alloc] init];
[__unarchiverImplementations addObject:implementation];
}
+ (NSArray *)_unarchiverImplementations
{
return [NSArray arrayWithArray:__unarchiverImplementations];
}
@end
@implementation NSURL (SUTypeDetection)
- (NSString *)__UTI
{
FSRef fsRefToItem;
FSPathMakeRef((UInt8 *)[[self path] fileSystemRepresentation], &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