ObjFW  Diff

Differences From Artifact [794d54862e]:

To Artifact [944c9a1051]:


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
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







+















-
+








#include "config.h"

#import "OFTarArchive.h"
#import "OFTarArchiveEntry.h"
#import "OFTarArchiveEntry+Private.h"
#import "OFStream.h"
#import "OFSeekableStream.h"
#import "OFDate.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
#endif

#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#import "OFWriteFailedException.h"

@interface OFTarArchive_FileReadStream: OFStream
{
	OFTarArchiveEntry *_entry;
	OFStream *_stream;
	OF_KINDOF(OFStream *) _stream;
	uint64_t _toRead;
	bool _atEndOfStream;
}

- initWithStream: (OFStream *)stream
	   entry: (OFTarArchiveEntry *)entry;
- (void)of_skip;
336
337
338
339
340
341
342















343
344


345
346
347
348
349
350





351
352
353
354
355
356





357
358

359
360
361
362




363
364
365
366
367
368
369
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358


359
360
361





362
363
364
365
366
367





368
369
370
371
372
373

374
375



376
377
378
379
380
381
382
383
384
385
386







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+

-
-
-
-
-
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+

-
+

-
-
-
+
+
+
+







	_stream = nil;

	[super close];
}

- (void)of_skip
{
	if ([_stream isKindOfClass: [OFSeekableStream class]] &&
	    _toRead <= INT64_MAX && (of_offset_t)_toRead == (int64_t)_toRead) {
		uint64_t size;

		[_stream seekToOffset: (of_offset_t)_toRead
			       whence: SEEK_CUR];

		_toRead = 0;

		size = [_entry size];

		if (size % 512 != 0)
			[_stream seekToOffset: 512 - (size % 512)
				       whence: SEEK_CUR];
	} else {
	char buffer[512];
	uint64_t size;
		char buffer[512];
		uint64_t size;

	while (_toRead >= 512) {
		[_stream readIntoBuffer: buffer
			    exactLength: 512];
		_toRead -= 512;
	}
		while (_toRead >= 512) {
			[_stream readIntoBuffer: buffer
				    exactLength: 512];
			_toRead -= 512;
		}

	if (_toRead > 0) {
		[_stream readIntoBuffer: buffer
			    exactLength: (size_t)_toRead];
		_toRead = 0;
	}
		if (_toRead > 0) {
			[_stream readIntoBuffer: buffer
				    exactLength: (size_t)_toRead];
			_toRead = 0;
		}

	size = [_entry size];
		size = [_entry size];

	if (size % 512 != 0)
		[_stream readIntoBuffer: buffer
			    exactLength: 512 - ((size_t)size % 512)];
		if (size % 512 != 0)
			[_stream readIntoBuffer: buffer
				    exactLength: 512 - (size % 512)];
	}
}
@end

@implementation OFTarArchive_FileWriteStream
- initWithStream: (OFStream *)stream
	   entry: (OFTarArchiveEntry *)entry
{