OSDN Git Service

2007-08-14 Pascal Obry <obry@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Aug 2007 08:49:36 +0000 (08:49 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Aug 2007 08:49:36 +0000 (08:49 +0000)
* s-fileio.adb (Is_Open): Add check for usability of the underlying
file stream.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127461 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/s-fileio.adb

index 3ae5d3d..5607e70 100644 (file)
@@ -610,7 +610,13 @@ package body System.File_IO is
 
    function Is_Open (File : AFCB_Ptr) return Boolean is
    begin
-      return (File /= null);
+      --  We return True if the file is open, and the underlying file stream is
+      --  usable. In particular on Windows an application linked with -mwindows
+      --  option set does not have a console attached. In this case standard
+      --  files (Current_Output, Current_Error, Current_Input) are not created.
+      --  We want Is_Open (Current_Output) to return False in this case.
+
+      return File /= null and then fileno (File.Stream) /= -1;
    end Is_Open;
 
    -------------------