ObjFW  Diff

Differences From Artifact [ac757b6022]:

To Artifact [ed7da6bb04]:


20
21
22
23
24
25
26

27
28
29

30
31
32
33
34
35
36
#import "OFZIPArchive.h"

#import "OFInvalidArgumentException.h"

@implementation OFZIPURIHandler
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
{

	OFString *percentEncodedPath, *archiveURI, *path;
	size_t pos;
	OFZIPArchive *archive;


	if (![URI.scheme isEqual: @"of-zip"] || URI.host != nil ||
	    URI.port != nil || URI.user != nil || URI.password != nil ||
	    URI.query != nil || URI.fragment != nil)
		@throw [OFInvalidArgumentException exception];

	if (![mode isEqual: @"r"])







>



>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#import "OFZIPArchive.h"

#import "OFInvalidArgumentException.h"

@implementation OFZIPURIHandler
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
{
	void *pool = objc_autoreleasePoolPush();
	OFString *percentEncodedPath, *archiveURI, *path;
	size_t pos;
	OFZIPArchive *archive;
	OFStream *stream;

	if (![URI.scheme isEqual: @"of-zip"] || URI.host != nil ||
	    URI.port != nil || URI.user != nil || URI.password != nil ||
	    URI.query != nil || URI.fragment != nil)
		@throw [OFInvalidArgumentException exception];

	if (![mode isEqual: @"r"])
52
53
54
55
56
57
58

59

60

61


62
	path = [percentEncodedPath substringWithRange:
	    OFMakeRange(pos + 1, percentEncodedPath.length - pos - 1)]
	    .stringByRemovingPercentEncoding;

	archive = [OFZIPArchive
	    archiveWithURI: [OFURI URIWithString: archiveURI]
		      mode: @"r"];



	return [archive streamForReadingFile: path];

}


@end







>

>
|
>
|
>
>

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
	path = [percentEncodedPath substringWithRange:
	    OFMakeRange(pos + 1, percentEncodedPath.length - pos - 1)]
	    .stringByRemovingPercentEncoding;

	archive = [OFZIPArchive
	    archiveWithURI: [OFURI URIWithString: archiveURI]
		      mode: @"r"];
	stream = [archive streamForReadingFile: path];

	[stream retain];

	objc_autoreleasePoolPop(pool);

	return [stream autorelease];
}
@end