From 82098fd24f9cf1e901f9466bcae101cf46a563cc Mon Sep 17 00:00:00 2001 From: mccallum Date: Fri, 12 Apr 1996 21:11:11 +0000 Subject: [PATCH] ([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 --- Source/StdioStream.m | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Source/StdioStream.m b/Source/StdioStream.m index 522bf1ac8..6cde1dc8a 100644 --- a/Source/StdioStream.m +++ b/Source/StdioStream.m @@ -24,6 +24,7 @@ #include #include #include +#include #include /* 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 { - 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 { - 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 )format, ...