ObjFW  Diff

Differences From Artifact [31589af3b0]:

To Artifact [f5b578d7a5]:

  • File src/OFZIPArchive.m — part of check-in [62e2de30b9] at 2015-02-16 08:39:17 on branch trunk — Explicitly pass errno to exceptions

    The old behaviour where the exception would access errno directly on
    creation of the exception was very fragile. The two main problems with
    it were that sometimes it would pick up an errno even though none had
    been set and in other cases that when the exception was created errno
    had already been overridden.

    This also greatly increases errno handling on Win32, especially in
    conjunction with sockets. It can still be improved further, though. (user: js, size: 13472) [annotate] [blame] [check-ins using]


11
12
13
14
15
16
17


18
19
20
21
22
23
24
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"



#import "OFZIPArchive.h"
#import "OFZIPArchiveEntry.h"
#import "OFZIPArchiveEntry+Private.h"
#import "OFDataArray.h"
#import "OFArray.h"
#import "OFDictionary.h"







>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <errno.h>

#import "OFZIPArchive.h"
#import "OFZIPArchiveEntry.h"
#import "OFZIPArchiveEntry+Private.h"
#import "OFDataArray.h"
#import "OFArray.h"
#import "OFDictionary.h"
317
318
319
320
321
322
323
324
325
326
327
328

329
330
331
332
333
334
335
{
	OFStream *ret;
	void *pool = objc_autoreleasePoolPush();
	OFZIPArchiveEntry *entry = [_pathToEntryMap objectForKey: path];
	OFZIPArchive_LocalFileHeader *localFileHeader;
	uint64_t offset64;

	if (entry == nil) {
		errno = ENOENT;
		@throw [OFOpenFileFailedException exceptionWithPath: path
							       mode: @"rb"];
	}


	offset64 = [entry OF_localFileHeaderOffset];
	if ((of_offset_t)offset64 != offset64)
		@throw [OFOutOfRangeException exception];

	[_file seekToOffset: (of_offset_t)offset64
		     whence: SEEK_SET];







|
<

|
<
>







319
320
321
322
323
324
325
326

327
328

329
330
331
332
333
334
335
336
{
	OFStream *ret;
	void *pool = objc_autoreleasePoolPush();
	OFZIPArchiveEntry *entry = [_pathToEntryMap objectForKey: path];
	OFZIPArchive_LocalFileHeader *localFileHeader;
	uint64_t offset64;

	if (entry == nil)

		@throw [OFOpenFileFailedException exceptionWithPath: path
							       mode: @"rb"

							      errNo: ENOENT];

	offset64 = [entry OF_localFileHeaderOffset];
	if ((of_offset_t)offset64 != offset64)
		@throw [OFOutOfRangeException exception];

	[_file seekToOffset: (of_offset_t)offset64
		     whence: SEEK_SET];