Index: src/OFDataArray.h ================================================================== --- src/OFDataArray.h +++ src/OFDataArray.h @@ -90,18 +90,20 @@ * @return A new autoreleased OFDataArray */ + (instancetype)dataArrayWithContentsOfFile: (OFString*)path; #endif +#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) /*! * @brief Creates a new OFDataArray with an item size of 1, containing the data * of the specified URL. * * @param URL The URL to the contents for the OFDataArray * @return A new autoreleased OFDataArray */ + (instancetype)dataArrayWithContentsOfURL: (OFURL*)URL; +#endif /*! * @brief Creates a new OFDataArray with an item size of 1, containing the data * of the string representation. * @@ -158,18 +160,20 @@ * @return An initialized OFDataArray */ - initWithContentsOfFile: (OFString*)path; #endif +#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) /*! * @brief Initializes an already allocated OFDataArray with an item size of 1, * containing the data of the specified URL. * * @param URL The URL to the contents for the OFDataArray * @return A new autoreleased OFDataArray */ - initWithContentsOfURL: (OFURL*)URL; +#endif /*! * @brief Initializes an already allocated OFDataArray with an item size of 1, * containing the data of the string representation. * Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -82,14 +82,16 @@ { return [[[self alloc] initWithContentsOfFile: path] autorelease]; } #endif +#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) + (instancetype)dataArrayWithContentsOfURL: (OFURL*)URL { return [[[self alloc] initWithContentsOfURL: URL] autorelease]; } +#endif + (instancetype)dataArrayWithStringRepresentation: (OFString*)string { return [[[self alloc] initWithStringRepresentation: string] autorelease]; @@ -184,25 +186,26 @@ return self; } #endif +#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) - initWithContentsOfURL: (OFURL*)URL { void *pool; OFString *scheme; pool = objc_autoreleasePoolPush(); scheme = [URL scheme]; -#ifdef OF_HAVE_FILES +# ifdef OF_HAVE_FILES if ([scheme isEqual: @"file"]) self = [self initWithContentsOfFile: [URL path]]; else -#endif -#ifdef OF_HAVE_SOCKETS +# endif +# ifdef OF_HAVE_SOCKETS if ([scheme isEqual: @"http"] || [scheme isEqual: @"https"]) { self = [self init]; @try { OFHTTPClient *client = [OFHTTPClient client]; @@ -247,17 +250,18 @@ } @catch (id e) { [self release]; @throw e; } } else -#endif +# endif @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; objc_autoreleasePoolPop(pool); return self; } +#endif - initWithStringRepresentation: (OFString*)string { @try { const char *cString; Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -291,10 +291,11 @@ */ + (instancetype)stringWithContentsOfFile: (OFString*)path encoding: (of_string_encoding_t)encoding; #endif +#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) /*! * @brief Creates a new OFString with the contents of the specified URL. * * If the URL's scheme is file, it tries UTF-8 encoding. * @@ -315,10 +316,11 @@ * @param encoding The encoding to assume * @return A new autoreleased OFString */ + (instancetype)stringWithContentsOfURL: (OFURL*)URL encoding: (of_string_encoding_t)encoding; +#endif /*! * @brief Creates a path from the specified path components. * * @param components An array of components for the path @@ -535,10 +537,11 @@ */ - 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. @@ -560,10 +563,11 @@ * @param encoding The encoding to assume * @return An initialized OFString */ - initWithContentsOfURL: (OFURL*)URL encoding: (of_string_encoding_t)encoding; +#endif /*! * @brief Writes the OFString into the specified C string with the specified * encoding. * Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -443,10 +443,11 @@ return (id)[[OFString_UTF8 alloc] initWithContentsOfFile: path encoding: encoding]; } #endif +#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) - initWithContentsOfURL: (OFURL*)URL { return (id)[[OFString_UTF8 alloc] initWithContentsOfURL: URL]; } @@ -454,10 +455,11 @@ encoding: (of_string_encoding_t)encoding { return (id)[[OFString_UTF8 alloc] initWithContentsOfURL: URL encoding: encoding]; } +#endif - initWithSerialization: (OFXMLElement*)element { return (id)[[OFString_UTF8 alloc] initWithSerialization: element]; } @@ -635,10 +637,11 @@ return [[[self alloc] initWithContentsOfFile: path encoding: encoding] autorelease]; } #endif +#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) + (instancetype)stringWithContentsOfURL: (OFURL*)URL { return [[[self alloc] initWithContentsOfURL: URL] autorelease]; } @@ -646,10 +649,11 @@ encoding: (of_string_encoding_t)encoding { return [[[self alloc] initWithContentsOfURL: URL encoding: encoding] autorelease]; } +#endif + (OFString*)pathWithComponents: (OFArray*)components { OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); @@ -861,10 +865,11 @@ return self; } #endif +#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) - initWithContentsOfURL: (OFURL*)URL { return [self initWithContentsOfURL: URL encoding: OF_STRING_ENCODING_AUTODETECT]; } @@ -872,30 +877,30 @@ - initWithContentsOfURL: (OFURL*)URL encoding: (of_string_encoding_t)encoding { void *pool; OFString *scheme; -#ifdef OF_HAVE_FILES +# ifdef OF_HAVE_FILES Class c = [self class]; -#endif +# endif [self release]; pool = objc_autoreleasePoolPush(); scheme = [URL scheme]; -#ifdef OF_HAVE_FILES +# ifdef OF_HAVE_FILES if ([scheme isEqual: @"file"]) { if (encoding == OF_STRING_ENCODING_AUTODETECT) encoding = OF_STRING_ENCODING_UTF_8; self = [[c alloc] initWithContentsOfFile: [URL path] encoding: encoding]; } else -#endif -#ifdef OF_HAVE_SOCKETS +# endif +# ifdef OF_HAVE_SOCKETS if ([scheme isEqual: @"http"] || [scheme isEqual: @"https"]) { OFHTTPClient *client = [OFHTTPClient client]; OFHTTPRequest *request = [OFHTTPRequest requestWithURL: URL]; OFHTTPResponse *response = [client performRequest: request]; OFDictionary *headers; @@ -937,17 +942,18 @@ self = [[c alloc] initWithCString: (char*)[data items] encoding: encoding length: [data count]]; } else -#endif +# endif @throw [OFUnsupportedProtocolException exception]; objc_autoreleasePoolPop(pool); return self; } +#endif - initWithSerialization: (OFXMLElement*)element { @try { void *pool = objc_autoreleasePoolPush();