mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
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:
parent
19c1c11f1d
commit
2d0dbcfa1d
@ -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)
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user