@@ -32,10 +32,15 @@ mode: (OFString*)mode { return [[[self alloc] initWithPath: path mode: mode] autorelease]; } + ++ fileWithFilePointer: (FILE*)fp_ +{ + return [[[self alloc] initWithFilePointer: fp_] autorelease]; +} + standardInput { if (of_file_stdin == nil) of_file_stdin = [[OFFileSingleton alloc] @@ -139,17 +144,28 @@ [super dealloc]; @throw [OFOpenFileFailedException newWithClass: c path: path mode: mode]; } + + close = YES; + + return self; +} + +- initWithFilePointer: (FILE*)fp_ +{ + self = [super init]; + + fp = fp_; return self; } - (void)dealloc { - if (fp != NULL) + if (close == YES && fp != NULL) fclose(fp); [super dealloc]; } @@ -224,19 +240,10 @@ return self; } @end @implementation OFFileSingleton -- initWithFilePointer: (FILE*)fp_ -{ - self = [super init]; - - fp = fp_; - - return self; -} - - initWithPath: (OFString*)path mode: (OFString*)mode { @throw [OFNotImplementedException newWithClass: isa selector: _cmd];