@@ -41,10 +41,15 @@ + dataArrayWithContentsOfFile: (OFString*)path { return [[[self alloc] initWithContentsOfFile: path] autorelease]; } + ++ dataArrayWithBase64EncodedString: (OFString*)str +{ + return [[[self alloc] initWithBase64EncodedString: str] autorelease]; +} - init { Class c = isa; [self release]; @@ -59,12 +64,12 @@ @try { if (is == 0) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; - data = NULL; itemSize = is; + data = NULL; } @catch (id e) { [self release]; @throw e; } @@ -76,11 +81,13 @@ self = [super init]; @try { OFFile *file = [[OFFile alloc] initWithPath: path mode: @"rb"]; + itemSize = 1; + data = NULL; @try { char *buf = [self allocMemoryWithSize: of_pagesize]; while (![file isAtEndOfStream]) { @@ -98,10 +105,26 @@ } } @catch (id e) { [self release]; @throw e; } + + return self; +} + +- initWithBase64EncodedString: (OFString*)str +{ + self = [super init]; + + itemSize = 1; + data = NULL; + + if (!of_base64_decode(self, [str cString], [str cStringLength])) { + Class c = isa; + [self release]; + @throw [OFInvalidEncodingException newWithClass: c]; + } return self; } - (size_t)count