Merged latest from CMake branche.

Fixed an error on very small files (< 4 bytes) that was only occuring on sol. Updated CMake configuration file.
This commit is contained in:
Ward Fisher 2013-05-01 23:55:24 +00:00
parent 19c1c11f1d
commit 2d0dbcfa1d
2 changed files with 32 additions and 8 deletions

View File

@ -382,12 +382,21 @@ IF (USE_HDF5 OR ENABLE_NETCDF_4)
SET(USE_HDF5 ON)
SET(USE_NETCDF4 ON)
IF(MSVC)
FIND_PACKAGE(HDF5 COMPONENTS C HL NO_MODULE REQUIRED)
ELSE()
FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED)
ENDIF()
# Accomodate developers who have hdf5 libraries and
# headers on their system, but do not have a the hdf
# .cmake files. If this is the case, they should
# specify HDF5_HL_LIB, HDF5_LIB, HDF5_INCLUDE_DIR manually.
IF(HDF5_LIB AND HDF5_HL_LIB AND HDF5_INCLUDE_DIR)
SET(HDF5_LIBRARIES ${HDF5_LIB} ${HDF5_HL_LIB})
SET(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR})
ELSE()
IF(MSVC)
FIND_PACKAGE(HDF5 COMPONENTS C HL NO_MODULE )
ELSE()
FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED)
ENDIF()
ENDIF()
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIRS})
#Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip.
@ -407,7 +416,6 @@ ENDIF()
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
ENDIF ()
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
# Option to Build DAP Client
OPTION (ENABLE_DAP "Enable DAP Client." ON)

View File

@ -119,15 +119,31 @@ NC_check_file_type(const char *path, int use_parallel, void *mpi_info,
{
FILE *fp;
int i;
#ifdef HAVE_SYS_STAT_H
struct stat st;
#endif
if(path == NULL || strlen(path)==0)
return NC_EINVAL;
if (!(fp = fopen(path, "r")))
return errno;
#ifdef HAVE_SYS_STAT_H
/* The file must be at least MAGIC_NUMBER_LEN in size,
or otherwise the following fread will exhibit unexpected
behavior. */
if(!(fstat(fileno(fp),&st) == 0))
return errno;
if(st.st_size < MAGIC_NUMBER_LEN)
return NC_ENOTNC;
#endif
i = fread(magic, MAGIC_NUMBER_LEN, 1, fp);
fclose(fp);
if(i == 0 && errno == 22) //if file size < 4, Windows fread returns 0, errno 22.
if(i == 0)
return NC_ENOTNC;
if(i != 1)
return errno;