ObjFW  Check-in [f4da2cffa9]

Overview
Comment:OFZIPArchive: Fix a few type mismatches.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f4da2cffa930a8553131134cb0dbcaed8e46da86b3bb3102a2b1ffdead21cedd
User & Date: js on 2013-11-24 19:21:05
Other Links: manifest | tags
Context
2013-11-26
10:25
runtime: Free runtime created selectors at exit. check-in: 0ede45ce93 user: js tags: trunk
2013-11-24
19:21
OFZIPArchive: Fix a few type mismatches. check-in: f4da2cffa9 user: js tags: trunk
18:57
OFString.h: Revert something that slipped in. check-in: 8486e8c42a user: js tags: trunk
Changes

Modified src/OFZIPArchive.m from [6bc862255c] to [a531eb9595].

70
71
72
73
74
75
76
77

78
79
80
81
82
83
84
70
71
72
73
74
75
76

77
78
79
80
81
82
83
84







-
+








@interface OFZIPArchive_FileStream: OFStream
{
	OFStream *_stream;
	OFFile *_file;
	OFZIPArchive_LocalFileHeader *_localFileHeader;
	bool _hasDataDescriptor;
	size_t _size;
	uint64_t _size;
	uint32_t _CRC32;
	bool _atEndOfStream;
}

- initWithArchiveFile: (OFString*)path
	       offset: (off_t)offset
      localFileHeader: (OFZIPArchive_LocalFileHeader*)localFileHeader;
304
305
306
307
308
309
310
311

312
313
314
315
316
317
318
304
305
306
307
308
309
310

311
312
313
314
315
316
317
318







-
+







{
	void *pool = objc_autoreleasePoolPush();
	size_t i;

	if ((off_t)_centralDirectoryOffset != _centralDirectoryOffset)
		@throw [OFOutOfRangeException exception];

	[_file seekToOffset: _centralDirectoryOffset
	[_file seekToOffset: (off_t)_centralDirectoryOffset
		     whence: SEEK_SET];

	_entries = [[OFMutableArray alloc] init];
	_pathToEntryMap = [[OFMutableDictionary alloc] init];

	for (i = 0; i < _centralDirectoryEntries; i++) {
		OFZIPArchiveEntry *entry = [[[OFZIPArchiveEntry alloc]
356
357
358
359
360
361
362
363

364
365
366
367
368
369
370
356
357
358
359
360
361
362

363
364
365
366
367
368
369
370







-
+







							       mode: @"rb"];
	}

	offset = [entry OF_localFileHeaderOffset];
	if ((off_t)offset != offset)
		@throw [OFOutOfRangeException exception];

	[_file seekToOffset: offset
	[_file seekToOffset: (off_t)offset
		     whence: SEEK_SET];
	localFileHeader = [[[OFZIPArchive_LocalFileHeader alloc]
	    initWithFile: _file] autorelease];

	if (![localFileHeader matchesEntry: entry])
		@throw [OFInvalidFormatException exception];

570
571
572
573
574
575
576
577

578
579
580
581
582
583
584
585
586
587
570
571
572
573
574
575
576

577
578
579
580
581
582
583
584
585
586
587







-
+











			if (~_CRC32 != _localFileHeader->_CRC32)
				@throw [OFChecksumFailedException exception];

			return 0;
		}

		min = (length < _size ? length : _size);
		min = (length < _size ? length : (size_t)_size);
		ret = [_stream readIntoBuffer: buffer
				       length: min];
		_size -= ret;
	}

	_CRC32 = crc32(_CRC32, buffer, ret);

	return ret;
}
@end

Modified utils/OFZIP.m from [7a27c4516e] to [7be8bd0d44].

174
175
176
177
178
179
180
181

182
183
184
185
186
187
188
174
175
176
177
178
179
180

181
182
183
184
185
186
187
188







-
+







		OFString *fileName = [entry fileName];
		OFString *outFileName = [fileName stringByStandardizingPath];
		OFEnumerator *componentEnumerator;
		OFString *component, *directory;
		OFStream *stream;
		OFFile *output;
		char buffer[BUFFER_SIZE];
		off_t written = 0, size = [entry uncompressedSize];
		uint64_t written = 0, size = [entry uncompressedSize];
		int_fast8_t percent = -1, newPercent;

		if (!all && ![files containsObject: fileName])
			continue;

		[missing removeObject: fileName];