Overview
Comment: | -[initWithContentsOfURL:]: Use OFURLHandler |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
99cb9ac6f993f09320fcaca29d229645 |
User & Date: | js on 2018-01-03 00:42:15 |
Other Links: | manifest | tags |
Context
2018-01-03
| ||
19:49 | Update copyright notice check-in: 7e5c81e186 user: js tags: trunk | |
00:42 | -[initWithContentsOfURL:]: Use OFURLHandler check-in: 99cb9ac6f9 user: js tags: trunk | |
2017-12-30
| ||
19:12 | OFFileManager: Don't use OF_KINDOF check-in: f71d8c57e2 user: js tags: trunk | |
Changes
Modified src/OFData.h from [507fa08959] to [f36923fc9a].
︙ | ︙ | |||
239 240 241 242 243 244 245 | * * @param path The path of the file * @return An initialized OFData */ - (instancetype)initWithContentsOfFile: (OFString *)path; #endif | < < | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | * * @param path The path of the file * @return An initialized OFData */ - (instancetype)initWithContentsOfFile: (OFString *)path; #endif /*! * @brief Initializes an already allocated OFData with an item size of 1, * containing the data of the specified URL. * * @param URL The URL to the contents for the OFData * @return A new autoreleased OFData */ - (instancetype)initWithContentsOfURL: (OFURL *)URL; /*! * @brief Initializes an already allocated OFData with an item size of 1, * containing the data of the string representation. * * @param string The string representation of the data * @return A new autoreleased OFData |
︙ | ︙ |
Modified src/OFData.m from [d98f273881] to [9c40edc919].
︙ | ︙ | |||
18 19 20 21 22 23 24 | #include <stdlib.h> #include <string.h> #include <limits.h> #import "OFData.h" #import "OFData+Private.h" | | | | | | > > | 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 | #include <stdlib.h> #include <string.h> #include <limits.h> #import "OFData.h" #import "OFData+Private.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFile.h" # import "OFFileManager.h" #endif #import "OFStream.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFURL.h" #import "OFURLHandler.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerReplyException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" |
︙ | ︙ | |||
229 230 231 232 233 234 235 | @throw e; } return self; } #endif | < < | > | > > > > > > | > > | < > | | > > > | | | > > > > > > > > > > < | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | @throw e; } return self; } #endif - (instancetype)initWithContentsOfURL: (OFURL *)URL { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFURLHandler *URLHandler; OFStream *stream; size_t pageSize; unsigned char *buffer; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; _itemSize = 1; _count = 0; pageSize = [OFSystemInfo pageSize]; buffer = [self allocMemoryWithSize: pageSize]; while (![stream isAtEndOfStream]) { size_t length = [stream readIntoBuffer: buffer length: pageSize]; if (SIZE_MAX - _count < length) @throw [OFOutOfRangeException exception]; _items = [self resizeMemory: _items size: _count + length]; memcpy(_items + _count, buffer, length); _count += length; } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithStringRepresentation: (OFString *)string { self = [super init]; @try { size_t count = [string |
︙ | ︙ |
Modified src/OFString.h from [21356c9437] to [584a9bb4f0].
︙ | ︙ | |||
823 824 825 826 827 828 829 | * @param encoding The encoding of the file * @return An initialized OFString */ - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (of_string_encoding_t)encoding; #endif | < | 823 824 825 826 827 828 829 830 831 832 833 834 835 836 | * @param encoding The encoding of the file * @return An initialized OFString */ - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (of_string_encoding_t)encoding; #endif /*! * @brief Initializes an already allocated OFString with the contents of the * specified URL. * * If the URL's scheme is file, it tries UTF-8 encoding. * * If the URL's scheme is http(s), it tries to detect the encoding from the HTTP |
︙ | ︙ | |||
849 850 851 852 853 854 855 | * * @param URL The URL to the contents for the string * @param encoding The encoding to assume * @return An initialized OFString */ - (instancetype)initWithContentsOfURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding; | < | 848 849 850 851 852 853 854 855 856 857 858 859 860 861 | * * @param URL The URL to the contents for the string * @param encoding The encoding to assume * @return An initialized OFString */ - (instancetype)initWithContentsOfURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding; /*! * @brief Writes the OFString into the specified C string with the specified * encoding. * * @param cString The C string to write into * @param maxLength The maximum number of bytes to write into the C string, |
︙ | ︙ |
Modified src/OFString.m from [6c49aac468] to [b724e2f129].
︙ | ︙ | |||
1060 1061 1062 1063 1064 1065 1066 | length: (size_t)fileSize]; [self freeMemory: tmp]; return self; } #endif | < > < | < < < < | < | < | < > > > > < | 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | length: (size_t)fileSize]; [self freeMemory: tmp]; return self; } #endif - (instancetype)initWithContentsOfURL: (OFURL *)URL { return [self initWithContentsOfURL: URL encoding: OF_STRING_ENCODING_AUTODETECT]; } - (instancetype)initWithContentsOfURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding { @try { void *pool = objc_autoreleasePoolPush(); OFData *data = [OFData dataWithContentsOfURL: URL]; self = [self initWithCString: [data items] encoding: encoding length: [data count]]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithSerialization: (OFXMLElement *)element { @try { void *pool = objc_autoreleasePoolPush(); if (![[element namespace] isEqual: OF_SERIALIZATION_NS]) |
︙ | ︙ |