'fopen' successfully opens directories

John W. Eaton jwe at bevo.che.wisc.edu
Thu Apr 24 01:36:33 CDT 2008


On 23-Apr-2008, Sergei Steshenko wrote:

| 
| --- "John W. Eaton" <jwe at bevo.che.wisc.edu> wrote:
| 
| > On 23-Apr-2008, Sergei Steshenko wrote:
| > 
| > | Which file implements 'fopen' in 'octave' ? And which function(s) in it ?
| > 
| > Look in src/file-io.cc.  Make the change in do_stream_open function.
| > Take advantage of the file_stat class from liboctave.
| > 
| > jwe
| > 
| 
| Please find a patch attached, it was produced using this command:
| 
| diff -Naur octave-3.0.1/src/file-io.cc.original octave-3.0.1/src/file-io.cc >
| warning_on_fopen_on_dir.patch
| .
| 
| With the patch 'fopen' works this way:
| 
| "
| octave:1> fid = fopen("/tmp", "r")
| warning: fopen: '/tmp' file to be opened is actually a directory, most likely the returned FID
| will be useless
| fid =  3
| ".

Instead of a warning, maybe it would be better to just be compatible
with the other brand and return -1?

jwe


More information about the Bug-octave mailing list