17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <errno.h>
#import "OFApplication.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OFPair.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFString.h"
|
>
>
>
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <errno.h>
#import "OFApplication.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFFile.h"
#import "OFFileManager.h"
#import "OFIRI.h"
#import "OFIRIHandler.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OFPair.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFString.h"
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
@implementation ZIPArchive
+ (void)initialize
{
if (self == [ZIPArchive class])
app = (OFArc *)[OFApplication sharedApplication].delegate;
}
+ (instancetype)archiveWithPath: (OFString *)path
stream: (OF_KINDOF(OFStream *))stream
mode: (OFString *)mode
encoding: (OFStringEncoding)encoding
{
return [[[self alloc] initWithPath: path
stream: stream
mode: mode
encoding: encoding] autorelease];
}
- (instancetype)initWithPath: (OFString *)path
stream: (OF_KINDOF(OFStream *))stream
mode: (OFString *)mode
encoding: (OFStringEncoding)encoding
{
self = [super init];
@try {
_path = [path copy];
_archive = [[OFZIPArchive alloc] initWithStream: stream
mode: mode];
_archive.delegate = self;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_path release];
[_archive release];
[super dealloc];
}
- (OFSeekableStream *)archive: (OFZIPArchive *)archive
wantsPartNumbered: (unsigned int)partNumber
lastPartNumber: (unsigned int)lastPartNumber
{
OFString *path;
if ([_path.pathExtension caseInsensitiveCompare: @"zip"] !=
OFOrderedSame)
return nil;
if (partNumber > 98)
return nil;
if (partNumber == lastPartNumber)
path = _path;
else
path = [_path.stringByDeletingPathExtension
stringByAppendingFormat: @".z%02u", partNumber + 1];
return [OFFile fileWithPath: path mode: @"r"];
}
- (void)listFiles
{
for (OFZIPArchiveEntry *entry in _archive.entries) {
void *pool = objc_autoreleasePoolPush();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
>
>
|
|
>
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
@implementation ZIPArchive
+ (void)initialize
{
if (self == [ZIPArchive class])
app = (OFArc *)[OFApplication sharedApplication].delegate;
}
+ (instancetype)archiveWithIRI: (OFIRI *)IRI
stream: (OF_KINDOF(OFStream *))stream
mode: (OFString *)mode
encoding: (OFStringEncoding)encoding
{
return [[[self alloc] initWithIRI: IRI
stream: stream
mode: mode
encoding: encoding] autorelease];
}
- (instancetype)initWithIRI: (OFIRI *)IRI
stream: (OF_KINDOF(OFStream *))stream
mode: (OFString *)mode
encoding: (OFStringEncoding)encoding
{
self = [super init];
@try {
_archiveIRI = [IRI copy];
_archive = [[OFZIPArchive alloc] initWithStream: stream
mode: mode];
_archive.delegate = self;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_archiveIRI release];
[_archive release];
[super dealloc];
}
- (OFSeekableStream *)archive: (OFZIPArchive *)archive
wantsPartNumbered: (unsigned int)partNumber
lastPartNumber: (unsigned int)lastPartNumber
{
OFIRI *IRI;
if ([_archiveIRI.path.pathExtension caseInsensitiveCompare: @"zip"] !=
OFOrderedSame)
return nil;
if (partNumber > 98)
return nil;
if (partNumber == lastPartNumber)
IRI = _archiveIRI;
else {
OFMutableIRI *copy = [[_archiveIRI mutableCopy] autorelease];
copy.path = [_archiveIRI.path.stringByDeletingPathExtension
stringByAppendingFormat: @".z%02u", partNumber + 1];
[copy makeImmutable];
IRI = copy;
}
return (OFSeekableStream *)[OFIRIHandler openItemAtIRI: IRI mode: @"r"];
}
- (void)listFiles
{
for (OFZIPArchiveEntry *entry in _archive.entries) {
void *pool = objc_autoreleasePoolPush();
|