@@ -20,11 +20,13 @@ #include #include #import "OFDataArray.h" #import "OFString.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" @@ -75,14 +77,16 @@ { return [[[self alloc] initWithItemSize: itemSize capacity: capacity] autorelease]; } +#ifdef OF_HAVE_FILES + (instancetype)dataArrayWithContentsOfFile: (OFString*)path { return [[[self alloc] initWithContentsOfFile: path] autorelease]; } +#endif + (instancetype)dataArrayWithContentsOfURL: (OFURL*)URL { return [[[self alloc] initWithContentsOfURL: URL] autorelease]; } @@ -144,10 +148,11 @@ } return self; } +#ifdef OF_HAVE_FILES - initWithContentsOfFile: (OFString*)path { @try { OFFile *file = [[OFFile alloc] initWithPath: path mode: @"rb"]; @@ -181,10 +186,11 @@ @throw e; } return self; } +#endif - initWithContentsOfURL: (OFURL*)URL { void *pool; #ifdef OF_HAVE_SOCKETS @@ -200,13 +206,17 @@ [self release]; pool = objc_autoreleasePoolPush(); if ([[URL scheme] isEqual: @"file"]) { +#ifdef OF_HAVE_FILES self = [[c alloc] initWithContentsOfFile: [URL path]]; objc_autoreleasePoolPop(pool); return self; +#else + @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; +#endif } #ifdef OF_HAVE_SOCKETS client = [OFHTTPClient client]; request = [OFHTTPRequest requestWithURL: URL]; @@ -597,10 +607,11 @@ - (OFString*)stringByBase64Encoding { return of_base64_encode(_items, _count * _itemSize); } +#ifdef OF_HAVE_FILES - (void)writeToFile: (OFString*)path { OFFile *file = [[OFFile alloc] initWithPath: path mode: @"wb"]; @@ -609,10 +620,11 @@ length: _count * _itemSize]; } @finally { [file release]; } } +#endif - (OFXMLElement*)XMLElementBySerializing { void *pool; OFXMLElement *element;