mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +00:00
(-isWriteable): New method.
(-initWithCoder): Renamed and rewritten from +newWithCoder. (-isAtEof): Renamed from -streamEof. (-initWithFilePointer:fmode:): Use new mode ivar. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@367 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6a7ac0eb7e
commit
d596d043fc
1 changed files with 26 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
||||||
/* Implementation of GNU Objective C stdio stream
|
/* Implementation of GNU Objective C stdio stream
|
||||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||||
Date: July 1994
|
Date: July 1994
|
||||||
|
@ -26,6 +26,12 @@
|
||||||
#include <objects/Coder.h>
|
#include <objects/Coder.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
STREAM_READONLY = 0,
|
||||||
|
STREAM_READWRITE,
|
||||||
|
STREAM_WRITEONLY
|
||||||
|
};
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
objects_vscanf (void *stream,
|
objects_vscanf (void *stream,
|
||||||
int (*inchar_func)(void*),
|
int (*inchar_func)(void*),
|
||||||
|
@ -63,25 +69,25 @@ objects_vscanf (void *stream,
|
||||||
|
|
||||||
- initWithFilePointer: (FILE*)afp fmode: (const char *)mo
|
- initWithFilePointer: (FILE*)afp fmode: (const char *)mo
|
||||||
{
|
{
|
||||||
int m;
|
|
||||||
#if 0
|
#if 0
|
||||||
/* xxx Is this portable? I don't think so.
|
/* xxx Is this portable? I don't think so.
|
||||||
How do I find out if a FILE* is open for reading/writing? */
|
How do I find out if a FILE* is open for reading/writing?
|
||||||
|
I want to get rid of the "mode" instance variable. */
|
||||||
if (afp->_flag & _IOREAD)
|
if (afp->_flag & _IOREAD)
|
||||||
m = STREAM_READONLY;
|
mode = STREAM_READONLY;
|
||||||
else if (afp->_flag & _IOWRT)
|
else if (afp->_flag & _IOWRT)
|
||||||
m = STREAM_WRITEONLY;
|
mode = STREAM_WRITEONLY;
|
||||||
else
|
else
|
||||||
m = STREAM_READWRITE;
|
mode = STREAM_READWRITE;
|
||||||
#else
|
#else
|
||||||
if (!strcmp(mo, "rw"))
|
if (!strcmp(mo, "rw"))
|
||||||
m = STREAM_READWRITE;
|
mode = STREAM_READWRITE;
|
||||||
else if (*mo == 'r')
|
else if (*mo == 'r')
|
||||||
m = STREAM_READONLY;
|
mode = STREAM_READONLY;
|
||||||
else if (*mo == 'w')
|
else if (*mo == 'w')
|
||||||
m = STREAM_WRITEONLY;
|
mode = STREAM_WRITEONLY;
|
||||||
#endif
|
#endif
|
||||||
[super initWithMode:m];
|
[super init];
|
||||||
fp = afp;
|
fp = afp;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +198,7 @@ stdio_unchar_func(void *s, int c)
|
||||||
return ftell(fp);
|
return ftell(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) streamEof
|
- (BOOL) isAtEof
|
||||||
{
|
{
|
||||||
if (feof(fp))
|
if (feof(fp))
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -200,6 +206,14 @@ stdio_unchar_func(void *s, int c)
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) isWritable
|
||||||
|
{
|
||||||
|
if (mode)
|
||||||
|
return YES;
|
||||||
|
else
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -211,7 +225,7 @@ stdio_unchar_func(void *s, int c)
|
||||||
[self notImplemented:_cmd];
|
[self notImplemented:_cmd];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ newWithCoder: (Coder*)aDecoder
|
- initWithCoder: (Coder*)aDecoder
|
||||||
{
|
{
|
||||||
[self notImplemented:_cmd];
|
[self notImplemented:_cmd];
|
||||||
return self;
|
return self;
|
||||||
|
|
Loading…
Reference in a new issue