Overview
Comment: | Add of-zip: URI handler |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
bcff1dfd70c5e7d94e3228eed6e375c8 |
User & Date: | js on 2022-10-04 20:50:41 |
Other Links: | manifest | tags |
Context
2022-10-04
| ||
21:33 | Add +[OFZIPArchive URIForFile:inArchive:] check-in: 19bbbbd95d user: js tags: trunk | |
20:50 | Add of-zip: URI handler check-in: bcff1dfd70 user: js tags: trunk | |
2022-10-03
| ||
22:18 | A few minor documentation fixes check-in: 694da470d4 user: js tags: trunk | |
Changes
Modified src/Makefile from [d4fba39890] to [b0447ea34a].
︙ | ︙ | |||
201 202 203 204 205 206 207 208 209 210 211 212 213 214 | OFRangeValue.m \ OFRectValue.m \ OFSandbox.m \ OFSizeValue.m \ OFStrPTime.m \ OFSubarray.m \ OFUTF8String.m \ ${LIBBASES_M} \ ${RUNTIME_AUTORELEASE_M} \ ${RUNTIME_INSTANCE_M} \ ${UNICODE_M} SRCS_FILES += OFFileURIHandler.m SRCS_SOCKETS += OFDNSResolverSettings.m \ ${OF_EPOLL_KERNEL_EVENT_OBSERVER_M} \ | > | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | OFRangeValue.m \ OFRectValue.m \ OFSandbox.m \ OFSizeValue.m \ OFStrPTime.m \ OFSubarray.m \ OFUTF8String.m \ OFZIPURIHandler.m \ ${LIBBASES_M} \ ${RUNTIME_AUTORELEASE_M} \ ${RUNTIME_INSTANCE_M} \ ${UNICODE_M} SRCS_FILES += OFFileURIHandler.m SRCS_SOCKETS += OFDNSResolverSettings.m \ ${OF_EPOLL_KERNEL_EVENT_OBSERVER_M} \ |
︙ | ︙ |
Modified src/OFURIHandler.m from [b12ed659e0] to [d4501677af].
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #import "OFEmbeddedURIHandler.h" #ifdef OF_HAVE_FILES # import "OFFileURIHandler.h" #endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS) # import "OFHTTPURIHandler.h" #endif #import "OFUnsupportedProtocolException.h" static OFMutableDictionary OF_GENERIC(OFString *, OFURIHandler *) *handlers; #ifdef OF_HAVE_THREADS static OFMutex *mutex; | > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #import "OFEmbeddedURIHandler.h" #ifdef OF_HAVE_FILES # import "OFFileURIHandler.h" #endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS) # import "OFHTTPURIHandler.h" #endif #import "OFZIPURIHandler.h" #import "OFUnsupportedProtocolException.h" static OFMutableDictionary OF_GENERIC(OFString *, OFURIHandler *) *handlers; #ifdef OF_HAVE_THREADS static OFMutex *mutex; |
︙ | ︙ | |||
64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #ifdef OF_HAVE_FILES [self registerClass: [OFFileURIHandler class] forScheme: @"file"]; #endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS) [self registerClass: [OFHTTPURIHandler class] forScheme: @"http"]; [self registerClass: [OFHTTPURIHandler class] forScheme: @"https"]; #endif } + (bool)registerClass: (Class)class forScheme: (OFString *)scheme { #ifdef OF_HAVE_THREADS [mutex lock]; @try { | > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #ifdef OF_HAVE_FILES [self registerClass: [OFFileURIHandler class] forScheme: @"file"]; #endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS) [self registerClass: [OFHTTPURIHandler class] forScheme: @"http"]; [self registerClass: [OFHTTPURIHandler class] forScheme: @"https"]; #endif [self registerClass: [OFZIPURIHandler class] forScheme: @"of-zip"]; } + (bool)registerClass: (Class)class forScheme: (OFString *)scheme { #ifdef OF_HAVE_THREADS [mutex lock]; @try { |
︙ | ︙ |
Added src/OFZIPURIHandler.h version [0359782d45].
> > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /* * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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. */ #import "OFURIHandler.h" OF_ASSUME_NONNULL_BEGIN @interface OFZIPURIHandler: OFURIHandler @end OF_ASSUME_NONNULL_END |
Added src/OFZIPURIHandler.m version [ac757b6022].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | /* * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFZIPURIHandler.h" #import "OFURI.h" #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"]) /* * Writing has some implications that are not decided yet: Will * it always append to an archive? What happens if the file * already exists? */ @throw [OFInvalidArgumentException exception]; percentEncodedPath = URI.percentEncodedPath; pos = [percentEncodedPath rangeOfString: @"!"].location; if (pos == OFNotFound) @throw [OFInvalidArgumentException exception]; archiveURI = [percentEncodedPath substringWithRange: OFMakeRange(0, pos)].stringByRemovingPercentEncoding; path = [percentEncodedPath substringWithRange: OFMakeRange(pos + 1, percentEncodedPath.length - pos - 1)] .stringByRemovingPercentEncoding; archive = [OFZIPArchive archiveWithURI: [OFURI URIWithString: archiveURI] mode: @"r"]; return [archive streamForReadingFile: path]; } @end |