Changeset 3342

Show
Ignore:
Timestamp:
11/12/09 16:25:37 (4 months ago)
Author:
kraftche
Message:

try to avoid HDF5 library writing junk to stdout/stderr for non-existent files

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • MOAB/trunk/ReadHDF5.cpp

    r3272 r3342  
    6262#define READ_HDF5_BUFFER_SIZE (40*1024*1024) 
    6363 
     64#if !defined(WIN32) && !defined(WIN64) 
     65# include <sys/stat.h> 
     66# include <unistd.h> 
     67# include <errno.h> 
     68#endif 
     69 
    6470// This function doesn't do anything useful.  It's just a nice 
    6571// place to set a break point to determine why the reader fails. 
     
    258264  } 
    259265  else { 
     266   
     267      // first check if file exists, so we can fail w/out 
     268      // a lot of noise from the HDF5 library if it does not 
     269#if !defined(WIN32) && !defined(WIN64) 
     270    struct stat junk; 
     271    if (stat( filename, &junk)) { 
     272      if (ENOENT == errno) 
     273        return MB_FILE_DOES_NOT_EXIST; 
     274      else 
     275        return MB_FILE_WRITE_ERROR; 
     276    } 
     277    else if (S_ISDIR(junk.st_mode)) 
     278      return MB_FILE_DOES_NOT_EXIST; 
     279#endif 
     280   
    260281      // Open the file 
    261282    filePtr = mhdf_openFile( filename, 0, NULL, &status );