@@ -78,15 +78,20 @@ } - initWithPath: (const char*)path andMode: (const char*)mode { + Class c; + if ((self = [super init])) { - if ((fp = fopen(path, mode)) == NULL) - @throw [OFOpenFileFailedException newWithObject: self - andPath: path - andMode: mode]; + if ((fp = fopen(path, mode)) == NULL) { + c = [self class]; + [super free]; + @throw [OFOpenFileFailedException newWithClass: c + andPath: path + andMode: mode]; + } } return self; } - free @@ -106,13 +111,13 @@ intoBuffer: (uint8_t*)buf { size_t ret; if ((ret = fread(buf, size, nitems, fp)) == 0 && !feof(fp)) - @throw [OFReadFailedException newWithObject: self - andSize: size - andNItems: nitems]; + @throw [OFReadFailedException newWithClass: [self class] + andSize: size + andNItems: nitems]; return ret; } - (size_t)readNBytes: (size_t)size @@ -155,13 +160,13 @@ { size_t ret; if ((ret = fwrite(buf, size, nitems, fp)) == 0 && size != 0 && nitems != 0) - @throw [OFWriteFailedException newWithObject: self - andSize: size - andNItems: nitems]; + @throw [OFWriteFailedException newWithClass: [self class] + andSize: size + andNItems: nitems]; return ret; } - (size_t)writeNBytes: (size_t)size