changeset 4799:e2d7d1ef5e55

[project @ 2004-02-24 19:47:18 by jwe]
author jwe
date Tue, 24 Feb 2004 19:47:18 +0000
parents da0d1c453971
children c322edde72ac
files src/ChangeLog src/file-io.cc src/oct-stream.h
diffstat 3 files changed, 19 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Feb 24 17:30:05 2004 +0000
+++ b/src/ChangeLog	Tue Feb 24 19:47:18 2004 +0000
@@ -1,7 +1,10 @@
 2004-02-24  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* file-io.cc (do_stream_open): Don't call ::error if stream can't
-	be created.  Don't call ::fopen if arch is invalid.	
+	be created.  Don't call ::fopen if arch is invalid.  Set error
+	state for stream if fopen fails.
+	* oct-stream.h (octave_stream::error (const char *)): New function.
+	(octave_stream::error (const std::string&)): Now public.
 
 2004-02-23  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
--- a/src/file-io.cc	Tue Feb 24 17:30:05 2004 +0000
+++ b/src/file-io.cc	Tue Feb 24 19:47:18 2004 +0000
@@ -342,15 +342,12 @@
 	{
 	  FILE *fptr = ::fopen (name.c_str (), mode.c_str ());
 
-	  if (fptr)
-	    {
-	      retval = octave_stdiostream::create (name, fptr, md, flt_fmt);
+	  retval = octave_stdiostream::create (name, fptr, md, flt_fmt);
 
-	      // XXX FIXME XXX -- it would now be possible for the
-	      // file id returned by fopen to correspond directly to
-	      // the underlying system file id (::fileno (fptr)).
-	      // Doing that would require some changes to the
-	      // octave_stream_list class.
+	  if (! fptr)
+	    {
+	      using namespace std;
+	      retval.error (::strerror (errno));
 	    }
 	}
     }
--- a/src/oct-stream.h	Tue Feb 24 17:30:05 2004 +0000
+++ b/src/oct-stream.h	Tue Feb 24 19:47:18 2004 +0000
@@ -542,6 +542,16 @@
       return error (clear, err_num);
     }
 
+  // Set the error message and state.
+
+  void error (const std::string& msg)
+    {
+      if (rep)
+	rep->error (msg);
+    }
+
+  void error (const char *msg) { error (std::string (msg)); }
+
   int file_number (void) { return rep ? rep->file_number () : -1; }
 
   bool is_valid (void) const { return (rep != 0); }
@@ -586,12 +596,6 @@
 
       return retval;
     }
-
-  void error (const std::string& msg)
-    {
-      if (rep)
-	rep->error (msg);
-    }
 };
 
 class