︙ | | | ︙ | |
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
|
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#import "OFWriteFailedException.h"
@interface OFTarArchive_FileReadStream: OFStream <OFReadyForReadingObserving>
{
OFTarArchiveEntry *_entry;
OFStream *_stream;
uint64_t _toRead;
bool _atEndOfStream, _skipped;
}
- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFTarArchiveEntry *)entry;
- (void)of_skip;
@end
@interface OFTarArchive_FileWriteStream: OFStream <OFReadyForWritingObserving>
{
OFTarArchiveEntry *_entry;
OFStream *_stream;
uint64_t _toWrite;
}
- (instancetype)of_initWithStream: (OFStream *)stream
|
|
|
|
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
|
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#import "OFWriteFailedException.h"
@interface OFTarArchiveFileReadStream: OFStream <OFReadyForReadingObserving>
{
OFTarArchiveEntry *_entry;
OFStream *_stream;
uint64_t _toRead;
bool _atEndOfStream, _skipped;
}
- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFTarArchiveEntry *)entry;
- (void)of_skip;
@end
@interface OFTarArchiveFileWriteStream: OFStream <OFReadyForWritingObserving>
{
OFTarArchiveEntry *_entry;
OFStream *_stream;
uint64_t _toWrite;
}
- (instancetype)of_initWithStream: (OFStream *)stream
|
︙ | | | ︙ | |
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
uint32_t u32[512 / sizeof(uint32_t)];
} buffer;
bool empty = true;
if (_mode != OF_TAR_ARCHIVE_MODE_READ)
@throw [OFInvalidArgumentException exception];
[(OFTarArchive_FileReadStream *)_lastReturnedStream of_skip];
[_lastReturnedStream close];
[_lastReturnedStream release];
_lastReturnedStream = nil;
if (_stream.atEndOfStream)
return nil;
|
|
|
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
uint32_t u32[512 / sizeof(uint32_t)];
} buffer;
bool empty = true;
if (_mode != OF_TAR_ARCHIVE_MODE_READ)
@throw [OFInvalidArgumentException exception];
[(OFTarArchiveFileReadStream *)_lastReturnedStream of_skip];
[_lastReturnedStream close];
[_lastReturnedStream release];
_lastReturnedStream = nil;
if (_stream.atEndOfStream)
return nil;
|
︙ | | | ︙ | |
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
return nil;
}
entry = [[[OFTarArchiveEntry alloc]
of_initWithHeader: buffer.c
encoding: _encoding] autorelease];
_lastReturnedStream = [[OFTarArchive_FileReadStream alloc]
of_initWithStream: _stream
entry: entry];
return entry;
}
- (OFStream <OFReadyForReadingObserving> *)streamForReadingCurrentEntry
{
if (_mode != OF_TAR_ARCHIVE_MODE_READ)
@throw [OFInvalidArgumentException exception];
if (_lastReturnedStream == nil)
@throw [OFInvalidArgumentException exception];
return [[(OFTarArchive_FileReadStream *)_lastReturnedStream
retain] autorelease];
}
- (OFStream <OFReadyForWritingObserving> *)
streamForWritingEntry: (OFTarArchiveEntry *)entry
{
void *pool;
|
|
|
|
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
return nil;
}
entry = [[[OFTarArchiveEntry alloc]
of_initWithHeader: buffer.c
encoding: _encoding] autorelease];
_lastReturnedStream = [[OFTarArchiveFileReadStream alloc]
of_initWithStream: _stream
entry: entry];
return entry;
}
- (OFStream <OFReadyForReadingObserving> *)streamForReadingCurrentEntry
{
if (_mode != OF_TAR_ARCHIVE_MODE_READ)
@throw [OFInvalidArgumentException exception];
if (_lastReturnedStream == nil)
@throw [OFInvalidArgumentException exception];
return [[(OFTarArchiveFileReadStream *)_lastReturnedStream
retain] autorelease];
}
- (OFStream <OFReadyForWritingObserving> *)
streamForWritingEntry: (OFTarArchiveEntry *)entry
{
void *pool;
|
︙ | | | ︙ | |
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
[_lastReturnedStream close];
[_lastReturnedStream release];
_lastReturnedStream = nil;
[entry of_writeToStream: _stream
encoding: _encoding];
_lastReturnedStream = [[OFTarArchive_FileWriteStream alloc]
of_initWithStream: _stream
entry: entry];
objc_autoreleasePoolPop(pool);
return [[(OFTarArchive_FileWriteStream *)_lastReturnedStream
retain] autorelease];
}
- (void)close
{
if (_stream == nil)
return;
|
|
|
|
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
[_lastReturnedStream close];
[_lastReturnedStream release];
_lastReturnedStream = nil;
[entry of_writeToStream: _stream
encoding: _encoding];
_lastReturnedStream = [[OFTarArchiveFileWriteStream alloc]
of_initWithStream: _stream
entry: entry];
objc_autoreleasePoolPop(pool);
return [[(OFTarArchiveFileWriteStream *)_lastReturnedStream
retain] autorelease];
}
- (void)close
{
if (_stream == nil)
return;
|
︙ | | | ︙ | |
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
}
[_stream release];
_stream = nil;
}
@end
@implementation OFTarArchive_FileReadStream
- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFTarArchiveEntry *)entry
{
self = [super init];
@try {
_entry = [entry copy];
|
|
|
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
}
[_stream release];
_stream = nil;
}
@end
@implementation OFTarArchiveFileReadStream
- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFTarArchiveEntry *)entry
{
self = [super init];
@try {
_entry = [entry copy];
|
︙ | | | ︙ | |
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
|
exactLength: (size_t)(512 - (size % 512))];
}
_skipped = true;
}
@end
@implementation OFTarArchive_FileWriteStream
- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFTarArchiveEntry *)entry
{
self = [super init];
@try {
_entry = [entry copy];
|
|
|
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
|
exactLength: (size_t)(512 - (size % 512))];
}
_skipped = true;
}
@end
@implementation OFTarArchiveFileWriteStream
- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFTarArchiveEntry *)entry
{
self = [super init];
@try {
_entry = [entry copy];
|
︙ | | | ︙ | |