'fopen' successfully opens directories

John W. Eaton jwe at bevo.che.wisc.edu
Wed Apr 23 10:50:28 CDT 2008


On 23-Apr-2008, Sergei Steshenko wrote:

| Hello,
| 
| please see this:
| 
| "
| GNU Octave, version 3.0.1b
| [snip]
| octave:1> fid = fopen("/tmp", "r")
| fid =  3
| octave:2> fread(fid, inf, "double")
| ans = [](0x1)
| "
| 
| - I would expect failure, i.e. negative 'fid', from 'fopen' in such a case.

What does the following C program do on your system?

  #include <errno.h>
  #include <stdio.h>

  int
  main (void)
  {
    FILE *fid = fopen ("/tmp", "r");

    if (fid)
      printf ("OK\n");

    printf ("errno: %d\n", errno);

    return 0;
  }


I'm not convinced that Octave should do anything different from this.

jwe


More information about the Bug-octave mailing list