([StdioStream -writeBytes:length:]): Check for error condition, and

report.  Reporting scheme needs fixing.
([StdioStream -readBytes:length:]): Likewise.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1353 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1996-04-12 21:11:11 +00:00
parent 2332831d4f
commit 82098fd24f

View file

@ -24,6 +24,7 @@
#include <objects/stdobjects.h> #include <objects/stdobjects.h>
#include <objects/StdioStream.h> #include <objects/StdioStream.h>
#include <objects/Coder.h> #include <objects/Coder.h>
#include <Foundation/NSException.h>
#include <stdarg.h> #include <stdarg.h>
/* xxx I should test return values of all functions on the FILE*. */ /* xxx I should test return values of all functions on the FILE*. */
@ -134,12 +135,27 @@ objects_vscanf (void *stream,
- (int) writeBytes: (const void*)b length: (int)len - (int) writeBytes: (const void*)b length: (int)len
{ {
return fwrite(b, 1, len, fp); /* xxx Check error conditions. */
int ret = fwrite (b, 1, len, fp);
if (ret != len)
printf ("Write bytes differ.\n");
assert (ret == len);
return ret;
} }
- (int) readBytes: (void*)b length: (int)len - (int) readBytes: (void*)b length: (int)len
{ {
return fread(b, 1, len, fp); /* xxx Check error conditions. */
int ret = fread (b, 1, len, fp);
if (ret != len)
{
printf ("Read bytes differ.\n");
if (feof (fp))
[NSException raise: NSGenericException
format: @"Tried to read from eof"];
}
assert (ret == len);
return ret;
} }
- (int) writeFormat: (id <String>)format, ... - (int) writeFormat: (id <String>)format, ...