June 23, 2008 [Issue 2163] New: successfully reading doesn't necessarily mean not EOF in the stream | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2163 Summary: successfully reading doesn't necessarily mean not EOF in the stream Product: D Version: 1.030 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: bugzilla@digitalmars.com ReportedBy: davidl@126.com // read from source size_t readBlock(void* buffer, size_t size) { size_t res = s.readBlock(buffer,size); readEOF = res == 0; return res; } readEOF = res == 0; <-- this should perform real test on the stream to see if real EOF reached. other wise, stream.eof become something useless. I need to catch ReadException. and the following coding pattern is not working with the current implementation: while (stream.eof) { stream.read(mydchar); // if last time exactly read all data from the stream. it will throw ReadException } -- |
Copyright © 1999-2021 by the D Language Foundation