forked from arqbackup/arq_restore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommitFailedFile.m
62 lines (59 loc) · 1.57 KB
/
CommitFailedFile.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
//
// CommitFailedFile.m
// Arq
//
// Created by Stefan Reitshamer on 2/22/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "CommitFailedFile.h"
#import "StringIO.h"
#import "BufferedInputStream.h"
@implementation CommitFailedFile
- (id)initWithPath:(NSString *)thePath errorMessage:(NSString *)theErrorMessage {
if (self = [super init]) {
path = [thePath copy];
errorMessage = [theErrorMessage copy];
}
return self;
}
- (id)initWithInputStream:(BufferedInputStream *)is error:(NSError **)error {
if (self = [super init]) {
if (![StringIO read:&path from:is error:error]
|| ![StringIO read:&errorMessage from:is error:error]) {
[self release];
return nil;
}
[path retain];
[errorMessage retain];
}
return self;
}
- (void)dealloc {
[path release];
[errorMessage release];
[super dealloc];
}
- (NSString *)path {
return [[path retain] autorelease];
}
- (NSString *)errorMessage {
return [[errorMessage retain] autorelease];
}
- (void)writeTo:(NSMutableData *)data {
[StringIO write:path to:data];
[StringIO write:errorMessage to:data];
}
- (BOOL)isEqualToCommitFailedFile:(CommitFailedFile *)cff {
return [[cff path] isEqualToString:path] && [[cff errorMessage] isEqualToString:errorMessage];
}
#pragma mark NSObject
- (BOOL)isEqual:(id)other {
if (other == self) {
return YES;
}
if (other == nil || ![other isKindOfClass:[self class]]) {
return NO;
}
return [self isEqualToCommitFailedFile:other];
}
@end