@@ -25,11 +25,13 @@ #import "OFString.h" #import "OFString_UTF8.h" #import "OFString_UTF8+Private.h" #import "OFArray.h" #import "OFDictionary.h" -#import "OFFile.h" +#ifdef OF_HAVE_FILES +# import "OFFile.h" +#endif #import "OFURL.h" #ifdef OF_HAVE_SOCKETS # import "OFHTTPClient.h" # import "OFHTTPRequest.h" # import "OFHTTPResponse.h" @@ -409,10 +411,11 @@ { return (id)[[OFString_UTF8 alloc] initWithFormat: format arguments: arguments]; } +#ifdef OF_HAVE_FILES - initWithContentsOfFile: (OFString*)path { return (id)[[OFString_UTF8 alloc] initWithContentsOfFile: path]; } @@ -420,10 +423,11 @@ encoding: (of_string_encoding_t)encoding { return (id)[[OFString_UTF8 alloc] initWithContentsOfFile: path encoding: encoding]; } +#endif - initWithContentsOfURL: (OFURL*)URL { return (id)[[OFString_UTF8 alloc] initWithContentsOfURL: URL]; } @@ -599,10 +603,11 @@ va_end(arguments); return ret; } +#ifdef OF_HAVE_FILES + (instancetype)stringWithContentsOfFile: (OFString*)path { return [[[self alloc] initWithContentsOfFile: path] autorelease]; } @@ -610,10 +615,11 @@ encoding: (of_string_encoding_t)encoding { return [[[self alloc] initWithContentsOfFile: path encoding: encoding] autorelease]; } +#endif + (instancetype)stringWithContentsOfURL: (OFURL*)URL { return [[[self alloc] initWithContentsOfURL: URL] autorelease]; } @@ -784,10 +790,11 @@ arguments: (va_list)arguments { OF_INVALID_INIT_METHOD } +#ifdef OF_HAVE_FILES - initWithContentsOfFile: (OFString*)path { return [self initWithContentsOfFile: path encoding: OF_STRING_ENCODING_UTF_8]; } @@ -831,10 +838,11 @@ length: (size_t)st.st_size]; [self freeMemory: tmp]; return self; } +#endif - initWithContentsOfURL: (OFURL*)URL { return [self initWithContentsOfURL: URL encoding: OF_STRING_ENCODING_AUTODETECT]; @@ -858,17 +866,21 @@ [self release]; pool = objc_autoreleasePoolPush(); if ([[URL scheme] isEqual: @"file"]) { +#ifdef OF_HAVE_FILES if (encoding == OF_STRING_ENCODING_AUTODETECT) encoding = OF_STRING_ENCODING_UTF_8; self = [[c alloc] initWithContentsOfFile: [URL path] encoding: encoding]; objc_autoreleasePoolPop(pool); return self; +#else + @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; +#endif } #ifdef OF_HAVE_SOCKETS client = [OFHTTPClient client]; request = [OFHTTPRequest requestWithURL: URL]; @@ -2423,10 +2435,11 @@ } return ret; } +#ifdef OF_HAVE_FILES - (void)writeToFile: (OFString*)path { return [self writeToFile: path encoding: OF_STRING_ENCODING_UTF_8]; } @@ -2442,10 +2455,11 @@ [file writeString: self encoding: encoding]; objc_autoreleasePoolPop(pool); } +#endif #ifdef OF_HAVE_BLOCKS - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block { void *pool = objc_autoreleasePoolPush();