30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
@implementation OFFile
+ fileWithPath: (OFString*)path
mode: (OFString*)mode
{
return [[[self alloc] initWithPath: path
mode: mode] autorelease];
}
+ standardInput
{
if (of_file_stdin == nil)
of_file_stdin = [[OFFileSingleton alloc]
initWithFilePointer: stdin];
|
>
>
>
>
>
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
@implementation OFFile
+ fileWithPath: (OFString*)path
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]
initWithFilePointer: stdin];
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
if ((fp = fopen([path cString], [mode cString])) == NULL) {
c = isa;
[super dealloc];
@throw [OFOpenFileFailedException newWithClass: c
path: path
mode: mode];
}
return self;
}
- (void)dealloc
{
if (fp != NULL)
fclose(fp);
[super dealloc];
}
- (BOOL)atEndOfStream
{
|
>
>
>
>
>
>
>
>
>
>
>
|
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
if ((fp = fopen([path cString], [mode cString])) == NULL) {
c = isa;
[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 (close == YES && fp != NULL)
fclose(fp);
[super dealloc];
}
- (BOOL)atEndOfStream
{
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
fp = NULL;
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];
}
|
<
<
<
<
<
<
<
<
<
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
fp = NULL;
return self;
}
@end
@implementation OFFileSingleton
- initWithPath: (OFString*)path
mode: (OFString*)mode
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
}
|