Overview
Comment: | Add of-tar: URI handler |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
4f56311b577a02c87109d64b63164e36 |
User & Date: | js on 2022-10-04 21:49:33 |
Other Links: | manifest | tags |
Context
2022-10-04
| ||
22:12 | Add of-gzip: URI handler check-in: 2481bede45 user: js tags: trunk | |
21:49 | Add of-tar: URI handler check-in: 4f56311b57 user: js tags: trunk | |
21:33 | Add +[OFZIPArchive URIForFile:inArchive:] check-in: 19bbbbd95d user: js tags: trunk | |
Changes
Modified src/Makefile from [b0447ea34a] to [d59b367af0].
︙ | ︙ | |||
200 201 202 203 204 205 206 207 208 209 210 211 212 213 | OFRangeCharacterSet.m \ 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 | > | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | OFRangeCharacterSet.m \ OFRangeValue.m \ OFRectValue.m \ OFSandbox.m \ OFSizeValue.m \ OFStrPTime.m \ OFSubarray.m \ OFTarURIHandler.m \ OFUTF8String.m \ OFZIPURIHandler.m \ ${LIBBASES_M} \ ${RUNTIME_AUTORELEASE_M} \ ${RUNTIME_INSTANCE_M} \ ${UNICODE_M} SRCS_FILES += OFFileURIHandler.m |
︙ | ︙ |
Modified src/OFTarArchive.h from [8804d5e5f3] to [748cfc3b0d].
︙ | ︙ | |||
75 76 77 78 79 80 81 82 83 84 85 86 87 88 | * @param mode The mode for the tar file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFTarArchive */ + (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFTarArchive object with the * specified stream. * * @param stream A stream from which the tar archive will be read. | > > > > > > > > > > > | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | * @param mode The mode for the tar file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFTarArchive */ + (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode; /** * @brief Creates a URI for accessing a the specified file within the specified * tar archive. * * @param path The path of the file within the archive * @param archive The URI of the archive * @return A URI for accessing the specified file within the specified Tar * archive */ + (OFURI *)URIForFile: (OFString *)path inArchive: (OFURI *)archive; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFTarArchive object with the * specified stream. * * @param stream A stream from which the tar archive will be read. |
︙ | ︙ |
Modified src/OFTarArchive.m from [859f5b3b09] to [0dbf94ce58].
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #import "OFTarArchive.h" #import "OFTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" #import "OFDate.h" #import "OFSeekableStream.h" #import "OFStream.h" #import "OFURIHandler.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" | > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #import "OFTarArchive.h" #import "OFTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" #import "OFDate.h" #import "OFSeekableStream.h" #import "OFStream.h" #import "OFURI.h" #import "OFURIHandler.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" |
︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } + (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode { return [[[self alloc] initWithURI: URI mode: mode] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode | > > > > > > > > > > > > > > > > > > > > > > > > | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } + (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode { return [[[self alloc] initWithURI: URI mode: mode] autorelease]; } + (OFURI *)URIForFile: (OFString *)path inArchive: (OFURI *)archive { OFMutableURI *URI = [OFMutableURI URI]; void *pool = objc_autoreleasePoolPush(); OFCharacterSet *characterSet = [OFCharacterSet of_URIPathAllowedCharacterSetWithoutExclamationMark]; OFString *archiveURI; path = [path stringByAddingPercentEncodingWithAllowedCharacters: characterSet]; archiveURI = [archive.string stringByAddingPercentEncodingWithAllowedCharacters: characterSet]; URI.scheme = @"of-tar"; URI.percentEncodedPath = [OFString stringWithFormat: @"%@!%@", archiveURI, path]; [URI makeImmutable]; objc_autoreleasePoolPop(pool); return URI; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode |
︙ | ︙ |
Added src/OFTarURIHandler.h version [7411ddfdf4].
> > > > > > > > > > > > > > > > > > > > > > > | 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 OFTarURIHandler: OFURIHandler @end OF_ASSUME_NONNULL_END |
Added src/OFTarURIHandler.m version [b5232b0f3e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 63 64 65 66 67 68 69 70 71 72 | /* * 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" #include <errno.h> #import "OFTarURIHandler.h" #import "OFTarArchive.h" #import "OFURI.h" #import "OFInvalidArgumentException.h" #import "OFOpenItemFailedException.h" @implementation OFTarURIHandler - (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode { OFString *percentEncodedPath, *archiveURI, *path; size_t pos; OFTarArchive *archive; OFTarArchiveEntry *entry; if (![URI.scheme isEqual: @"of-tar"] || 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 = [OFTarArchive archiveWithURI: [OFURI URIWithString: archiveURI] mode: @"r"]; while ((entry = [archive nextEntry]) != nil) if ([entry.fileName isEqual: path]) return [archive streamForReadingCurrentEntry]; @throw [OFOpenItemFailedException exceptionWithURI: URI mode: mode errNo: ENOENT]; } @end |
Modified src/OFURIHandler.m from [d4501677af] to [98204d10fd].
︙ | ︙ | |||
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 "OFZIPURIHandler.h" #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 "OFTarURIHandler.h" #import "OFZIPURIHandler.h" #import "OFUnsupportedProtocolException.h" static OFMutableDictionary OF_GENERIC(OFString *, OFURIHandler *) *handlers; #ifdef OF_HAVE_THREADS static OFMutex *mutex; |
︙ | ︙ | |||
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | #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]; | > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #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: [OFTarURIHandler class] forScheme: @"of-tar"]; [self registerClass: [OFZIPURIHandler class] forScheme: @"of-zip"]; } + (bool)registerClass: (Class)class forScheme: (OFString *)scheme { #ifdef OF_HAVE_THREADS [mutex lock]; |
︙ | ︙ |