Overview
Context
Changes
Modified src/OFData.h
from [507fa08959]
to [f36923fc9a].
︙ | | |
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
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
#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS)
/*!
* @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;
#endif
/*!
* @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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
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 "OFString.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFURL.h"
#import "OFDictionary.h"
#import "OFXMLElement.h"
#import "OFSystemInfo.h"
#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
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
|
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
#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS)
- (instancetype)initWithContentsOfURL: (OFURL *)URL
{
void *pool;
OFString *scheme;
self = [super init];
@try {
pool = objc_autoreleasePoolPush();
void *pool = objc_autoreleasePoolPush();
OFURLHandler *URLHandler;
OFStream *stream;
size_t pageSize;
unsigned char *buffer;
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException
scheme = [URL scheme];
exceptionWithURL: URL];
_itemSize = 1;
_count = 0;
# ifdef OF_HAVE_FILES
if ([scheme isEqual: @"file"])
self = [self initWithContentsOfFile:
[URL fileSystemRepresentation]];
else
# endif
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
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);
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
#endif
- (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
830
831
832
833
834
835
836
837
|
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
#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS)
/*!
* @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
856
857
858
859
860
861
862
863
|
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;
#endif
/*!
* @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
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
1099
1100
1101
1102
1103
|
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
#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS)
- (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();
void *pool = objc_autoreleasePoolPush();
OFString *scheme = [URL scheme];
OFData *data = [OFData dataWithContentsOfURL: URL];
# ifdef OF_HAVE_FILES
if ([scheme isEqual: @"file"]) {
if (encoding == OF_STRING_ENCODING_AUTODETECT)
encoding = OF_STRING_ENCODING_UTF_8;
self = [self
self = [self initWithCString: [data items]
initWithContentsOfFile: [URL fileSystemRepresentation]
encoding: encoding];
encoding: encoding
} else
# endif
length: [data count]];
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
objc_autoreleasePoolPop(pool);
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
#endif
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
@try {
void *pool = objc_autoreleasePoolPush();
if (![[element namespace] isEqual: OF_SERIALIZATION_NS])
|
︙ | | |