Overview
Comment: | Add +[OFZIPArchive URIForFile:inArchive:]
This allows constructing a URI to access a file within an archive. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
19bbbbd95d138fb1961d60324482f571 |
User & Date: | js on 2022-10-04 21:33:53 |
Other Links: | manifest | tags |
Context
2022-10-04
| ||
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 | |
20:50 | Add of-zip: URI handler check-in: bcff1dfd70 user: js tags: trunk | |
Changes
Modified src/OFURI.h from [63067c2093] to [0e7faecce0].
︙ | ︙ | |||
371 372 373 374 375 376 377 378 379 380 381 382 383 384 | /** * @brief Returns the characters allowed in the fragment part of a URI. * * @return The characters allowed in the fragment part of a URI. */ + (OFCharacterSet *)URIFragmentAllowedCharacterSet; @end #ifdef __cplusplus extern "C" { #endif extern bool OFURIIsIPv6Host(OFString *host); extern void OFURIVerifyIsEscaped(OFString *, OFCharacterSet *); | > > | 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | /** * @brief Returns the characters allowed in the fragment part of a URI. * * @return The characters allowed in the fragment part of a URI. */ + (OFCharacterSet *)URIFragmentAllowedCharacterSet; + (OFCharacterSet *)of_URIPathAllowedCharacterSetWithoutExclamationMark; @end #ifdef __cplusplus extern "C" { #endif extern bool OFURIIsIPv6Host(OFString *host); extern void OFURIVerifyIsEscaped(OFString *, OFCharacterSet *); |
︙ | ︙ |
Modified src/OFURI.m from [f265de725c] to [a82a35d7aa].
︙ | ︙ | |||
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | @end @interface OFURIQueryOrFragmentAllowedCharacterSet: OFURIAllowedCharacterSetBase @end @interface OFURIQueryKeyValueAllowedCharacterSet: OFURIAllowedCharacterSetBase @end static OFCharacterSet *URIAllowedCharacterSet = nil; static OFCharacterSet *URISchemeAllowedCharacterSet = nil; static OFCharacterSet *URIPathAllowedCharacterSet = nil; static OFCharacterSet *URIQueryOrFragmentAllowedCharacterSet = nil; static OFCharacterSet *URIQueryKeyValueAllowedCharacterSet = nil; static OFOnceControl URIAllowedCharacterSetOnce = OFOnceControlInitValue; static OFOnceControl URIQueryOrFragmentAllowedCharacterSetOnce = OFOnceControlInitValue; static void initURIAllowedCharacterSet(void) | > > > > > > > > > > > > > > > > > > > | 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | @end @interface OFURIQueryOrFragmentAllowedCharacterSet: OFURIAllowedCharacterSetBase @end @interface OFURIQueryKeyValueAllowedCharacterSet: OFURIAllowedCharacterSetBase @end @interface OFURIPathAllowedCharacterSetWithoutExclamationMark: OFURIPathAllowedCharacterSet { OFCharacterSet *_characterSet; bool (*_characterIsMember)(id, SEL, OFUnichar); } @end OF_DIRECT_MEMBERS @interface OFInvertedCharacterSetWithoutPercent: OFCharacterSet { OFCharacterSet *_characterSet; bool (*_characterIsMember)(id, SEL, OFUnichar); } - (instancetype)initWithCharacterSet: (OFCharacterSet *)characterSet; @end static OFCharacterSet *URIAllowedCharacterSet = nil; static OFCharacterSet *URISchemeAllowedCharacterSet = nil; static OFCharacterSet *URIPathAllowedCharacterSet = nil; static OFCharacterSet *URIQueryOrFragmentAllowedCharacterSet = nil; static OFCharacterSet *URIQueryKeyValueAllowedCharacterSet = nil; static OFCharacterSet *URIPathAllowedCharacterSetWithoutExclamationMark = nil; static OFOnceControl URIAllowedCharacterSetOnce = OFOnceControlInitValue; static OFOnceControl URIQueryOrFragmentAllowedCharacterSetOnce = OFOnceControlInitValue; static void initURIAllowedCharacterSet(void) |
︙ | ︙ | |||
93 94 95 96 97 98 99 | static void initURIQueryKeyValueAllowedCharacterSet(void) { URIQueryKeyValueAllowedCharacterSet = [[OFURIQueryKeyValueAllowedCharacterSet alloc] init]; } | < > | | | < < < | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | static void initURIQueryKeyValueAllowedCharacterSet(void) { URIQueryKeyValueAllowedCharacterSet = [[OFURIQueryKeyValueAllowedCharacterSet alloc] init]; } static void initURIPathAllowedCharacterSetWithoutExclamationMark(void) { URIPathAllowedCharacterSetWithoutExclamationMark = [[OFURIPathAllowedCharacterSetWithoutExclamationMark alloc] init]; } bool OFURIIsIPv6Host(OFString *host) { const char *UTF8String = host.UTF8String; bool hasColon = false; |
︙ | ︙ | |||
286 287 288 289 290 291 292 293 294 295 296 297 298 299 | case '?': return true; default: return false; } } @end @implementation OFInvertedCharacterSetWithoutPercent - (instancetype)initWithCharacterSet: (OFCharacterSet *)characterSet { self = [super init]; @try { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | case '?': return true; default: return false; } } @end @implementation OFURIPathAllowedCharacterSetWithoutExclamationMark - (instancetype)init { self = [super init]; @try { _characterSet = [[OFCharacterSet URIPathAllowedCharacterSet] retain]; _characterIsMember = (bool (*)(id, SEL, OFUnichar)) [_characterSet methodForSelector: @selector(characterIsMember:)]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_characterSet release]; [super dealloc]; } - (bool)characterIsMember: (OFUnichar)character { return (character != '!' && _characterIsMember(_characterSet, @selector(characterIsMember:), character)); } @end @implementation OFInvertedCharacterSetWithoutPercent - (instancetype)initWithCharacterSet: (OFCharacterSet *)characterSet { self = [super init]; @try { |
︙ | ︙ | |||
394 395 396 397 398 399 400 401 402 403 404 405 406 407 | + (OFCharacterSet *)URIFragmentAllowedCharacterSet { OFOnce(&URIQueryOrFragmentAllowedCharacterSetOnce, initURIQueryOrFragmentAllowedCharacterSet); return URIQueryOrFragmentAllowedCharacterSet; } @end @implementation OFURI + (instancetype)URI { return [[[self alloc] init] autorelease]; } | > > > > > > > > > | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | + (OFCharacterSet *)URIFragmentAllowedCharacterSet { OFOnce(&URIQueryOrFragmentAllowedCharacterSetOnce, initURIQueryOrFragmentAllowedCharacterSet); return URIQueryOrFragmentAllowedCharacterSet; } + (OFCharacterSet *)of_URIPathAllowedCharacterSetWithoutExclamationMark { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, initURIPathAllowedCharacterSetWithoutExclamationMark); return URIPathAllowedCharacterSetWithoutExclamationMark; } @end @implementation OFURI + (instancetype)URI { return [[[self alloc] init] autorelease]; } |
︙ | ︙ |
Modified src/OFZIPArchive.h from [56eecfe29a] to [e88e9d721e].
︙ | ︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | * @param mode The mode for the ZIP 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 OFZIPArchive */ + (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFZIPArchive object with the * specified stream. * * @param stream A stream from which the ZIP archive will be read. | > > > > > > > > > > > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | * @param mode The mode for the ZIP 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 OFZIPArchive */ + (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode; /** * @brief Creates a URI for accessing a the specified file within the specified * ZIP 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 ZIP * archive */ + (OFURI *)URIForFile: (OFString *)path inArchive: (OFURI *)archive; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFZIPArchive object with the * specified stream. * * @param stream A stream from which the ZIP archive will be read. |
︙ | ︙ |
Modified src/OFZIPArchive.m from [161538a2bd] to [d0b4f286d3].
︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #import "OFCRC32.h" #import "OFData.h" #import "OFDictionary.h" #import "OFInflate64Stream.h" #import "OFInflateStream.h" #import "OFSeekableStream.h" #import "OFStream.h" #import "OFURIHandler.h" #import "OFChecksumMismatchException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" | > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #import "OFCRC32.h" #import "OFData.h" #import "OFDictionary.h" #import "OFInflate64Stream.h" #import "OFInflateStream.h" #import "OFSeekableStream.h" #import "OFStream.h" #import "OFURI.h" #import "OFURIHandler.h" #import "OFChecksumMismatchException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" |
︙ | ︙ | |||
162 163 164 165 166 167 168 169 170 171 172 173 174 175 | 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 | > > > > > > > > > > > > > > > > > > > > > > > > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | 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-zip"; 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 |
︙ | ︙ |