mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-01 17:06:03 +08:00
Detect attribute creation order tracking setting
When opening an existing file for NC_WRITE access, check whether the file was created originally with attribute creation order tracking disabled and if so, use that setting for subsequent attribute creation. Also check the `mode` passed in to the open call in case application is explicitly disabling the attribute creation order tracking with the NC_NOATTRCREORD flag.
This commit is contained in:
parent
a611f19b32
commit
3ce6df07ba
@ -756,6 +756,10 @@ nc4_open_file(const char *path, int mode, void* parameters, int ncid)
|
||||
if ((mode & NC_WRITE) == 0)
|
||||
nc4_info->no_write = NC_TRUE;
|
||||
|
||||
if ((mode & NC_WRITE) && (mode & NC_NOATTCREORD)) {
|
||||
nc4_info->no_attr_create_order = NC_TRUE;
|
||||
}
|
||||
|
||||
if(nc4_info->mem.inmemory && nc4_info->mem.diskless)
|
||||
BAIL(NC_EINTERNAL);
|
||||
|
||||
@ -900,6 +904,19 @@ nc4_open_file(const char *path, int mode, void* parameters, int ncid)
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
|
||||
/* Get the file creation property list to check for attribute ordering */
|
||||
{
|
||||
hid_t pid;
|
||||
unsigned int crt_order_flags;
|
||||
if ((pid = H5Fget_create_plist(h5->hdfid)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (H5Pget_attr_creation_order(pid, &crt_order_flags) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (!(crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
|
||||
nc4_info->no_attr_create_order = NC_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now read in all the metadata. Some types and dimscale
|
||||
* information may be difficult to resolve here, if, for example, a
|
||||
* dataset of user-defined type is encountered before the
|
||||
|
Loading…
Reference in New Issue
Block a user