adding, and starting to use nc4_file_list_add()

This commit is contained in:
edwardhartnett 2019-08-02 09:14:35 -06:00
parent ad086e23d6
commit 181f260a20
3 changed files with 40 additions and 2 deletions

View File

@ -334,6 +334,8 @@ int nc4_get_typeclass(const NC_FILE_INFO_T *h5, nc_type xtype,
int nc4_type_free(NC_TYPE_INFO_T *type);
/* These list functions add and delete vars, atts. */
int nc4_file_list_add(int ncid, const char *path, int mode,
void **dispatchdata);
int nc4_nc4f_list_add(NC *nc, const char *path, int mode);
int nc4_nc4f_list_del(NC_FILE_INFO_T *h5);
int nc4_var_list_add(NC_GRP_INFO_T* grp, const char* name, int ndims,

View File

@ -629,9 +629,11 @@ NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
return NC_EHDFERR;
/* Add necessary structs to hold netcdf-4 file data. */
if ((retval = nc4_nc4f_list_add(nc, path, mode)))
/* if ((retval = nc4_nc4f_list_add(nc, path, mode))) */
/* return retval; */
/* h5 = (NC_FILE_INFO_T *)nc->dispatchdata; */
if ((retval = nc4_file_list_add(ncid, path, mode, &h5)))
return retval;
h5 = (NC_FILE_INFO_T *)nc->dispatchdata;
assert(h5 && h5->root_grp);
h5->no_write = NC_TRUE;
h5->root_grp->atts_read = 1;

View File

@ -82,6 +82,40 @@ nc4_check_name(const char *name, char *norm_name)
return NC_NOERR;
}
/**
* @internal Add a file to the list of libsrc4 open files. This is
* used by dispatch layers that wish to use the libsrc4 metadata
* model, but don't know about struct NC. This is the same as
* nc4_nc4f_list_add(), except it takes an ncid instead of an NC *.
*
* @param ncid The ncid of the file (aka ext_ncid).
* @param path The file name of the new file.
* @param mode The mode flag.
*
* @return ::NC_NOERR No error.
* @return ::NC_EBADID No NC struct with this ext_ncid.
* @return ::NC_ENOMEM Out of memory.
* @author Ed Hartnett
*/
int
nc4_file_list_add(int ncid, const char *path, int mode, void **dispatchdata)
{
NC *nc;
int ret;
/* Find NC pointer for this file. */
if ((ret = NC_check_id(ncid, &nc)))
return ret;
/* Add necessary structs to hold netcdf-4 file data. */
if ((ret = nc4_nc4f_list_add(nc, path, mode)))
return ret;
*dispatchdata = nc->dispatchdata;
return NC_NOERR;
}
/**
* @internal Given an NC pointer, add the necessary stuff for a
* netcdf-4 file.