[Developers] Bug fix for bug 1864 on all platforms.

smadiraju at cct.lsu.edu smadiraju at cct.lsu.edu
Thu Jun 23 09:17:23 CDT 2005


Hi all,

The bug fix I sent in my last mail will work on all platforms with the following
modification. The IS_DIR macro is replaced with a test for a bit which is set
when the file is a directory.

For this to work the sys/stat.h must be included as shown below.

#include <sys/stat.h>

// This is the extra code that needs to be added.
  else
  {
    struct stat *buf;
    stat(ConfigData->parameter_file_name,buf);

    if(buf->st_mode & 0040000)
    {
      parameter_file = NULL;
      CCTK_VWarn (0, __LINE__, __FILE__, "Cactus",
                "Cannot open parameter file '%s', it is a directory",
                   ConfigData->parameter_file_name);
    }
    else
    {
      parameter_file = fopen (ConfigData->parameter_file_name, "r");
    }
  }

We query the st_mode parameter set by the stat command. We can test if this
parameter is pointing to a directory by doing a "bitwise and" with 0040000
which is the value of S_IFDIR. This constant is also present in Windows but it
is called _S_IFDIR. This patch will work on windows as the value of _S_IFDIR is
also 0040000. This is same on all the platforms only the name of the constant is
different. For example, the same constant is called S_IFDIR in Linux but it has
the same value as above.

Please test it and apply.

Regards
Sasanka Madiraju.






More information about the Developers mailing list