'fopen' successfully opens directories

Sergei Steshenko sergstesh at yahoo.com
Thu Apr 24 01:41:51 CDT 2008


--- "John W. Eaton" <jwe at bevo.che.wisc.edu> wrote:

> 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
> 

Wasn't it you who said the behavior was legal ?

I think that 'fopen' allowing directory as its input is a historical UNIX nuisance, but since 
it's deeply entrenched, I was afraid to radically change the behavior.

...

What about 'matlab' compatibility ? I do not have 'matlab' to try.

If 'matlab' allows directory as 'fopen' input, we probably don't have a choice.

Thanks,
  Sergei.

Applications From Scratch: http://appsfromscratch.berlios.de/


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


More information about the Bug-octave mailing list