# HG changeset patch # User jwe # Date 1077652038 0 # Node ID e2d7d1ef5e5556d0073dfbe46a44757ab7756271 # Parent da0d1c453971a75900d007d29a26bf299f16ed18 [project @ 2004-02-24 19:47:18 by jwe] diff -r da0d1c453971 -r e2d7d1ef5e55 src/ChangeLog --- 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 * 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 diff -r da0d1c453971 -r e2d7d1ef5e55 src/file-io.cc --- 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)); } } } diff -r da0d1c453971 -r e2d7d1ef5e55 src/oct-stream.h --- 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