PR# 2681 Problem with preconditions of read_character, read_integer, etc in FILE.

Problem Report Summary
Submitter: gabutler
Category: EiffelBase
Priority: Low
Date: 2000/10/10
Class: Bug
Severity: Non-critical
Number: 2681
Release: 4.5.020
Confidential: No
Status: Open
Responsible:
Environment: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)
Synopsis: Problem with preconditions of read_character, read_integer, etc in FILE.

Description
There seems to be a problem with the preconditions of the read_character, 
read_integer, etc features in FILE. The problem occurs when you inadvertently 
attempt to read a file that has been opened only for writing. You would expect 
the precondition to detect the error, but it doesn't. Instead, it fails 
later with an I/O error.

Possible solution: In FILE, rename 'readable' from IO_MEDIUM as 'file_readable', then remove the 'require else' clauses from 'read_x' features.

See attached file for more detailed description.
To Reproduce
	make is
		local
			f: PLAIN_TEXT_FILE
		do
			create f.make_open_write ("f.txt")
			f.put_string ("abc")
			f.read_character
			io.put_character (f.last_character)
		end
Problem Report Interactions
From:gabutler    Date:2000/10/10    Download   
From: "Gerry Butler" <gbutler@dstc.monash.edu.au>
To: <bugs@support.eiffel.com>
Cc:  Subject: RE: EiffelBase/2681
Date: Wed, 11 Oct 2000 09:34:51 +1000

 This is a multi-part message in MIME format.
 
 ------=_NextPart_000_0000_01C03366.81324510
 Content-Type: text/plain;
 	charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit
 
 Good morning
 
 I think I forgot to include the attachment with my original bug report.
 
 Here it is.
 
 Gerry
 
 
 
 
 
 
 ------=_NextPart_000_0000_01C03366.81324510
 Content-Type: text/plain;
 	name="read_x_precondition.txt"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
 	filename="read_x_precondition.txt"
 
 There seems to be a problem with the preconditions of the =
 read_character,=20
 read_integer, etc features in FILE. The problem occurs when you =
 inadvertently=20
 attempt to read a file that has been opened only for writing. You would =
 expect=20
 the precondition to detect the error, but it doesn't. Instead, it fails=20
 later with an I/
....
Output truncated, Click download to get the full message