summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-04-11 16:22:16 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-04-11 16:22:16 (GMT)
commit9d2070890b0cfb2c8a406906da0470e948141db4 (patch)
tree567cc6f6c36d67c78be5e79b3529d30bcbe06a50
parent78158e8dbffcbf025257a72bb42c1fbe8c7660b7 (diff)
downloadhdf5-9d2070890b0cfb2c8a406906da0470e948141db4.zip
hdf5-9d2070890b0cfb2c8a406906da0470e948141db4.tar.gz
hdf5-9d2070890b0cfb2c8a406906da0470e948141db4.tar.bz2
[svn-r13636] Description:
Change H5[D|G|T]<foo>_expand() "temporary" API routines to H5[D|G|T]<foo>2() "versioned" routines. Also added H5[D|G|T](create|commit)_anon() routines to continue to allow "anonymous" objects to be created in a file. Tested on: Mac OS X/32 10.4.9 (amazon) FreeBSD/32 6.2 (duty) FreeBSD/64 6.2 (liberty) Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
-rw-r--r--MANIFEST3
-rw-r--r--examples/h5_extlink.c10
-rw-r--r--release_docs/RELEASE.txt2
-rw-r--r--src/H5D.c294
-rw-r--r--src/H5Ddeprec.c256
-rw-r--r--src/H5Doh.c74
-rw-r--r--src/H5Dpkg.h16
-rw-r--r--src/H5Dpublic.h20
-rw-r--r--src/H5G.c538
-rw-r--r--src/H5Gdeprec.c167
-rw-r--r--src/H5Gint.c200
-rw-r--r--src/H5Goh.c67
-rw-r--r--src/H5Gpkg.h31
-rw-r--r--src/H5Gprivate.h2
-rw-r--r--src/H5Gpublic.h10
-rw-r--r--src/H5Gtraverse.c39
-rw-r--r--src/H5L.c157
-rw-r--r--src/H5Lexternal.c6
-rw-r--r--src/H5Lpkg.h2
-rw-r--r--src/H5Lprivate.h10
-rw-r--r--src/H5O.c48
-rw-r--r--src/H5Opkg.h1
-rw-r--r--src/H5Oprivate.h8
-rw-r--r--src/H5Tcommit.c282
-rw-r--r--src/H5Tdeprec.c223
-rw-r--r--src/H5Toh.c62
-rw-r--r--src/H5Tpkg.h12
-rw-r--r--src/H5Tpublic.h19
-rwxr-xr-xsrc/Makefile.am8
-rw-r--r--src/Makefile.in15
-rw-r--r--test/links.c162
-rw-r--r--test/stab.c9
-rw-r--r--test/th5o.c18
-rw-r--r--test/tmisc.c111
-rw-r--r--test/unlink.c3
-rw-r--r--tools/misc/h5mkgrp.c10
-rw-r--r--tools/testfiles/h5mkgrp_nested.ls4
-rw-r--r--tools/testfiles/h5mkgrp_nested_latest.ls4
-rw-r--r--tools/testfiles/h5mkgrp_nested_mult.ls8
-rw-r--r--tools/testfiles/h5mkgrp_nested_mult_latest.ls8
40 files changed, 1845 insertions, 1074 deletions
diff --git a/MANIFEST b/MANIFEST
index 8e37cdd..4bbf5b8 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -455,6 +455,7 @@
./src/H5D.c
./src/H5Dcompact.c
./src/H5Dcontig.c
+./src/H5Ddeprec.c
./src/H5Defl.c
./src/H5Dio.c
./src/H5Distore.c
@@ -524,6 +525,7 @@
./src/H5Gdense.c
./src/H5Gdeprec.c
./src/H5Gent.c
+./src/H5Gint.c
./src/H5Glink.c
./src/H5Gloc.c
./src/H5Gname.c
@@ -671,6 +673,7 @@
./src/H5Tcompound.c
./src/H5Tconv.c
./src/H5Tcset.c
+./src/H5Tdeprec.c
./src/H5Tenum.c
./src/H5Tfields.c
./src/H5Tfixed.c
diff --git a/examples/h5_extlink.c b/examples/h5_extlink.c
index dd5a834..113d269 100644
--- a/examples/h5_extlink.c
+++ b/examples/h5_extlink.c
@@ -148,9 +148,9 @@ static void extlink_prefix_example(void)
/* Now if we traverse the external link, HDF5 will look for an external
* file named red/prefix_target.h5, which exists.
- * To pass the group access property list, we need to use H5Gopen_expand.
+ * To pass the group access property list, we need to use H5Gopen2.
*/
- group_id = H5Gopen_expand(source_file_id, "ext_link", gapl_id);
+ group_id = H5Gopen2(source_file_id, "ext_link", gapl_id);
/* Now we can use the open group ID to create a new group inside the
* "red" file.
@@ -165,7 +165,7 @@ static void extlink_prefix_example(void)
* directory.
*/
H5Pset_elink_prefix(gapl_id, "blue/");
- group_id = H5Gopen_expand(source_file_id, "ext_link", gapl_id);
+ group_id = H5Gopen2(source_file_id, "ext_link", gapl_id);
group2_id = H5Gcreate(group_id, "sky blue", (size_t) 0);
/* Close both groups. */
@@ -591,14 +591,14 @@ static void plist_link_example(void)
/* Open the first group through the plist link using the GAPL we just
* created */
- group_id = H5Gopen_expand(file_id, "plist_link", gapl_id);
+ group_id = H5Gopen2(file_id, "plist_link", gapl_id);
/* If we change the value set on the property list, it will change where
* the plist link points.
*/
path = "group_1/group_2";
H5Pset(gapl_id, PLIST_LINK_PROP, &path);
- group2_id = H5Gopen_expand(file_id, "plist_link", gapl_id);
+ group2_id = H5Gopen2(file_id, "plist_link", gapl_id);
/* group_id points to group_1 and group2_id points to group_2, both opened
* through the same link.
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 8a83b96..09533f8 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -259,7 +259,7 @@ New Features
H5Lget_val - just like H5Gget_linkval
H5Lget_info - gets link-specific info (like H5Gget_objinfo)
- In addition, H5Gcreate_expand, H5Tcommit_expand, and H5Dcreate_expand
+ In addition, H5Gcreate_anon, H5Tcommit_anon, and H5Dcreate_anon
no longer create links to objects; objects must be manually linked
using H5Llink or they will be deleted when the ID is closed.
diff --git a/src/H5D.c b/src/H5D.c
index 2ffe9e2..607f4b0 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -29,19 +29,19 @@
#include "H5private.h" /* Generic Functions */
#include "H5Dpkg.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free Lists */
#include "H5FOprivate.h" /* File objects */
#include "H5HLprivate.h" /* Local heaps */
#include "H5Iprivate.h" /* IDs */
#include "H5Lprivate.h" /* Links */
#include "H5MMprivate.h" /* Memory management */
-#include "H5Sprivate.h" /* Dataspaces */
#include "H5Vprivate.h" /* Vectors and arrays */
+
/****************/
/* Local Macros */
/****************/
+
/******************/
/* Local Typedefs */
/******************/
@@ -57,15 +57,14 @@ typedef struct {
hsize_t size; /* Accumulated number of bytes for the selection */
} H5D_vlen_bufsize_t;
+
/********************/
/* Local Prototypes */
/********************/
/* General stuff */
static herr_t H5D_init_storage(H5D_t *dataset, hbool_t full_overwrite, hid_t dxpl_id);
-static H5D_shared_t * H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type);
-static H5D_t * H5D_create(H5F_t *file, hid_t type_id,
- const H5S_t *space, hid_t dcpl_id, hid_t dxpl_id);
+static H5D_shared_t *H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type);
static herr_t H5D_open_oid(H5D_t *dataset, hid_t dxpl_id);
static herr_t H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id);
static hsize_t H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id);
@@ -76,6 +75,7 @@ static herr_t H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id);
static herr_t H5D_set_extent(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id);
static herr_t H5D_init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type);
+
/*********************/
/* Package Variables */
/*********************/
@@ -83,10 +83,12 @@ static herr_t H5D_init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const
/* Define a "default" dataset transfer property list cache structure to use for default DXPLs */
H5D_dxpl_cache_t H5D_def_dxpl_cache;
+
/*****************************/
/* Library Private Variables */
/*****************************/
+
/*******************/
/* Local Variables */
/*******************/
@@ -107,6 +109,7 @@ H5FL_BLK_EXTERN(sieve_buf);
/* Define a static "default" dataset structure to use to initialize new datasets */
static H5D_shared_t H5D_def_dset;
+
/*-------------------------------------------------------------------------
* Function: H5D_init
@@ -132,7 +135,7 @@ H5D_init(void)
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5D_init() */
/*--------------------------------------------------------------------------
@@ -253,7 +256,7 @@ H5D_term_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5Dcreate
+ * Function: H5Dcreate2
*
* Purpose: Creates a new dataset named NAME at LOC_ID, opens the
* dataset for access, and associates with that dataset constant
@@ -271,101 +274,133 @@ H5D_term_interface(void)
* point, the dataset is ready to receive its
* raw data. Attempting to read raw data from
* the dataset will probably return the fill
- * value. The dataset should be closed when
- * the caller is no longer interested in it.
+ * value. The dataset should be closed when the
+ * caller is no longer interested in it.
*
* Failure: FAIL
*
- * Programmer: Robb Matzke
- * Wednesday, December 3, 1997
+ * Programmer: Quincey Koziol
+ * Thursday, April 5, 2007
*
*-------------------------------------------------------------------------
*/
hid_t
-H5Dcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
- hid_t dcpl_id)
+H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
+ hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id)
{
- H5G_loc_t loc; /* Object location to insert dataset into */
- H5G_loc_t dset_loc; /* Object location of the dataset */
- H5G_loc_t insertion_loc; /* Loc of group in which to create object */
- H5G_name_t insert_path; /* Path of group in which to create object */
- H5O_loc_t insert_oloc; /* oloc of group in which to create object */
- hbool_t insert_loc_valid = FALSE; /* Is insertion_loc valid? */
- H5F_t* file; /* File in which dataset is being created */
- H5D_t *new_dset = NULL; /* New dataset's info */
+ H5G_loc_t loc; /* Object location to insert dataset into */
+ H5D_t *dset = NULL; /* New dataset's info */
const H5S_t *space; /* Dataspace for dataset */
- hid_t dset_id = -1; /* New dataset's id */
hid_t ret_value; /* Return value */
- FUNC_ENTER_API(H5Dcreate, FAIL)
- H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, dcpl_id);
+ FUNC_ENTER_API(H5Dcreate2, FAIL)
+ H5TRACE5("i", "iiiii", loc_id, type_id, space_id, dcpl_id, dapl_id);
/* Check arguments */
if(H5G_loc(loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
- if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
if(H5I_DATATYPE != H5I_get_type(type_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID")
- if(NULL == (space = H5I_object_verify(space_id,H5I_DATASPACE)))
+ if(NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID")
+
+ /* Get correct property list */
+ if(H5P_DEFAULT == lcpl_id)
+ lcpl_id = H5P_LINK_CREATE_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list")
+
+ /* Get correct property list */
if(H5P_DEFAULT == dcpl_id)
dcpl_id = H5P_DATASET_CREATE_DEFAULT;
else
if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID")
- /* What file is the dataset being added to? */
- insertion_loc.path = &insert_path;
- insertion_loc.oloc = &insert_oloc;
- H5G_loc_reset(&insertion_loc);
- if(H5G_insertion_loc(&loc, name, &insertion_loc, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to locate insertion point")
- insert_loc_valid=TRUE;
- file = insertion_loc.oloc->file;
+ /* Get correct property list */
+ if(H5P_DEFAULT == dapl_id)
+ dapl_id = H5P_DATASET_ACCESS_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list")
- /* build and open the new dataset */
- if(NULL == (new_dset = H5D_create(file, type_id, space, dcpl_id, H5AC_dxpl_id)))
+ /* Create the new dataset & get its ID */
+ if(NULL == (dset = H5D_create_named(&loc, name, type_id, space, lcpl_id,
+ dcpl_id, dapl_id, H5AC_dxpl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
-
- /* Register the new dataset to get an ID for it */
- if((dset_id = H5I_register(H5I_DATASET, new_dset)) < 0)
+ if((ret_value = H5I_register(H5I_DATASET, dset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset")
- if(H5G_loc(dset_id, &dset_loc) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get location for dataset")
+done:
+ if(ret_value < 0)
+ if(dset && H5D_close(dset) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
- /* Link the new dataset */
- if( H5L_link(&loc, name, &dset_loc, H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link to dataset")
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Dcreate2() */
- ret_value = dset_id;
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_create_named
+ *
+ * Purpose: Internal routine to create a new dataset.
+ *
+ * Return: Success: Non-NULL, pointer to new dataset object.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, April 5, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+H5D_t *
+H5D_create_named(const H5G_loc_t *loc, const char *name, hid_t type_id,
+ const H5S_t *space, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id,
+ hid_t dxpl_id)
+{
+ H5O_obj_create_t ocrt_info; /* Information for object creation */
+ H5D_obj_create_t dcrt_info; /* Information for dataset creation */
+ H5D_t *ret_value; /* Return value */
-done:
- if(insert_loc_valid) {
- if(H5G_loc_free(&insertion_loc) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to free location")
- }
- if(ret_value < 0) {
- if(dset_id >= 0)
- {
- H5I_dec_ref(dset_id);
- }
- else
- {
- if(new_dset != NULL) {
- if(H5D_close(new_dset) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
- } /* end if */
- } /* end if-else */
- } /* end if */
+ FUNC_ENTER_NOAPI(H5D_create_named, NULL)
- FUNC_LEAVE_API(ret_value)
-} /* end H5Dcreate() */
+ /* Check arguments */
+ HDassert(loc);
+ HDassert(name && *name);
+ HDassert(type_id != H5P_DEFAULT);
+ HDassert(space);
+ HDassert(lcpl_id != H5P_DEFAULT);
+ HDassert(dcpl_id != H5P_DEFAULT);
+ HDassert(dapl_id != H5P_DEFAULT);
+ HDassert(dxpl_id != H5P_DEFAULT);
+
+ /* Set up dataset creation info */
+ dcrt_info.type_id = type_id;
+ dcrt_info.space = space;
+ dcrt_info.dcpl_id = dcpl_id;
+
+ /* Set up object creation information */
+ ocrt_info.obj_type = H5O_TYPE_DATASET;
+ ocrt_info.crt_info = &dcrt_info;
+ ocrt_info.new_obj = NULL;
+
+ /* Create the new dataset and link it to its parent group */
+ if(H5L_link_object(loc, name, &ocrt_info, lcpl_id, dapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create and link to dataset")
+ HDassert(ocrt_info.new_obj);
+
+ /* Set the return value */
+ ret_value = ocrt_info.new_obj;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_create_named() */
/*-------------------------------------------------------------------------
- * Function: H5Dcreate_expand
+ * Function: H5Dcreate_anon
*
* Purpose: Creates a new dataset named NAME at LOC_ID, opens the
* dataset for access, and associates with that dataset constant
@@ -400,15 +435,15 @@ done:
*-------------------------------------------------------------------------
*/
hid_t
-H5Dcreate_expand(hid_t loc_id, hid_t type_id, hid_t space_id,
- hid_t dcpl_id, hid_t dapl_id)
+H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id,
+ hid_t dapl_id)
{
H5G_loc_t loc; /* Object location to insert dataset into */
- H5D_t *new_dset = NULL; /* New dataset's info */
+ H5D_t *dset = NULL; /* New dataset's info */
const H5S_t *space; /* Dataspace for dataset */
hid_t ret_value; /* Return value */
- FUNC_ENTER_API(H5Dcreate_expand, FAIL)
+ FUNC_ENTER_API(H5Dcreate_anon, FAIL)
H5TRACE5("i", "iiiii", loc_id, type_id, space_id, dcpl_id, dapl_id);
/* Check arguments */
@@ -416,7 +451,7 @@ H5Dcreate_expand(hid_t loc_id, hid_t type_id, hid_t space_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
if(H5I_DATATYPE != H5I_get_type(type_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID")
- if(NULL == (space = H5I_object_verify(space_id,H5I_DATASPACE)))
+ if(NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID")
if(H5P_DEFAULT == dcpl_id)
dcpl_id = H5P_DATASET_CREATE_DEFAULT;
@@ -432,107 +467,24 @@ H5Dcreate_expand(hid_t loc_id, hid_t type_id, hid_t space_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list")
/* build and open the new dataset */
- if(NULL == (new_dset = H5D_create(loc.oloc->file, type_id, space, dcpl_id, H5AC_dxpl_id)))
+ if(NULL == (dset = H5D_create(loc.oloc->file, type_id, space, dcpl_id, H5AC_dxpl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
/* Register the new dataset to get an ID for it */
- if((ret_value = H5I_register(H5I_DATASET, new_dset)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset")
-
-done:
- if(ret_value < 0) {
- if(new_dset != NULL) {
- if(H5D_close(new_dset) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
- } /* end if */
- } /* end if */
-
- FUNC_LEAVE_API(ret_value)
-} /* end H5Dcreate() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5Dopen
- *
- * Purpose: Finds a dataset named NAME at LOC_ID, opens it, and returns
- * its ID. The dataset should be close when the caller is no
- * longer interested in it.
- *
- * Return: Success: A new dataset ID
- *
- * Failure: FAIL
- *
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-H5Dopen(hid_t loc_id, const char *name)
-{
- H5D_t *dset = NULL;
- H5G_loc_t loc; /* Object location of group */
- H5G_loc_t dset_loc; /* Object location of dataset */
- H5G_name_t path; /* Dataset group hier. path */
- H5O_loc_t oloc; /* Dataset object location */
- H5O_type_t obj_type; /* Type of object at location */
- hbool_t loc_found = FALSE; /* Location at 'name' found */
- hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */
- hid_t ret_value;
-
- FUNC_ENTER_API(H5Dopen, FAIL)
- H5TRACE2("i", "i*s", loc_id, name);
-
- /* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
-
- /* Set up dataset location to fill in */
- dset_loc.oloc = &oloc;
- dset_loc.path = &path;
- H5G_loc_reset(&dset_loc);
-
- /* Find the dataset object */
- if(H5G_loc_find(&loc, name, &dset_loc, H5P_DEFAULT, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found")
- loc_found = TRUE;
-
- /* Check that the object found is the correct type */
- if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_DATASET)
- HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset")
-
- /* Open the dataset */
- if((dset = H5D_open(&dset_loc, dxpl_id)) == NULL)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset")
-
- /* Register an atom for the dataset */
if((ret_value = H5I_register(H5I_DATASET, dset)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset")
done:
- if(ret_value < 0) {
- if(dset != NULL) {
- if(H5D_close(dset) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
- } /* end if */
- else {
- if(loc_found) {
- if(H5G_loc_free(&dset_loc) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
- }
- } /* end else */
- } /* end if */
+ if(ret_value < 0)
+ if(dset && H5D_close(dset) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
-} /* end H5Dopen() */
+} /* end H5Dcreate_anon() */
/*-------------------------------------------------------------------------
- * Function: H5Dopen_expand
+ * Function: H5Dopen2
*
* Purpose: Finds a dataset named NAME at LOC_ID, opens it, and returns
* its ID. The dataset should be close when the caller is no
@@ -549,7 +501,7 @@ done:
*-------------------------------------------------------------------------
*/
hid_t
-H5Dopen_expand(hid_t loc_id, const char *name, hid_t dapl_id)
+H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id)
{
H5D_t *dset = NULL;
H5G_loc_t loc; /* Object location of group */
@@ -561,7 +513,7 @@ H5Dopen_expand(hid_t loc_id, const char *name, hid_t dapl_id)
hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */
hid_t ret_value;
- FUNC_ENTER_API(H5Dopen_expand, FAIL)
+ FUNC_ENTER_API(H5Dopen2, FAIL)
H5TRACE3("i", "i*si", loc_id, name, dapl_id);
/* Check args */
@@ -603,8 +555,10 @@ H5Dopen_expand(hid_t loc_id, const char *name, hid_t dapl_id)
done:
if(ret_value < 0) {
- if(dset != NULL && H5D_close(dset) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
+ if(dset) {
+ if(H5D_close(dset) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
+ } /* end if */
else {
if(loc_found && H5G_loc_free(&dset_loc) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
@@ -612,7 +566,7 @@ done:
} /* end if */
FUNC_LEAVE_API(ret_value)
-} /* end H5Dopen_expand() */
+} /* end H5Dopen2() */
/*-------------------------------------------------------------------------
@@ -1314,9 +1268,9 @@ done:
*
*-------------------------------------------------------------------------
*/
-static H5D_t *
-H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space,
- hid_t dcpl_id, hid_t dxpl_id)
+H5D_t *
+H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id,
+ hid_t dxpl_id)
{
const H5T_t *type; /* Datatype for dataset */
H5D_t *new_dset = NULL;
diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c
new file mode 100644
index 0000000..7fe61e6
--- /dev/null
+++ b/src/H5Ddeprec.c
@@ -0,0 +1,256 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5Ddeprec.c
+ * April 5 2007
+ * Quincey Koziol <koziol@hdfgroup.org>
+ *
+ * Purpose: Deprecated functions from the H5D interface. These
+ * functions are here for compatibility purposes and may be
+ * removed in the future. Applications should switch to the
+ * newer APIs.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#define H5D_PACKAGE /*suppress error about including H5Dpkg */
+
+/* Interface initialization */
+#define H5_INTERFACE_INIT_FUNC H5D_init_deprec_interface
+
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5Dpkg.h" /* Datasets */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Iprivate.h" /* IDs */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Package Typedefs */
+/********************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+
+
+/*--------------------------------------------------------------------------
+NAME
+ H5D_init_deprec_interface -- Initialize interface-specific information
+USAGE
+ herr_t H5D_init_deprec_interface()
+RETURNS
+ Non-negative on success/Negative on failure
+DESCRIPTION
+ Initializes any interface-specific data or routines. (Just calls
+ H5D_init() currently).
+
+--------------------------------------------------------------------------*/
+static herr_t
+H5D_init_deprec_interface(void)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_init_deprec_interface)
+
+ FUNC_LEAVE_NOAPI(H5D_init())
+} /* H5D_init_deprec_interface() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Dcreate
+ *
+ * Purpose: Creates a new dataset named NAME at LOC_ID, opens the
+ * dataset for access, and associates with that dataset constant
+ * and initial persistent properties including the type of each
+ * datapoint as stored in the file (TYPE_ID), the size of the
+ * dataset (SPACE_ID), and other initial miscellaneous
+ * properties (DCPL_ID).
+ *
+ * All arguments are copied into the dataset, so the caller is
+ * allowed to derive new types, data spaces, and creation
+ * parameters from the old ones and reuse them in calls to
+ * create other datasets.
+ *
+ * Return: Success: The object ID of the new dataset. At this
+ * point, the dataset is ready to receive its
+ * raw data. Attempting to read raw data from
+ * the dataset will probably return the fill
+ * value. The dataset should be closed when
+ * the caller is no longer interested in it.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, December 3, 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Dcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
+ hid_t dcpl_id)
+{
+ H5G_loc_t loc; /* Object location to insert dataset into */
+ H5D_t *dset = NULL; /* New dataset's info */
+ const H5S_t *space; /* Dataspace for dataset */
+ hid_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(H5Dcreate, FAIL)
+ H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, dcpl_id);
+
+ /* Check arguments */
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ if(H5I_DATATYPE != H5I_get_type(type_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID")
+ if(NULL == (space = H5I_object_verify(space_id,H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID")
+ if(H5P_DEFAULT == dcpl_id)
+ dcpl_id = H5P_DATASET_CREATE_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID")
+
+ /* Build and open the new dataset */
+ if(NULL == (dset = H5D_create_named(&loc, name, type_id, space,
+ H5P_LINK_CREATE_DEFAULT, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, H5AC_dxpl_id)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
+
+ /* Register the new dataset to get an ID for it */
+ if((ret_value = H5I_register(H5I_DATASET, dset)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset")
+
+done:
+ if(ret_value < 0)
+ if(dset && H5D_close(dset) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
+
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Dcreate() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Dopen
+ *
+ * Purpose: Finds a dataset named NAME at LOC_ID, opens it, and returns
+ * its ID. The dataset should be close when the caller is no
+ * longer interested in it.
+ *
+ * Return: Success: A new dataset ID
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Dopen(hid_t loc_id, const char *name)
+{
+ H5D_t *dset = NULL;
+ H5G_loc_t loc; /* Object location of group */
+ H5G_loc_t dset_loc; /* Object location of dataset */
+ H5G_name_t path; /* Dataset group hier. path */
+ H5O_loc_t oloc; /* Dataset object location */
+ H5O_type_t obj_type; /* Type of object at location */
+ hbool_t loc_found = FALSE; /* Location at 'name' found */
+ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */
+ hid_t ret_value;
+
+ FUNC_ENTER_API(H5Dopen, FAIL)
+ H5TRACE2("i", "i*s", loc_id, name);
+
+ /* Check args */
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+
+ /* Set up dataset location to fill in */
+ dset_loc.oloc = &oloc;
+ dset_loc.path = &path;
+ H5G_loc_reset(&dset_loc);
+
+ /* Find the dataset object */
+ if(H5G_loc_find(&loc, name, &dset_loc, H5P_DEFAULT, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found")
+ loc_found = TRUE;
+
+ /* Check that the object found is the correct type */
+ if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type")
+ if(obj_type != H5O_TYPE_DATASET)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset")
+
+ /* Open the dataset */
+ if((dset = H5D_open(&dset_loc, dxpl_id)) == NULL)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset")
+
+ /* Register an atom for the dataset */
+ if((ret_value = H5I_register(H5I_DATASET, dset)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom")
+
+done:
+ if(ret_value < 0) {
+ if(dset != NULL) {
+ if(H5D_close(dset) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
+ } /* end if */
+ else {
+ if(loc_found && H5G_loc_free(&dset_loc) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
+ } /* end else */
+ } /* end if */
+
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Dopen() */
+
diff --git a/src/H5Doh.c b/src/H5Doh.c
index 56cb565..e59fe8b 100644
--- a/src/H5Doh.c
+++ b/src/H5Doh.c
@@ -17,26 +17,31 @@
/* Module Setup */
/****************/
+#define H5D_PACKAGE /*suppress error about including H5Dpkg */
#define H5O_PACKAGE /*suppress error about including H5Opkg */
+
/***********/
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
-#include "H5Dprivate.h" /* Datasets */
+#include "H5Dpkg.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
#include "H5Iprivate.h" /* IDs */
#include "H5Opkg.h" /* Object headers */
+
/****************/
/* Local Macros */
/****************/
+
/******************/
/* Local Typedefs */
/******************/
+
/********************/
/* Local Prototypes */
/********************/
@@ -44,16 +49,21 @@ static void *H5O_dset_get_copy_file_udata(void);
static void H5O_dset_free_copy_file_udata(void *);
static htri_t H5O_dset_isa(H5O_t *loc);
static hid_t H5O_dset_open(const H5G_loc_t *obj_loc, hid_t dxpl_id);
+static void *H5O_dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc,
+ hid_t dxpl_id);
static H5O_loc_t *H5O_dset_get_oloc(hid_t obj_id);
+
/*********************/
/* Package Variables */
/*********************/
+
/*****************************/
/* Library Private Variables */
/*****************************/
+
/*******************/
/* Local Variables */
/*******************/
@@ -66,6 +76,7 @@ const H5O_obj_class_t H5O_OBJ_DATASET[1] = {{
H5O_dset_free_copy_file_udata, /* free 'copy file' user data */
H5O_dset_isa, /* "isa" message */
H5O_dset_open, /* open an object of this class */
+ H5O_dset_create, /* create an object of this class */
H5O_dset_get_oloc /* get an object header location for an object */
}};
@@ -218,8 +229,8 @@ H5O_dset_open(const H5G_loc_t *obj_loc, hid_t dxpl_id)
HDassert(obj_loc);
/* Open the dataset */
- if((dset = H5D_open(obj_loc, dxpl_id)) == NULL)
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open dataset")
+ if(NULL == (dset = H5D_open(obj_loc, dxpl_id)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset")
/* Register an ID for the dataset */
if((ret_value = H5I_register(H5I_DATASET, dset)) < 0)
@@ -227,14 +238,63 @@ H5O_dset_open(const H5G_loc_t *obj_loc, hid_t dxpl_id)
done:
if(ret_value < 0)
- if(dset != NULL)
- H5D_close(dset);
+ if(dset && H5D_close(dset) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_dset_open() */
/*-------------------------------------------------------------------------
+ * Function: H5O_dset_create
+ *
+ * Purpose: Create a dataset in a file
+ *
+ * Return: Success: Pointer to the dataset data structure
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, April 11, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5O_dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id)
+{
+ H5D_obj_create_t *crt_info = (H5D_obj_create_t *)_crt_info; /* Dataset creation parameters */
+ H5D_t *dset = NULL; /* New dataset created */
+ void *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_dset_create)
+
+ /* Sanity checks */
+ HDassert(f);
+ HDassert(crt_info);
+ HDassert(obj_loc);
+
+ /* Create the the dqtaset */
+ if(NULL == (dset = H5D_create(f, crt_info->type_id, crt_info->space, crt_info->dcpl_id, dxpl_id)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset")
+
+ /* Set up the new dataset's location */
+ if(NULL == (obj_loc->oloc = H5D_oloc(dset)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get object location of dataset")
+ if(NULL == (obj_loc->path = H5D_nameof(dset)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get path of dataset")
+
+ /* Set the return value */
+ ret_value = dset;
+
+done:
+ if(ret_value == NULL)
+ if(dset && H5D_close(dset) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dset_create() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_dset_get_oloc
*
* Purpose: Retrieve the object header location for an open object
@@ -256,11 +316,11 @@ H5O_dset_get_oloc(hid_t obj_id)
FUNC_ENTER_NOAPI_NOINIT(H5O_dset_get_oloc)
/* Get the dataset */
- if((dset = H5I_object(obj_id)) == NULL)
+ if(NULL == (dset = H5I_object(obj_id)))
HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID")
/* Get the dataset's object header location */
- if((ret_value = H5D_oloc(dset)) == NULL)
+ if(NULL == (ret_value = H5D_oloc(dset)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from object")
done:
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index 64e2c06..c527ce7 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -218,17 +218,31 @@ typedef struct fm_map {
hbool_t *select_chunk; /* store the information about whether this chunk is selected or not */
} fm_map;
+/* Typedef for dataset creation operation */
+typedef struct {
+ hid_t type_id; /* Datatype for dataset */
+ const H5S_t *space; /* Dataspace for dataset */
+ hid_t dcpl_id; /* Dataset creation property list */
+} H5D_obj_create_t;
+
+
/*****************************/
/* Package Private Variables */
/*****************************/
extern H5D_dxpl_cache_t H5D_def_dxpl_cache;
+
/******************************/
/* Package Private Prototypes */
/******************************/
+H5_DLL H5D_t *H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space,
+ hid_t dcpl_id, hid_t dxpl_id);
+H5_DLL H5D_t *H5D_create_named(const H5G_loc_t *loc, const char *name,
+ hid_t type_id, const H5S_t *space, hid_t lcpl_id, hid_t dcpl_id,
+ hid_t dapl_id, hid_t dxpl_id);
H5_DLL herr_t H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset, H5D_time_alloc_t time_alloc,
- hbool_t update_time, hbool_t full_overwrite);
+ hbool_t update_time, hbool_t full_overwrite);
/* Functions that perform serial I/O operations */
H5_DLL herr_t H5D_select_fscat (H5D_io_info_t *io_info,
diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h
index 5dec2fc..ad1b873 100644
--- a/src/H5Dpublic.h
+++ b/src/H5Dpublic.h
@@ -91,10 +91,11 @@ extern "C" {
typedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim,
const hsize_t *point, void *operator_data);
-H5_DLL hid_t H5Dcreate(hid_t file_id, const char *name, hid_t type_id,
- hid_t space_id, hid_t plist_id);
-H5_DLL hid_t H5Dopen(hid_t file_id, const char *name);
-H5_DLL hid_t H5Dopen_expand(hid_t file_id, const char *name, hid_t dapl_id);
+H5_DLL hid_t H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id,
+ hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id);
+H5_DLL hid_t H5Dcreate_anon(hid_t file_id, hid_t type_id, hid_t space_id,
+ hid_t plist_id, hid_t dapl_id);
+H5_DLL hid_t H5Dopen2(hid_t file_id, const char *name, hid_t dapl_id);
H5_DLL herr_t H5Dclose(hid_t dset_id);
H5_DLL hid_t H5Dget_space(hid_t dset_id);
H5_DLL herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation);
@@ -115,11 +116,18 @@ H5_DLL herr_t H5Dfill(const void *fill, hid_t fill_type, void *buf,
hid_t buf_type, hid_t space);
H5_DLL herr_t H5Dset_extent(hid_t dset_id, const hsize_t *size);
H5_DLL herr_t H5Ddebug(hid_t dset_id);
-H5_DLL hid_t H5Dcreate_expand(hid_t file_id, hid_t type_id,
- hid_t space_id, hid_t plist_id, hid_t dapl_id);
+/* Functions and variables defined for compatibility with previous versions
+ * of the HDF5 API.
+ *
+ * Use of these functions and variables is deprecated.
+ */
+H5_DLL hid_t H5Dcreate(hid_t file_id, const char *name, hid_t type_id,
+ hid_t space_id, hid_t plist_id);
+H5_DLL hid_t H5Dopen(hid_t file_id, const char *name);
#ifdef __cplusplus
}
#endif
#endif /* _H5Dpublic_H */
+
diff --git a/src/H5G.c b/src/H5G.c
index b193e61..7de5062 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -85,12 +85,9 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* File access */
-#include "H5FLprivate.h" /* Free Lists */
#include "H5Gpkg.h" /* Groups */
-#include "H5HLprivate.h" /* Local Heaps */
#include "H5Iprivate.h" /* IDs */
-#include "H5Lprivate.h" /* Links */
-#include "H5MMprivate.h" /* Memory management */
+#include "H5Lprivate.h" /* Links */
#include "H5Pprivate.h" /* Property lists */
/* Local macros */
@@ -112,28 +109,23 @@ H5FL_DEFINE(H5G_t);
H5FL_DEFINE(H5G_shared_t);
/* Private prototypes */
-static H5G_t *H5G_create(H5F_t *file, hid_t dxpl_id, hid_t gcpl_id, hid_t gapl_id);
static herr_t H5G_open_oid(H5G_t *grp, hid_t dxpl_id);
-static herr_t H5G_insertion_loc_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
- const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/,
- H5G_own_loc_t *own_loc/*out*/);
/*-------------------------------------------------------------------------
- * Function: H5Gcreate
+ * Function: H5Gcreate2
*
- * Purpose: Creates a new group relative to LOC_ID and gives it the
- * specified NAME. The group is opened for write access
- * and it's object ID is returned.
- *
- * The optional SIZE_HINT specifies how much file space to
- * reserve to store the names that will appear in this
- * group. If a non-positive value is supplied for the SIZE_HINT
- * then a default size is chosen.
- *
- * See also: H5Gset(), H5Gpush(), H5Gpop()
+ * Purpose: Creates a new group relative to LOC_ID, giving it the
+ * specified creation property list GCPL_ID and access
+ * property list GAPL_ID. The link to the new group is
+ * created with the LCPL_ID.
*
- * Errors:
+ * Usage: H5Gcreate2(loc_id, char *name, lcpl_id, gcpl_id, gapl_id)
+ * hid_t loc_id; IN: File or group identifier
+ * const char *name; IN: Absolute or relative name of the new group
+ * hid_t lcpl_id; IN: Property list for link creation
+ * hid_t gcpl_id; IN: Property list for group creation
+ * hid_t gapl_id; IN: Property list for group access
*
* Return: Success: The object ID of a new, empty group open for
* writing. Call H5Gclose() when finished with
@@ -141,115 +133,118 @@ static herr_t H5G_insertion_loc_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
*
* Failure: FAIL
*
- * Programmer: Robb Matzke
- * Wednesday, September 24, 1997
+ * Programmer: Quincey Koziol
+ * April 5, 2007
*
*-------------------------------------------------------------------------
*/
hid_t
-H5Gcreate(hid_t loc_id, const char *name, size_t size_hint)
+H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id,
+ hid_t gapl_id)
{
- H5G_loc_t loc;
- H5G_loc_t grp_loc;
- H5G_t *grp = NULL;
- H5G_loc_t insertion_loc; /* Loc of group in which to create object */
- H5G_name_t insert_path; /* Path of group in which to create object */
- H5O_loc_t insert_oloc; /* oloc of group in which to create object */
- hbool_t insert_loc_valid = FALSE; /* Is insertion_loc valid? */
- H5F_t *file; /* File the group will be inserted into */
- hid_t tmp_gcpl = (-1); /* Temporary group creation property list */
- hid_t grp_id = (-1); /* ID of group being created */
- hid_t ret_value;
+ H5G_loc_t loc; /* Location to create group */
+ H5G_t *grp = NULL; /* New group created */
+ hid_t ret_value; /* Return value */
- FUNC_ENTER_API(H5Gcreate, FAIL)
- H5TRACE3("i", "i*sz", loc_id, name, size_hint);
+ FUNC_ENTER_API(H5Gcreate2, FAIL)
/* Check arguments */
if(H5G_loc(loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
- /* Check if we need to create a non-standard GCPL */
- if(size_hint > 0) {
- H5P_genplist_t *gc_plist; /* Property list created */
- H5O_ginfo_t ginfo; /* Group info property */
+ /* Get correct property list */
+ if(H5P_DEFAULT == lcpl_id)
+ lcpl_id = H5P_LINK_CREATE_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list")
- /* Get the default property list */
- if(NULL == (gc_plist = H5I_object(H5P_GROUP_CREATE_DEFAULT)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ /* Check group creation property list */
+ if(H5P_DEFAULT == gcpl_id)
+ gcpl_id = H5P_GROUP_CREATE_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group create property list")
- /* Make a copy of the default property list */
- if((tmp_gcpl = H5P_copy_plist(gc_plist)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list")
+ /* Check the group access property list */
+ if(H5P_DEFAULT == gapl_id)
+ gapl_id = H5P_GROUP_ACCESS_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list")
- /* Get the copy of the property list */
- if(NULL == (gc_plist = H5I_object(H5P_GROUP_CREATE_DEFAULT)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ /* Create the new group & get its ID */
+ if(NULL == (grp = H5G_create_named(&loc, name, lcpl_id, gcpl_id, gapl_id, H5AC_dxpl_id)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+ if((ret_value = H5I_register(H5I_GROUP, grp)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
- /* Get the group info property */
- if(H5P_get(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
+done:
+ if(ret_value < 0)
+ if(grp && H5G_close(grp) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
- /* Set the non-default local heap size hint */
- ginfo.lheap_size_hint = size_hint;
- if(H5P_set(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
- } /* end if */
- else
- tmp_gcpl = H5P_GROUP_CREATE_DEFAULT;
-
- /* What file is the group being added to? This may not be the same file
- * that loc_id is in if mounting is being used. */
- insertion_loc.path = &insert_path;
- insertion_loc.oloc = &insert_oloc;
- H5G_loc_reset(&insertion_loc);
- if(H5G_insertion_loc(&loc, name, &insertion_loc, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate insertion point")
- insert_loc_valid=TRUE;
- file = insertion_loc.oloc->file;
-
- /* Create the group */
- if(NULL == (grp = H5G_create(file, H5AC_dxpl_id, tmp_gcpl, H5P_DEFAULT)))
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gcreate2() */
- /* Get an ID for the newly created group */
- if((grp_id = H5I_register(H5I_GROUP, grp)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_create_named
+ *
+ * Purpose: Internal routine to create a new "named" group.
+ *
+ * Return: Success: Non-NULL, pointer to new group object.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * April 5, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+H5G_t *
+H5G_create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id,
+ hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id)
+{
+ H5O_obj_create_t ocrt_info; /* Information for object creation */
+ H5G_obj_create_t gcrt_info; /* Information for group creation */
+ H5G_t *ret_value; /* Return value */
- /* Get the new group's location */
- if(H5G_loc(grp_id, &grp_loc) <0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get location for new group")
+ FUNC_ENTER_NOAPI(H5G_create_named, NULL)
- /* Link the new group to its parent group */
- if(H5L_link(&loc, name, &grp_loc, H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link to group")
+ /* Check arguments */
+ HDassert(loc);
+ HDassert(name && *name);
+ HDassert(lcpl_id != H5P_DEFAULT);
+ HDassert(gcpl_id != H5P_DEFAULT);
+ HDassert(gapl_id != H5P_DEFAULT);
+ HDassert(dxpl_id != H5P_DEFAULT);
- /* Set the return value */
- ret_value = grp_id;
+ /* Set up group creation info */
+ gcrt_info.gcpl_id = gcpl_id;
-done:
- if(tmp_gcpl > 0 && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT)
- if(H5I_dec_ref(tmp_gcpl) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release property list")
+ /* Set up object creation information */
+ ocrt_info.obj_type = H5O_TYPE_GROUP;
+ ocrt_info.crt_info = &gcrt_info;
+ ocrt_info.new_obj = NULL;
- if(insert_loc_valid) {
- if(H5G_loc_free(&insertion_loc) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to free location")
- }
- if(ret_value < 0) {
- if(grp_id >= 0)
- H5I_dec_ref(grp_id);
- else if(grp!=NULL)
- H5G_close(grp);
- } /* end if */
+ /* Create the new group and link it to its parent group */
+ if(H5L_link_object(loc, name, &ocrt_info, lcpl_id, gapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create and link to group")
+ HDassert(ocrt_info.new_obj);
- FUNC_LEAVE_API(ret_value)
-} /* end H5Gcreate() */
+ /* Set the return value */
+ ret_value = ocrt_info.new_obj;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_create_named() */
/*-------------------------------------------------------------------------
- * Function: H5Gcreate_expand
+ * Function: H5Gcreate_anon
*
* Purpose: Creates a new group relative to LOC_ID, giving it the
* specified creation property list GCPL_ID and access
@@ -258,23 +253,19 @@ done:
* The resulting ID should be linked into the file with
* H5Llink or it will be deleted when closed.
*
- * Given the default setting, H5Gcreate_expand() followed by
+ * Given the default setting, H5Gcreate_anon() followed by
* H5Llink() will have the same function as H5Gcreate().
*
- * Usage: H5Gcreate_expand(loc_id, char *name, gcpl_id, gapl_id)
- * hid_t loc_id; IN: File or group identifier
- * const char *name; IN: Absolute or relative name of the new group
- * hid_t gcpl_id; IN: Property list for group creation
- * hid_t gapl_id; IN: Property list for group access
+ * Usage: H5Gcreate_anon(loc_id, char *name, gcpl_id, gapl_id)
+ * hid_t loc_id; IN: File or group identifier
+ * const char *name; IN: Absolute or relative name of the new group
+ * hid_t gcpl_id; IN: Property list for group creation
+ * hid_t gapl_id; IN: Property list for group access
*
* Example: To create missing groups "A" and "B01" along the given path "/A/B01/grp"
* hid_t create_id = H5Pcreate(H5P_GROUP_CREATE);
* int status = H5Pset_create_intermediate_group(create_id, TRUE);
- * hid_t gid = H5Gcreate_expand(file_id, "/A/B01/grp", create_id, H5P_DEFAULT);
- *
- * See also: H5Gcreate(), H5Dcreate_expand(), H5Pset_create_intermediate_group()
- *
- * Errors:
+ * hid_t gid = H5Gcreate_anon(file_id, "/A/B01/grp", create_id, H5P_DEFAULT);
*
* Return: Success: The object ID of a new, empty group open for
* writing. Call H5Gclose() when finished with
@@ -284,16 +275,17 @@ done:
*
* Programmer: Peter Cao
* May 08, 2005
+ *
*-------------------------------------------------------------------------
*/
hid_t
-H5Gcreate_expand(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
+H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
{
H5G_loc_t loc;
H5G_t *grp = NULL;
hid_t ret_value;
- FUNC_ENTER_API(H5Gcreate_expand, FAIL)
+ FUNC_ENTER_API(H5Gcreate_anon, FAIL)
H5TRACE3("i", "iii", loc_id, gcpl_id, gapl_id);
/* Check arguments */
@@ -315,101 +307,22 @@ H5Gcreate_expand(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list")
/* Create the new group & get its ID */
- if(NULL == (grp = H5G_create(loc.oloc->file, H5AC_dxpl_id, gcpl_id, gapl_id)))
+ if(NULL == (grp = H5G_create(loc.oloc->file, gcpl_id, H5AC_dxpl_id)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
if((ret_value = H5I_register(H5I_GROUP, grp)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
done:
- if(ret_value < 0) {
- if(grp!=NULL)
- H5G_close(grp);
- } /* end if */
-
- FUNC_LEAVE_API(ret_value)
-} /* end H5Gcreate_expand() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5Gopen
- *
- * Purpose: Opens an existing group for modification. When finished,
- * call H5Gclose() to close it and release resources.
- *
- * Errors:
- *
- * Return: Success: Object ID of the group.
- *
- * Failure: FAIL
- *
- * Programmer: Robb Matzke
- * Wednesday, December 31, 1997
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-H5Gopen(hid_t loc_id, const char *name)
-{
- H5G_t *grp = NULL;
- H5G_loc_t loc;
- H5G_loc_t grp_loc; /* Location used to open group */
- H5G_name_t grp_path; /* Opened object group hier. path */
- H5O_loc_t grp_oloc; /* Opened object object location */
- H5O_type_t obj_type; /* Type of object at location */
- hbool_t loc_found = FALSE; /* Location at 'name' found */
- hid_t ret_value; /* Return value */
-
- FUNC_ENTER_API(H5Gopen, FAIL)
- H5TRACE2("i", "i*s", loc_id, name);
-
- /* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
-
- /* Set up opened group location to fill in */
- grp_loc.oloc = &grp_oloc;
- grp_loc.path = &grp_path;
- H5G_loc_reset(&grp_loc);
-
- /* Find the group object */
- if(H5G_loc_find(&loc, name, &grp_loc/*out*/, H5P_DEFAULT, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found")
- loc_found = TRUE;
-
- /* Check that the object found is the correct type */
- if(H5O_obj_type(&grp_oloc, &obj_type, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_GROUP)
- HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group")
-
- /* Open the group */
- if((grp = H5G_open(&grp_loc, H5AC_dxpl_id)) == NULL)
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
-
- /* Register an atom for the group */
- if((ret_value = H5I_register(H5I_GROUP, grp)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
-
-done:
- if(ret_value < 0) {
- if(grp != NULL)
- H5G_close(grp);
- else {
- if(loc_found) {
- if(H5G_loc_free(&grp_loc) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
- }
- } /* end else */
- } /* end if */
+ if(ret_value < 0)
+ if(grp && H5G_close(grp) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
FUNC_LEAVE_API(ret_value)
-} /* end H5Gopen() */
+} /* end H5Gcreate_anon() */
/*-------------------------------------------------------------------------
- * Function: H5Gopen_expand
+ * Function: H5Gopen2
*
* Purpose: Opens an existing group for modification. When finished,
* call H5Gclose() to close it and release resources.
@@ -426,7 +339,7 @@ done:
*-------------------------------------------------------------------------
*/
hid_t
-H5Gopen_expand(hid_t loc_id, const char *name, hid_t gapl_id)
+H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id)
{
H5G_t *grp = NULL;
H5G_loc_t loc;
@@ -437,7 +350,7 @@ H5Gopen_expand(hid_t loc_id, const char *name, hid_t gapl_id)
hbool_t loc_found = FALSE; /* Location at 'name' found */
hid_t ret_value; /* Return value */
- FUNC_ENTER_API(H5Gopen_expand, FAIL);
+ FUNC_ENTER_API(H5Gopen2, FAIL)
H5TRACE3("i", "i*si", loc_id, name, gapl_id);
/* Check args */
@@ -479,18 +392,18 @@ H5Gopen_expand(hid_t loc_id, const char *name, hid_t gapl_id)
done:
if(ret_value < 0) {
- if(grp != NULL)
- H5G_close(grp);
+ if(grp) {
+ if(H5G_close(grp) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
+ } /* end if */
else {
- if(loc_found) {
- if(H5G_loc_free(&grp_loc) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
- }
+ if(loc_found && H5G_loc_free(&grp_loc) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
} /* end else */
} /* end if */
FUNC_LEAVE_API(ret_value)
-} /* end H5Gopen_expand() */
+} /* end H5Gopen2() */
/*-------------------------------------------------------------------------
@@ -730,7 +643,7 @@ H5Gclose(hid_t group_id)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Gclose, FAIL);
+ FUNC_ENTER_API(H5Gclose, FAIL)
H5TRACE1("e", "i", group_id);
/* Check args */
@@ -840,10 +753,10 @@ H5G_term_interface(void)
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_term_interface)
- if (H5_interface_initialize_g) {
- if ((n = H5I_nmembers(H5I_GROUP))) {
+ if(H5_interface_initialize_g) {
+ if((n = H5I_nmembers(H5I_GROUP)))
H5I_clear_type(H5I_GROUP, FALSE);
- } else {
+ else {
/* Destroy the group object id group */
H5I_dec_type_ref(H5I_GROUP);
@@ -861,105 +774,6 @@ H5G_term_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5G_component
- *
- * Purpose: Returns the pointer to the first component of the
- * specified name by skipping leading slashes. Returns
- * the size in characters of the component through SIZE_P not
- * counting leading slashes or the null terminator.
- *
- * Return: Success: Ptr into NAME.
- *
- * Failure: Ptr to the null terminator of NAME.
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 11 1997
- *
- *-------------------------------------------------------------------------
- */
-const char *
-H5G_component(const char *name, size_t *size_p)
-{
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_component)
-
- assert(name);
-
- while ('/' == *name)
- name++;
- if (size_p)
- *size_p = HDstrcspn(name, "/");
-
- FUNC_LEAVE_NOAPI(name)
-} /* end H5G_component() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5G_normalize
- *
- * Purpose: Returns a pointer to a new string which has duplicate and
- * trailing slashes removed from it.
- *
- * Return: Success: Ptr to normalized name.
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * Saturday, August 16, 2003
- *
- *-------------------------------------------------------------------------
- */
-char *
-H5G_normalize(const char *name)
-{
- char *norm; /* Pointer to the normalized string */
- size_t s,d; /* Positions within the strings */
- unsigned last_slash; /* Flag to indicate last character was a slash */
- char *ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5G_normalize);
-
- /* Sanity check */
- assert(name);
-
- /* Duplicate the name, to return */
- if (NULL==(norm=H5MM_strdup(name)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string");
-
- /* Walk through the characters, omitting duplicated '/'s */
- s=d=0;
- last_slash=0;
- while(name[s]!='\0') {
- if(name[s]=='/')
- if(last_slash)
- ;
- else {
- norm[d++]=name[s];
- last_slash=1;
- } /* end else */
- else {
- norm[d++]=name[s];
- last_slash=0;
- } /* end else */
- s++;
- } /* end while */
-
- /* Terminate normalized string */
- norm[d]='\0';
-
- /* Check for final '/' on normalized name & eliminate it */
- if(d>1 && last_slash)
- norm[d-1]='\0';
-
- /* Set return value */
- ret_value=norm;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5G_normalize() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5G_mkroot
*
* Purpose: Creates a root group in an empty file and opens it. If a
@@ -1094,8 +908,8 @@ done:
*
*-------------------------------------------------------------------------
*/
-static H5G_t *
-H5G_create(H5F_t *file, hid_t dxpl_id, hid_t gcpl_id, hid_t UNUSED gapl_id)
+H5G_t *
+H5G_create(H5F_t *file, hid_t gcpl_id, hid_t dxpl_id)
{
H5G_t *grp = NULL; /*new group */
H5P_genplist_t *gc_plist; /* Property list created */
@@ -1109,9 +923,7 @@ H5G_create(H5F_t *file, hid_t dxpl_id, hid_t gcpl_id, hid_t UNUSED gapl_id)
/* check args */
HDassert(file);
HDassert(gcpl_id != H5P_DEFAULT);
-#ifdef LATER
- HDassert(gapl_id != H5P_DEFAULT);
-#endif /* LATER */
+ HDassert(dxpl_id != H5P_DEFAULT);
/* create an open group */
if(NULL == (grp = H5FL_CALLOC(H5G_t)))
@@ -1559,86 +1371,6 @@ H5G_map_obj_type(H5O_type_t obj_type)
/*-------------------------------------------------------------------------
- * Function: H5G_insertion_loc_cb
- *
- * Purpose: Callback for finding insertion location. This routine sets the
- * correct information in the location passed in through the udata.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: James Laird
- * Wednesday, August 16, 2006
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5G_insertion_loc_cb(H5G_loc_t *grp_loc/*in*/, const char UNUSED *name, const H5O_link_t UNUSED *lnk,
- H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/)
-{
- H5G_trav_ins_t *udata = (H5G_trav_ins_t *)_udata; /* User data passed in */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5G_insertion_loc_cb)
-
- /* Check if the name in this group resolves to a valid location */
- /* (which is not what we want) */
- if(obj_loc != NULL)
- HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name already exists")
-
- /* Take ownership of the grp_loc */
- if(H5G_loc_copy(udata->loc, grp_loc, H5_COPY_SHALLOW) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "couldn't take ownership of group location")
- *own_loc = H5G_OWN_GRP_LOC;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_insertion_loc_cb() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5G_insertion_loc
- *
- * Purpose: Given a location and name that specifies a not-yet-existing
- * object return the location of the group into which the object
- * is about to be inserted.
- *
- * Return: Success: H5G_loc_t pointer
- * (should be released with H5G_loc_free)
- *
- * Failure: NULL
- *
- * Programmer: James Laird
- * Wednesday, August 16, 2006
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5G_insertion_loc(H5G_loc_t *src_loc, const char *name,
- H5G_loc_t *insertion_loc/*out*/, hid_t dxpl_id)
-{
- H5G_trav_ins_t udata; /* User data for traversal */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5G_insertion_loc, FAIL)
-
- HDassert(src_loc);
- HDassert(insertion_loc);
- HDassert(name && *name);
-
- /*
- * Look up the name to get the containing group's location and to make
- * sure the name doesn't already exist.
- */
- udata.loc = insertion_loc;
- if(H5G_traverse(src_loc, name, H5G_TARGET_NORMAL, H5G_insertion_loc_cb, &udata, H5P_DEFAULT, dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name already exists")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_insertion_loc() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5G_free_grp_name
*
* Purpose: Free the 'ID to name' buffers.
@@ -1687,12 +1419,12 @@ done:
herr_t
H5G_get_shared_count(H5G_t *grp)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_get_shared_count);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_get_shared_count)
/* Check args */
HDassert(grp && grp->shared);
- FUNC_LEAVE_NOAPI(grp->shared->fo_count);
+ FUNC_LEAVE_NOAPI(grp->shared->fo_count)
} /* end H5G_get_shared_count() */
@@ -1711,7 +1443,7 @@ H5G_get_shared_count(H5G_t *grp)
herr_t
H5G_mount(H5G_t *grp)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_mount);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_mount)
/* Check args */
HDassert(grp && grp->shared);
@@ -1720,7 +1452,7 @@ H5G_mount(H5G_t *grp)
/* Set the 'mounted' flag */
grp->shared->mounted = TRUE;
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5G_mount() */
@@ -1739,7 +1471,7 @@ H5G_mount(H5G_t *grp)
herr_t
H5G_unmount(H5G_t *grp)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_unmount);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_unmount)
/* Check args */
HDassert(grp && grp->shared);
@@ -1748,6 +1480,6 @@ H5G_unmount(H5G_t *grp)
/* Reset the 'mounted' flag */
grp->shared->mounted = FALSE;
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5G_unmount() */
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c
index d202f7f..2f6d4e5 100644
--- a/src/H5Gdeprec.c
+++ b/src/H5Gdeprec.c
@@ -43,7 +43,9 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Gpkg.h" /* Groups */
+#include "H5Iprivate.h" /* IDs */
#include "H5Lprivate.h" /* Links */
+#include "H5Pprivate.h" /* Property lists */
/****************/
@@ -126,6 +128,171 @@ H5G_init_deprec_interface(void)
/*-------------------------------------------------------------------------
+ * Function: H5Gcreate
+ *
+ * Purpose: Creates a new group relative to LOC_ID and gives it the
+ * specified NAME. The group is opened for write access
+ * and it's object ID is returned.
+ *
+ * The optional SIZE_HINT specifies how much file space to
+ * reserve to store the names that will appear in this
+ * group. If a non-positive value is supplied for the SIZE_HINT
+ * then a default size is chosen.
+ *
+ * Return: Success: The object ID of a new, empty group open for
+ * writing. Call H5Gclose() when finished with
+ * the group.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, September 24, 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Gcreate(hid_t loc_id, const char *name, size_t size_hint)
+{
+ H5G_loc_t loc; /* Location to create group */
+ H5G_t *grp = NULL; /* New group created */
+ hid_t tmp_gcpl = (-1); /* Temporary group creation property list */
+ hid_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(H5Gcreate, FAIL)
+ H5TRACE3("i", "i*sz", loc_id, name, size_hint);
+
+ /* Check arguments */
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given")
+
+ /* Check if we need to create a non-standard GCPL */
+ if(size_hint > 0) {
+ H5P_genplist_t *gc_plist; /* Property list created */
+ H5O_ginfo_t ginfo; /* Group info property */
+
+ /* Get the default property list */
+ if(NULL == (gc_plist = H5I_object(H5P_GROUP_CREATE_DEFAULT)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+
+ /* Make a copy of the default property list */
+ if((tmp_gcpl = H5P_copy_plist(gc_plist)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list")
+
+ /* Get the copy of the property list */
+ if(NULL == (gc_plist = H5I_object(H5P_GROUP_CREATE_DEFAULT)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+
+ /* Get the group info property */
+ if(H5P_get(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
+
+ /* Set the non-default local heap size hint */
+ ginfo.lheap_size_hint = size_hint;
+ if(H5P_set(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
+ } /* end if */
+ else
+ tmp_gcpl = H5P_GROUP_CREATE_DEFAULT;
+
+ /* Create the new group & get its ID */
+ if(NULL == (grp = H5G_create_named(&loc, name, H5P_LINK_CREATE_DEFAULT,
+ tmp_gcpl, H5P_GROUP_ACCESS_DEFAULT, H5AC_dxpl_id)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+ if((ret_value = H5I_register(H5I_GROUP, grp)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
+
+done:
+ if(tmp_gcpl > 0 && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT)
+ if(H5I_dec_ref(tmp_gcpl) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release property list")
+
+ if(ret_value < 0)
+ if(grp && H5G_close(grp) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
+
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gcreate() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Gopen
+ *
+ * Purpose: Opens an existing group for modification. When finished,
+ * call H5Gclose() to close it and release resources.
+ *
+ * Return: Success: Object ID of the group.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, December 31, 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Gopen(hid_t loc_id, const char *name)
+{
+ H5G_t *grp = NULL;
+ H5G_loc_t loc;
+ H5G_loc_t grp_loc; /* Location used to open group */
+ H5G_name_t grp_path; /* Opened object group hier. path */
+ H5O_loc_t grp_oloc; /* Opened object object location */
+ H5O_type_t obj_type; /* Type of object at location */
+ hbool_t loc_found = FALSE; /* Location at 'name' found */
+ hid_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(H5Gopen, FAIL)
+ H5TRACE2("i", "i*s", loc_id, name);
+
+ /* Check args */
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+
+ /* Set up opened group location to fill in */
+ grp_loc.oloc = &grp_oloc;
+ grp_loc.path = &grp_path;
+ H5G_loc_reset(&grp_loc);
+
+ /* Find the group object */
+ if(H5G_loc_find(&loc, name, &grp_loc/*out*/, H5P_DEFAULT, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found")
+ loc_found = TRUE;
+
+ /* Check that the object found is the correct type */
+ if(H5O_obj_type(&grp_oloc, &obj_type, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type")
+ if(obj_type != H5O_TYPE_GROUP)
+ HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group")
+
+ /* Open the group */
+ if((grp = H5G_open(&grp_loc, H5AC_dxpl_id)) == NULL)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
+
+ /* Register an atom for the group */
+ if((ret_value = H5I_register(H5I_GROUP, grp)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
+
+done:
+ if(ret_value < 0) {
+ if(grp) {
+ if(H5G_close(grp) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
+ } /* end if */
+ else {
+ if(loc_found && H5G_loc_free(&grp_loc) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
+ } /* end else */
+ } /* end if */
+
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gopen() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Glink
*
* Purpose: Creates a link between two existing objects. The new
diff --git a/src/H5Gint.c b/src/H5Gint.c
new file mode 100644
index 0000000..61598c2
--- /dev/null
+++ b/src/H5Gint.c
@@ -0,0 +1,200 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5Gint.c
+ * April 5 2007
+ * Quincey Koziol <koziol@hdfgroup.org>
+ *
+ * Purpose: General use, "internal" routines for groups.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#define H5G_PACKAGE /*suppress error about including H5Gpkg */
+
+/* Interface initialization */
+#define H5_INTERFACE_INIT_FUNC H5G_init_int_interface
+
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Gpkg.h" /* Groups */
+#include "H5MMprivate.h" /* Memory management */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Package Typedefs */
+/********************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+
+
+/*--------------------------------------------------------------------------
+NAME
+ H5G_init_int_interface -- Initialize interface-specific information
+USAGE
+ herr_t H5G_init_int_interface()
+RETURNS
+ Non-negative on success/Negative on failure
+DESCRIPTION
+ Initializes any interface-specific data or routines. (Just calls
+ H5G_init() currently).
+
+--------------------------------------------------------------------------*/
+static herr_t
+H5G_init_int_interface(void)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_init_int_interface)
+
+ FUNC_LEAVE_NOAPI(H5G_init())
+} /* H5G_init_int_interface() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_component
+ *
+ * Purpose: Returns the pointer to the first component of the
+ * specified name by skipping leading slashes. Returns
+ * the size in characters of the component through SIZE_P not
+ * counting leading slashes or the null terminator.
+ *
+ * Return: Success: Ptr into NAME.
+ *
+ * Failure: Ptr to the null terminator of NAME.
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 11 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+const char *
+H5G_component(const char *name, size_t *size_p)
+{
+ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_component)
+
+ assert(name);
+
+ while ('/' == *name)
+ name++;
+ if (size_p)
+ *size_p = HDstrcspn(name, "/");
+
+ FUNC_LEAVE_NOAPI(name)
+} /* end H5G_component() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_normalize
+ *
+ * Purpose: Returns a pointer to a new string which has duplicate and
+ * trailing slashes removed from it.
+ *
+ * Return: Success: Ptr to normalized name.
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, August 16, 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+char *
+H5G_normalize(const char *name)
+{
+ char *norm; /* Pointer to the normalized string */
+ size_t s,d; /* Positions within the strings */
+ unsigned last_slash; /* Flag to indicate last character was a slash */
+ char *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5G_normalize)
+
+ /* Sanity check */
+ HDassert(name);
+
+ /* Duplicate the name, to return */
+ if(NULL == (norm = H5MM_strdup(name)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string")
+
+ /* Walk through the characters, omitting duplicated '/'s */
+ s = d = 0;
+ last_slash = 0;
+ while(name[s] != '\0') {
+ if(name[s] == '/')
+ if(last_slash)
+ ;
+ else {
+ norm[d++] = name[s];
+ last_slash = 1;
+ } /* end else */
+ else {
+ norm[d++] = name[s];
+ last_slash = 0;
+ } /* end else */
+ s++;
+ } /* end while */
+
+ /* Terminate normalized string */
+ norm[d] = '\0';
+
+ /* Check for final '/' on normalized name & eliminate it */
+ if(d > 1 && last_slash)
+ norm[d - 1] = '\0';
+
+ /* Set return value */
+ ret_value = norm;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_normalize() */
+
diff --git a/src/H5Goh.c b/src/H5Goh.c
index 6ea3a00..598cd5a 100644
--- a/src/H5Goh.c
+++ b/src/H5Goh.c
@@ -18,15 +18,19 @@
/****************/
#define H5O_PACKAGE /*suppress error about including H5Opkg */
+#define H5G_PACKAGE /*suppress error about including H5Gpkg */
+
/***********/
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
+#include "H5Gpkg.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
#include "H5Opkg.h" /* Object headers */
+
/****************/
/* Local Macros */
/****************/
@@ -43,8 +47,11 @@
static htri_t H5O_group_isa(H5O_t *loc);
static hid_t H5O_group_open(const H5G_loc_t *obj_loc, hid_t dxpl_id);
+static void *H5O_group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc,
+ hid_t dxpl_id);
static H5O_loc_t *H5O_group_get_oloc(hid_t obj_id);
+
/*********************/
/* Package Variables */
/*********************/
@@ -67,6 +74,7 @@ const H5O_obj_class_t H5O_OBJ_GROUP[1] = {{
NULL, /* free 'copy file' user data */
H5O_group_isa, /* "isa" message */
H5O_group_open, /* open an object of this class */
+ H5O_group_create, /* create an object of this class */
H5O_group_get_oloc /* get an object header location for an object */
}};
@@ -136,7 +144,7 @@ H5O_group_open(const H5G_loc_t *obj_loc, hid_t dxpl_id)
HDassert(obj_loc);
/* Open the group */
- if((grp = H5G_open(obj_loc, dxpl_id)) == NULL)
+ if(NULL == (grp = H5G_open(obj_loc, dxpl_id)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
/* Register an ID for the group */
@@ -145,14 +153,63 @@ H5O_group_open(const H5G_loc_t *obj_loc, hid_t dxpl_id)
done:
if(ret_value < 0)
- if(grp != NULL)
- H5G_close(grp);
+ if(grp && H5G_close(grp) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_group_open() */
/*-------------------------------------------------------------------------
+ * Function: H5O_group_create
+ *
+ * Purpose: Create a group in a file
+ *
+ * Return: Success: Pointer to the group data structure
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, April 10, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5O_group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id)
+{
+ H5G_obj_create_t *crt_info = (H5G_obj_create_t *)_crt_info; /* Group creation parameters */
+ H5G_t *grp = NULL; /* New group created */
+ void *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_group_create)
+
+ /* Sanity checks */
+ HDassert(f);
+ HDassert(crt_info);
+ HDassert(obj_loc);
+
+ /* Create the the group */
+ if(NULL == (grp = H5G_create(f, crt_info->gcpl_id, dxpl_id)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group")
+
+ /* Set up the new group's location */
+ if(NULL == (obj_loc->oloc = H5G_oloc(grp)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get object location of group")
+ if(NULL == (obj_loc->path = H5G_nameof(grp)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get path of group")
+
+ /* Set the return value */
+ ret_value = grp;
+
+done:
+ if(ret_value == NULL)
+ if(grp && H5G_close(grp) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release group")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_group_create() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_group_get_oloc
*
* Purpose: Retrieve the object header location for an open object
@@ -174,11 +231,11 @@ H5O_group_get_oloc(hid_t obj_id)
FUNC_ENTER_NOAPI_NOINIT(H5O_group_get_oloc)
/* Get the group */
- if((grp = H5I_object(obj_id)) == NULL)
+ if(NULL == (grp = H5I_object(obj_id)))
HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID")
/* Get the group's object header location */
- if((ret_value = H5G_oloc(grp)) == NULL)
+ if(NULL == (ret_value = H5G_oloc(grp)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from object")
done:
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index 879b364..928da33 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -332,6 +332,12 @@ typedef herr_t (*H5G_traverse_t)(H5G_loc_t *grp_loc/*in*/, const char *name,
const H5O_link_t *lnk/*in*/, H5G_loc_t *obj_loc/*out*/, void *operator_data/*in,out*/,
H5G_own_loc_t *own_loc/*out*/);
+/* Typedef for group creation operation */
+typedef struct {
+ hid_t gcpl_id; /* Group creation property list */
+} H5G_obj_create_t;
+
+
/*****************************/
/* Package Private Variables */
/*****************************/
@@ -350,12 +356,20 @@ H5_DLLVAR const H5B2_class_t H5G_BT2_NAME[1];
/* The v2 B-tree class for indexing 'creation order' field on links */
H5_DLLVAR const H5B2_class_t H5G_BT2_CORDER[1];
+/******************************/
+/* Package Private Prototypes */
+/******************************/
+
/*
- * Utility functions
+ * General group routines
+ */
+H5_DLL H5G_t *H5G_create(H5F_t *file, hid_t gcpl_id, hid_t dxpl_id);
+H5_DLL H5G_t *H5G_create_named(const H5G_loc_t *loc, const char *name,
+ hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id);
+
+/*
+ * Group hierarchy traversal routines
*/
-H5_DLL herr_t H5G_init(void);
-H5_DLL char * H5G_normalize(const char *name);
-H5_DLL const char * H5G_component(const char *name, size_t *size_p);
H5_DLL herr_t H5G_traverse_term_interface(void);
H5_DLL herr_t H5G_traverse_special(const H5G_loc_t *grp_loc,
const H5O_link_t *lnk, unsigned target, size_t *nlinks, hbool_t last_comp,
@@ -364,9 +378,12 @@ H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name,
unsigned target, H5G_traverse_t op, void *op_data, hid_t lapl_id,
hid_t dxpl_id);
-/******************************/
-/* Package Private Prototypes */
-/******************************/
+/*
+ * Utility functions
+ */
+H5_DLL herr_t H5G_init(void);
+H5_DLL char *H5G_normalize(const char *name);
+H5_DLL const char *H5G_component(const char *name, size_t *size_p);
/*
* Functions that understand symbol tables but not names. The
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index 647f36d..40d2df8 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -154,8 +154,6 @@ H5_DLL H5F_t *H5G_fileof(H5G_t *grp);
H5_DLL herr_t H5G_free(H5G_t *grp);
H5_DLL H5G_t *H5G_open(const H5G_loc_t *loc, hid_t dxpl_id);
H5_DLL herr_t H5G_close(H5G_t *grp);
-H5_DLL herr_t H5G_insertion_loc(H5G_loc_t *src_loc, const char *name,
- H5G_loc_t *insertion_loc/*out*/, hid_t dxpl_id);
H5_DLL herr_t H5G_free_grp_name(H5G_t *grp);
H5_DLL herr_t H5G_get_shared_count(H5G_t *grp);
H5_DLL herr_t H5G_mount(H5G_t *grp);
diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h
index 598d04e..59c9307 100644
--- a/src/H5Gpublic.h
+++ b/src/H5Gpublic.h
@@ -120,10 +120,10 @@ typedef herr_t (*H5G_iterate_t)(hid_t group, const char *name, void *op_data);
/*********************/
/* Public Prototypes */
/*********************/
-H5_DLL hid_t H5Gcreate(hid_t loc_id, const char *name, size_t size_hint);
-H5_DLL hid_t H5Gcreate_expand(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id);
-H5_DLL hid_t H5Gopen(hid_t loc_id, const char *name);
-H5_DLL hid_t H5Gopen_expand(hid_t loc_id, const char *name, hid_t gapl_id);
+H5_DLL hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id,
+ hid_t gcpl_id, hid_t gapl_id);
+H5_DLL hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id);
+H5_DLL hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id);
H5_DLL hid_t H5Gget_create_plist(hid_t group_id);
H5_DLL herr_t H5Gget_info(hid_t loc_id, const char *name, H5G_info_t *ginfo,
hid_t lapl_id);
@@ -137,6 +137,8 @@ H5_DLL herr_t H5Gclose(hid_t group_id);
*
* Use of these functions and variables is deprecated.
*/
+H5_DLL hid_t H5Gcreate(hid_t loc_id, const char *name, size_t size_hint);
+H5_DLL hid_t H5Gopen(hid_t loc_id, const char *name);
H5_DLL herr_t H5Glink(hid_t cur_loc_id, H5L_type_t type, const char *cur_name,
const char *new_name);
H5_DLL herr_t H5Gmove(hid_t src_loc_id, const char *src_name,
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index 9434f17..99a9113 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -157,8 +157,8 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk,
H5G_loc_t grp_loc_copy;
H5G_name_t grp_path_copy;
H5O_loc_t grp_oloc_copy;
- H5O_loc_t *new_oloc=NULL;
- H5F_t *temp_file=NULL;
+ H5O_loc_t *new_oloc = NULL;
+ H5F_t *temp_file = NULL;
H5G_t *grp;
hid_t lapl_id = (-1); /* LAPL local to this routine */
H5P_genplist_t *lapl; /* LAPL with nlinks set */
@@ -197,24 +197,27 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk,
if((cur_grp = H5I_register(H5I_GROUP, grp)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
- /* Record number of soft links left to traverse in the property list.
- * If no property list exists yet, create one. */
- if(_lapl_id == H5P_DEFAULT || _lapl_id == H5P_LINK_ACCESS_DEFAULT) {
+ /* Check for generic default property list and use link access default if so */
+ if(_lapl_id == H5P_DEFAULT) {
HDassert(H5P_LINK_ACCESS_DEFAULT != -1);
if(NULL == (lapl = H5I_object(H5P_LINK_ACCESS_DEFAULT)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "unable to get default property list")
-
- if((lapl_id = H5P_copy_plist(lapl)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unable to copy property list")
} /* end if */
else {
- /* Use the property list passed in */
- lapl_id = _lapl_id;
-
- if(NULL == (lapl = H5I_object(lapl_id)))
+ /* Get the underlying property list passed in */
+ if(NULL == (lapl = H5I_object(_lapl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "unable to get property list from ID")
} /* end else */
+ /* Copy the property list passed in */
+ if((lapl_id = H5P_copy_plist(lapl)) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unable to copy property list")
+
+ /* Get the underlying property list copy */
+ if(NULL == (lapl = H5I_object(lapl_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "unable to get property list from ID")
+
+ /* Record number of soft links left to traverse in the property list. */
if(H5P_set(lapl, H5L_ACS_NLINKS_NAME, nlinks) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set nlink info")
@@ -223,8 +226,7 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk,
HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "traversal callback returned invalid ID")
/* Get the oloc from the ID the user callback returned */
- switch(H5I_get_type(cb_return))
- {
+ switch(H5I_get_type(cb_return)) {
case H5I_GROUP:
if((new_oloc = H5G_oloc(H5I_object(cb_return))) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location from group ID")
@@ -249,7 +251,7 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk,
default:
HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL, "not a valid location or object ID")
- }
+ } /* end switch */
/* Copy the location the user returned to us */
if(H5O_loc_copy(obj_loc->oloc, new_oloc, H5_COPY_DEEP) < 0)
@@ -277,9 +279,8 @@ done:
HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback")
/* Close the LAPL, if we copied the default one */
- if(lapl_id > 0 && lapl_id != _lapl_id)
- if(H5I_dec_ref(lapl_id) < 0)
- HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close copied link access property list")
+ if(lapl_id > 0 && H5I_dec_ref(lapl_id) < 0)
+ HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close copied link access property list")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_traverse_ud() */
@@ -853,7 +854,7 @@ H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traver
/* Go perform "real" traversal */
if(H5G_traverse_real(loc, name, target, &nlinks, op, op_data, lapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "path traversal failed")
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "internal path traversal failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5L.c b/src/H5L.c
index 79d28da..5e41b2e 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -70,9 +70,10 @@ typedef struct {
/* User data for path traversal callback to creating a link */
typedef struct {
H5F_t *file; /* Pointer to the file */
+ H5P_genplist_t *lc_plist; /* Link creation property list */
hid_t dxpl_id; /* Dataset transfer property list */
- hid_t lcpl_id; /* Link creation property list */
H5G_name_t *path; /* Path to object being linked */
+ H5O_obj_create_t *ocrt_info; /* Pointer to object creation info */
H5O_link_t *lnk; /* Pointer to link information to insert */
} H5L_trav_cr_t;
@@ -149,9 +150,9 @@ static int H5L_find_class_idx(H5L_type_t id);
static herr_t H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/,
H5G_own_loc_t *own_loc/*out*/);
-static herr_t H5L_create_real(H5G_loc_t *link_loc, const char *link_name,
- H5G_name_t *obj_path, H5F_t *obj_file, H5O_link_t *lnk, hid_t lcpl_id,
- hid_t lapl_id, hid_t dxpl_id);
+static herr_t H5L_create_real(const H5G_loc_t *link_loc, const char *link_name,
+ H5G_name_t *obj_path, H5F_t *obj_file, H5O_link_t *lnk, H5O_obj_create_t *ocrt_info,
+ hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id);
static herr_t H5L_get_val_real(const H5O_link_t *lnk, void *buf, size_t size);
static herr_t H5L_get_val_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/,
@@ -1431,8 +1432,8 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5L_link(H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc,
- hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id)
+H5L_link(const H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc,
+ hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id)
{
H5O_link_t lnk; /* Link to insert */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1454,7 +1455,7 @@ H5L_link(H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc,
lnk.u.hard.addr = obj_loc->oloc->addr;
/* Create the link */
- if(H5L_create_real(new_loc, new_name, obj_loc->path, obj_loc->oloc->file, &lnk, lcpl_id, lapl_id, dxpl_id) < 0)
+ if(H5L_create_real(new_loc, new_name, obj_loc->path, obj_loc->oloc->file, &lnk, NULL, lcpl_id, lapl_id, dxpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object")
done:
@@ -1463,6 +1464,49 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5L_link_object
+ *
+ * Purpose: Creates a new object and a link to it.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Monday, April 9, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5L_link_object(const H5G_loc_t *new_loc, const char *new_name,
+ H5O_obj_create_t *ocrt_info, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id)
+{
+ H5O_link_t lnk; /* Link to insert */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5L_link_object)
+
+ /* Check args */
+ HDassert(new_loc);
+ HDassert(new_name && *new_name);
+ HDassert(ocrt_info);
+
+ /* The link callback will check that the object isn't being hard linked
+ * into a different file, so we don't need to do it here (there could be
+ * external links along the path).
+ */
+
+ /* Construct link information for eventual insertion */
+ lnk.type = H5L_TYPE_HARD;
+
+ /* Create the link */
+ if(H5L_create_real(new_loc, new_name, NULL, NULL, &lnk, ocrt_info, lcpl_id, lapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5L_link_object() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5L_link_cb
*
* Purpose: Callback for creating a link to an object.
@@ -1494,11 +1538,41 @@ H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED
/* Check for crossing file boundaries with a new hard link */
if(udata->lnk->type == H5L_TYPE_HARD) {
- /* Check that both objects are in same file */
- if(grp_loc->oloc->file->shared != udata->file->shared)
- HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "interfile hard links are not allowed")
+ /* Check for creating an object */
+ /* (only for hard links) */
+ if(udata->ocrt_info) {
+ H5G_loc_t new_loc; /* Group location for new object */
+
+ /* Create new object at this location */
+ if(NULL == (udata->ocrt_info->new_obj = H5O_obj_create(grp_loc->oloc->file, udata->ocrt_info->obj_type, udata->ocrt_info->crt_info, &new_loc, udata->dxpl_id)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create object")
+
+ /* Set address for hard link */
+ udata->lnk->u.hard.addr = new_loc.oloc->addr;
+
+ /* Set object path to use for setting object name (below) */
+ udata->path = new_loc.path;
+ } /* end if */
+ else {
+ /* Check that both objects are in same file */
+ if(grp_loc->oloc->file->shared != udata->file->shared)
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "interfile hard links are not allowed")
+ } /* end else */
} /* end if */
+ /* Set 'standard' aspects of link */
+ udata->lnk->corder = 0; /* Will be re-written during group insertion, if the group is tracking creation order */
+ udata->lnk->corder_valid = FALSE; /* Creation order not valid (yet) */
+
+ /* Check for non-default link creation properties */
+ if(udata->lc_plist) {
+ /* Get character encoding property */
+ if(H5P_get(udata->lc_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &udata->lnk->cset) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for character encoding")
+ } /* end if */
+ else
+ udata->lnk->cset = H5F_DEFAULT_CSET; /* Default character encoding for link */
+
/* Set the link's name correctly */
/* Casting away const OK -QAK */
udata->lnk->name = (char *)name;
@@ -1588,22 +1662,22 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5L_create_real(H5G_loc_t *link_loc, const char *link_name, H5G_name_t *obj_path,
- H5F_t *obj_file, H5O_link_t *lnk, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id)
+H5L_create_real(const H5G_loc_t *link_loc, const char *link_name,
+ H5G_name_t *obj_path, H5F_t *obj_file, H5O_link_t *lnk,
+ H5O_obj_create_t *ocrt_info, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id)
{
char *norm_link_name = NULL; /* Pointer to normalized link name */
unsigned target_flags = H5G_TARGET_NORMAL; /* Flags to pass to group traversal function */
- H5T_cset_t char_encoding = H5F_DEFAULT_CSET; /* Character encoding for link */
- H5P_genplist_t* lc_plist; /* Link creation property list */
+ H5P_genplist_t *lc_plist = NULL; /* Link creation property list */
H5L_trav_cr_t udata; /* User data for callback */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5L_create_real)
/* Check args */
- HDassert(lnk);
HDassert(link_loc);
HDassert(link_name && *link_name);
+ HDassert(lnk);
HDassert(lnk->type >= H5L_TYPE_HARD && lnk->type <= H5L_TYPE_MAX);
/* Get normalized link name */
@@ -1614,6 +1688,7 @@ H5L_create_real(H5G_loc_t *link_loc, const char *link_name, H5G_name_t *obj_path
if(lcpl_id != H5P_DEFAULT) {
unsigned crt_intmd_group;
+ /* Get link creation property list */
if(NULL == (lc_plist = H5I_object(lcpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
@@ -1623,35 +1698,27 @@ H5L_create_real(H5G_loc_t *link_loc, const char *link_name, H5G_name_t *obj_path
if(crt_intmd_group > 0)
target_flags |= H5G_CRT_INTMD_GROUP;
-
- /* Get character encoding property */
- if(H5P_get(lc_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &char_encoding) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for character encoding")
} /* end if */
- /* Pass the lcpl to the link creation callback */
- udata.lcpl_id = lcpl_id;
-
- /* Fill in common data for the link struct */
- lnk->cset = char_encoding;
- lnk->corder = 0; /* Will be re-written during group insertion, if the group is tracking creation order */
- lnk->corder_valid = FALSE; /* Creation order not valid (yet) */
-
/* Set up user data
- * file is used to make sure that hard links don't cross files, and
+ * FILE is used to make sure that hard links don't cross files, and
* should be NULL for other link types.
- * lnk is the link struct passed into this function. At this point all
- * of its fields should be populated except for name, which is set when
- * inserting it in the callback.
- * dxpl_id is the dxpl ID that needs to be used during writes and reads.
- * path is a pointer to the path of the object being inserted if this is
+ * LC_PLIST is a pointer to the link creation property list.
+ * DXPL_ID is the dxpl ID that needs to be used during writes and reads.
+ * PATH is a pointer to the path of the object being inserted if this is
* a hard link; this is used to set the paths to objects when they are
* created. For other link types, this is NULL.
+ * OCRT_INFO is a pointer to the structure for object creation.
+ * LNK is the link struct passed into this function. At this point all
+ * of its fields should be populated except for name, which is set when
+ * inserting it in the callback.
*/
udata.file = obj_file;
- udata.lnk = lnk;
+ udata.lc_plist = lc_plist;
udata.dxpl_id = dxpl_id;
udata.path = obj_path;
+ udata.ocrt_info = ocrt_info;
+ udata.lnk = lnk;
/* Traverse the destination path & create new link */
if(H5G_traverse(link_loc, link_name, target_flags, H5L_link_cb, &udata, lapl_id, dxpl_id) < 0)
@@ -1680,8 +1747,8 @@ done:
*/
herr_t
H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name,
- H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id, hid_t lapl_id,
- hid_t dxpl_id)
+ const H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id,
+ hid_t lapl_id, hid_t dxpl_id)
{
char *norm_cur_name = NULL; /* Pointer to normalized current name */
H5F_t *link_file = NULL; /* Pointer to file to link to */
@@ -1696,8 +1763,8 @@ H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name,
/* Check args */
HDassert(cur_loc);
- HDassert(link_loc);
HDassert(cur_name && *cur_name);
+ HDassert(link_loc);
HDassert(link_name && *link_name);
/* Get normalized copy of the current name */
@@ -1723,7 +1790,7 @@ H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name,
/* Create actual link to the object. Pass in NULL for the path, since this
* function shouldn't change an object's user path. */
- if(H5L_create_real(link_loc, link_name, NULL, link_file, &lnk, lcpl_id, lapl_id, dxpl_id) < 0)
+ if(H5L_create_real(link_loc, link_name, NULL, link_file, &lnk, NULL, lcpl_id, lapl_id, dxpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object")
done:
@@ -1753,7 +1820,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5L_create_soft(const char *target_path, H5G_loc_t *link_loc,
+H5L_create_soft(const char *target_path, const H5G_loc_t *link_loc,
const char *link_name, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id)
{
char *norm_target = NULL; /* Pointer to normalized current name */
@@ -1776,7 +1843,7 @@ H5L_create_soft(const char *target_path, H5G_loc_t *link_loc,
lnk.u.soft.name = norm_target;
/* Create actual link to the object */
- if(H5L_create_real(link_loc, link_name, NULL, NULL, &lnk, lcpl_id, lapl_id, dxpl_id) < 0)
+ if(H5L_create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id, lapl_id, dxpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object")
done:
@@ -1802,9 +1869,9 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5L_create_ud(H5G_loc_t *link_loc, const char *link_name, const void *ud_data,
- size_t ud_data_size, H5L_type_t type, hid_t lcpl_id, hid_t lapl_id,
- hid_t dxpl_id)
+H5L_create_ud(const H5G_loc_t *link_loc, const char *link_name,
+ const void *ud_data, size_t ud_data_size, H5L_type_t type, hid_t lcpl_id,
+ hid_t lapl_id, hid_t dxpl_id)
{
H5O_link_t lnk; /* Link to insert */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1836,7 +1903,7 @@ H5L_create_ud(H5G_loc_t *link_loc, const char *link_name, const void *ud_data,
lnk.type = type;
/* Create actual link to the object */
- if(H5L_create_real(link_loc, link_name, NULL, NULL, &lnk, lcpl_id, lapl_id, dxpl_id) < 0)
+ if(H5L_create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id, lapl_id, dxpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to register new name for object")
done:
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c
index d920f64..d6053b7 100644
--- a/src/H5Lexternal.c
+++ b/src/H5Lexternal.c
@@ -436,7 +436,7 @@ H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size,
/* We're now guaranteed that HDstrlen won't segfault, since the buffer has
* at least one NULL in it.
*/
- len = HDstrlen(ext_linkval + 1);
+ len = HDstrlen((const char *)ext_linkval + 1);
/* If the first NULL we found was at the very end of the buffer, then
* this external link value has no object name and is invalid.
@@ -449,9 +449,9 @@ H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size,
* filename and object path.
*/
if(filename)
- *filename = ext_linkval + 1;
+ *filename = (const char *)ext_linkval + 1;
if(obj_path)
- *obj_path = (ext_linkval + 1) + len + 1; /* Add one for NULL terminator */
+ *obj_path = ((const char *)ext_linkval + 1) + len + 1; /* Add one for NULL terminator */
/* Set the flags to return */
if(flags)
diff --git a/src/H5Lpkg.h b/src/H5Lpkg.h
index 14e9239..e02a871 100644
--- a/src/H5Lpkg.h
+++ b/src/H5Lpkg.h
@@ -53,7 +53,7 @@
/* Package Private Prototypes */
/******************************/
-H5_DLL herr_t H5L_create_ud(H5G_loc_t *link_loc, const char *link_name,
+H5_DLL herr_t H5L_create_ud(const H5G_loc_t *link_loc, const char *link_name,
const void * ud_data, size_t ud_data_size, H5L_type_t type,
hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id);
diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h
index 15e63b4..6d3811e 100644
--- a/src/H5Lprivate.h
+++ b/src/H5Lprivate.h
@@ -27,6 +27,7 @@
#include "H5Gprivate.h" /* Groups */
#include "H5Oprivate.h" /* Object headers */
+
/**************************/
/* Library Private Macros */
/**************************/
@@ -41,6 +42,7 @@
#define H5L_ACS_NLINKS_NAME "max soft links" /* Number of soft links to traverse */
#define H5L_ACS_ELINK_PREFIX_NAME "external link prefix" /* External link prefix */
+
/****************************/
/* Library Private Typedefs */
/****************************/
@@ -57,12 +59,14 @@
/* General operations on links */
H5_DLL herr_t H5L_init(void);
-H5_DLL herr_t H5L_link(H5G_loc_t *new_loc, const char *new_name,
+H5_DLL herr_t H5L_link(const H5G_loc_t *new_loc, const char *new_name,
H5G_loc_t *obj_loc, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id);
+H5_DLL herr_t H5L_link_object(const H5G_loc_t *new_loc, const char *new_name,
+ H5O_obj_create_t *ocrt_info, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id);
H5_DLL herr_t H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name,
- H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id,
+ const H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id,
hid_t lapl_id, hid_t dxpl_id);
-H5_DLL herr_t H5L_create_soft(const char *target_path, H5G_loc_t *cur_loc,
+H5_DLL herr_t H5L_create_soft(const char *target_path, const H5G_loc_t *cur_loc,
const char *cur_name, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id);
H5_DLL hid_t H5L_get_default_lcpl(void);
H5_DLL herr_t H5L_move(H5G_loc_t *src_loc, const char *src_name,
diff --git a/src/H5O.c b/src/H5O.c
index f02a7f5..2bb7505 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -2086,3 +2086,51 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_get_nlinks() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_obj_create
+ *
+ * Purpose: Creates an object, in an abstract manner.
+ *
+ * Return: Success: Pointer to object opened
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * April 9 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc,
+ hid_t dxpl_id)
+{
+ size_t u; /* Local index variable */
+ void *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_obj_create, NULL)
+
+ /* Sanity checks */
+ HDassert(f);
+ HDassert(obj_type >= H5O_TYPE_GROUP && obj_type <= H5O_TYPE_NAMED_DATATYPE);
+ HDassert(crt_info);
+ HDassert(obj_loc);
+
+ /* Iterate through the object classes */
+ for(u = 0; u < NELMTS(H5O_obj_class_g); u++) {
+ /* Check for correct type of object to create */
+ if(H5O_obj_class_g[u]->type == obj_type) {
+ /* Call the object class's 'create' routine */
+ HDassert(H5O_obj_class_g[u]->create);
+ if(NULL == (ret_value = H5O_obj_class_g[u]->create(f, crt_info, obj_loc, dxpl_id)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object")
+
+ /* Break out of loop */
+ break;
+ } /* end if */
+ } /* end for */
+ HDassert(ret_value);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_obj_create() */
+
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 0fc1aa6..067e36c 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -290,6 +290,7 @@ typedef struct H5O_obj_class_t {
void (*free_copy_file_udata)(void *); /*free user data for 'copy file' operation */
htri_t (*isa)(H5O_t *); /*if a header matches an object class */
hid_t (*open)(const H5G_loc_t *, hid_t ); /*open an object of this class */
+ void *(*create)(H5F_t *, void *, H5G_loc_t *, hid_t ); /*create an object of this class */
H5O_loc_t *(*get_oloc)(hid_t ); /*get the object header location for an object */
} H5O_obj_class_t;
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 2bfe8ef..f904c4c 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -442,6 +442,13 @@ typedef uint32_t H5O_refcount_t;
typedef herr_t (*H5O_operator_t)(const void *mesg/*in*/, unsigned idx,
void *operator_data/*in,out*/);
+/* Typedef for abstract object creation */
+typedef struct {
+ H5O_type_t obj_type; /* Type of object to create */
+ void *crt_info; /* Information for object creation callback */
+ void *new_obj; /* Pointer to new object created */
+} H5O_obj_create_t;
+
/* Forward declarations for prototype arguments */
struct H5P_genplist_t;
@@ -467,6 +474,7 @@ H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxp
H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, hid_t dxpl_id, struct H5P_genplist_t *oc_plist);
H5_DLL hid_t H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id);
H5_DLL herr_t H5O_get_nlinks(const H5O_loc_t *loc, hid_t dxpl_id, hsize_t *nlinks);
+H5_DLL void *H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id);
/* Object header message routines */
H5_DLL herr_t H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags,
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index 684b9ff..1959aa5 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -26,17 +26,13 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free Lists */
#include "H5FOprivate.h" /* File objects */
#include "H5Iprivate.h" /* IDs */
#include "H5Lprivate.h" /* Links */
-#include "H5Oprivate.h" /* Object headers */
#include "H5Pprivate.h" /* Property lists */
#include "H5Tpkg.h" /* Datatypes */
/* Static local functions */
-static herr_t H5T_commit(H5F_t *file, H5T_t *type,
- hid_t dxpl_id, hid_t tcpl_id, hid_t tapl_id);
static H5T_t *H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id);
@@ -63,35 +59,27 @@ H5T_init_commit_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5Tcommit
+ * Function: H5Tcommit2
*
* Purpose: Save a transient datatype to a file and turn the type handle
- * into a named, immutable type.
+ * into a "named", immutable type.
*
* Return: Non-negative on success/Negative on failure
*
- * Programmer: Robb Matzke
- * Monday, June 1, 1998
+ * Programmer: Quincey Koziol
+ * April 5, 2007
*
*-------------------------------------------------------------------------
*/
herr_t
-H5Tcommit(hid_t loc_id, const char *name, hid_t type_id)
+H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id,
+ hid_t tcpl_id, hid_t tapl_id)
{
- H5G_loc_t loc;
- H5G_loc_t type_loc;
- H5G_loc_t insertion_loc; /* Loc of group in which to create object */
- H5G_name_t insert_path; /* Path of group in which to create object */
- H5O_loc_t insert_oloc; /* oloc of group in which to create object */
- hbool_t insert_loc_valid = FALSE; /* Is insertion_loc valid? */
- H5F_t *file = NULL;
- H5T_t *type = NULL;
- hbool_t uncommit = FALSE; /* TRUE if H5T_commit needs to be undone */
- H5T_state_t old_state = H5T_STATE_TRANSIENT; /* The state of the datatype before H5T_commit. */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5G_loc_t loc; /* Location to create datatype */
+ H5T_t *type; /* Datatype for ID */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Tcommit, FAIL)
- H5TRACE3("e", "i*si", loc_id, name, type_id);
+ FUNC_ENTER_API(H5Tcommit2, FAIL)
/* Check arguments */
if(H5G_loc(loc_id, &loc) < 0)
@@ -101,64 +89,120 @@ H5Tcommit(hid_t loc_id, const char *name, hid_t type_id)
if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- /* What file is the datatype being added to? */
- insertion_loc.path = &insert_path;
- insertion_loc.oloc = &insert_oloc;
- H5G_loc_reset(&insertion_loc);
- if(H5G_insertion_loc(&loc, name, &insertion_loc, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to locate insertion point")
- insert_loc_valid = TRUE;
- file = insertion_loc.oloc->file;
+ /* Get correct property list */
+ if(H5P_DEFAULT == lcpl_id)
+ lcpl_id = H5P_LINK_CREATE_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list")
- /* Record the type's state so that we can revert to it if linking fails */
- old_state = type->shared->state;
+ /* Get correct property list */
+ if(H5P_DEFAULT == tcpl_id)
+ tcpl_id = H5P_DATATYPE_CREATE_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list")
+
+ /* Get correct property list */
+ if(H5P_DEFAULT == tapl_id)
+ tapl_id = H5P_DATATYPE_ACCESS_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list")
- /* Write the type to disk */
- if(H5T_commit(file, type, H5AC_dxpl_id, H5P_DATATYPE_CREATE_DEFAULT, H5P_DEFAULT) < 0)
+ /* Commit the type */
+ if(H5T_commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
- /* Get the group location for the newly committed datatype */
- if(H5G_loc(type_id, &type_loc) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get committed datatype's location")
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Tcommit2() */
- /* Link the type into the group hierarchy */
- if(H5L_link(&loc, name, &type_loc, H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0) {
- uncommit = TRUE; /* Linking failed, and we need to undo H5T_commit. */
- HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link to type")
- } /* end if */
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_commit_named
+ *
+ * Purpose: Internal routine to save a transient datatype to a file and
+ * turn the type ID into a "named", immutable type.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * April 5, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt,
+ hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id)
+{
+ H5O_obj_create_t ocrt_info; /* Information for object creation */
+ H5T_obj_create_t tcrt_info; /* Information for named datatype creation */
+ H5T_state_t old_state; /* The state of the datatype before H5T_commit. */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5T_commit_named, FAIL)
+
+ /* Sanity checks */
+ HDassert(loc);
+ HDassert(name && *name);
+ HDassert(dt);
+ HDassert(lcpl_id != H5P_DEFAULT);
+ HDassert(tcpl_id != H5P_DEFAULT);
+ HDassert(tapl_id != H5P_DEFAULT);
+ HDassert(dxpl_id != H5P_DEFAULT);
+
+ /* Record the type's state so that we can revert to it if linking fails */
+ old_state = dt->shared->state;
+
+ /* Set up named datatype creation info */
+ tcrt_info.dt = dt;
+ tcrt_info.tcpl_id = tcpl_id;
+
+ /* Set up object creation information */
+ ocrt_info.obj_type = H5O_TYPE_NAMED_DATATYPE;
+ ocrt_info.crt_info = &tcrt_info;
+ ocrt_info.new_obj = NULL;
+
+ /* Create the new named datatype and link it to its parent group */
+ if(H5L_link_object(loc, name, &ocrt_info, lcpl_id, tapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create and link to named datatype")
+ HDassert(ocrt_info.new_obj);
done:
- if(insert_loc_valid)
- if(H5G_loc_free(&insertion_loc) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to free location")
-
- /* If the datatype was committed but couldn't be linked, we need to return it to the state it was in
- * before it was committed. */
- if(TRUE == uncommit) {
- if(type->shared->state == H5T_STATE_OPEN && type->sh_loc.flags & H5O_COMMITTED_FLAG) {
+ /* If the datatype was committed but something failed after that, we need
+ * to return it to the state it was in before it was committed.
+ */
+ if(ret_value < 0 && ocrt_info.new_obj) {
+ if(dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.flags & H5O_COMMITTED_FLAG) {
/* Remove the datatype from the list of opened objects in the file */
- if(H5FO_top_decr(type->sh_loc.u.oloc.file, type->sh_loc.u.oloc.addr) < 0)
+ if(H5FO_top_decr(dt->sh_loc.u.oloc.file, dt->sh_loc.u.oloc.addr) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
- if(H5FO_delete(type->sh_loc.u.oloc.file, H5AC_dxpl_id, type->sh_loc.u.oloc.addr) < 0)
+ if(H5FO_delete(dt->sh_loc.u.oloc.file, dxpl_id, dt->sh_loc.u.oloc.addr) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects")
- if(H5O_close(&(type->sh_loc.u.oloc)) < 0)
+
+ /* Close the datatype object */
+ if(H5O_close(&(dt->sh_loc.u.oloc)) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header")
- if(H5O_delete(file, H5AC_dxpl_id, type->sh_loc.u.oloc.addr) < 0)
+
+ /* Remove the datatype's object header from the file */
+ if(H5O_delete(dt->sh_loc.u.oloc.file, dxpl_id, dt->sh_loc.u.oloc.addr) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header")
+
/* Mark datatype as being back in memory */
- if(H5T_set_loc(type, file, H5T_LOC_MEMORY))
+ if(H5T_set_loc(dt, dt->sh_loc.u.oloc.file, H5T_LOC_MEMORY))
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to return datatype to memory")
- type->sh_loc.flags = H5O_NOT_SHARED;
- type->shared->state = old_state;
+ dt->sh_loc.flags = H5O_NOT_SHARED;
+ dt->shared->state = old_state;
} /* end if */
} /* end if */
- FUNC_LEAVE_API(ret_value)
-} /* end H5Tcommit() */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_commit_named() */
/*-------------------------------------------------------------------------
- * Function: H5Tcommit_expand
+ * Function: H5Tcommit_anon
*
* Purpose: Save a transient datatype to a file and turn the type handle
* into a "named", immutable type.
@@ -166,6 +210,9 @@ done:
* The resulting ID should be linked into the file with
* H5Llink or it will be deleted when closed.
*
+ * Note: Datatype access property list is unused currently, but is
+ * checked for sanity anyway.
+ *
* Return: Non-negative on success/Negative on failure
*
* Programmer: Peter Cao
@@ -174,13 +221,13 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Tcommit_expand(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id)
+H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id)
{
H5G_loc_t loc;
H5T_t *type = NULL;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Tcommit_expand, FAIL)
+ FUNC_ENTER_API(H5Tcommit_anon, FAIL)
H5TRACE4("e", "iiii", loc_id, type_id, tcpl_id, tapl_id);
/* Check arguments */
@@ -194,7 +241,7 @@ H5Tcommit_expand(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id)
tcpl_id = H5P_DATATYPE_CREATE_DEFAULT;
else
if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype create property list")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list")
/* Get correct property list */
if(H5P_DEFAULT == tapl_id)
@@ -204,12 +251,12 @@ H5Tcommit_expand(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list")
/* Commit the type */
- if(H5T_commit(loc.oloc->file, type, H5AC_dxpl_id, tcpl_id, tapl_id) < 0)
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+ if(H5T_commit(loc.oloc->file, type, tcpl_id, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Tcommit_expand() */
+} /* end H5Tcommit_anon() */
/*-------------------------------------------------------------------------
@@ -225,8 +272,8 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id, hid_t tcpl_id, hid_t UNUSED tapl_id)
+herr_t
+H5T_commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id)
{
H5O_loc_t temp_oloc; /* Temporary object header location */
H5G_name_t temp_path; /* Temporary path */
@@ -239,9 +286,6 @@ H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id, hid_t tcpl_id, hid_t UNUSED
HDassert(file);
HDassert(type);
HDassert(tcpl_id != H5P_DEFAULT);
-#ifdef LATER
- HDassert(tapl_id != H5P_DEFAULT);
-#endif /* LATER */
/*
* Check arguments. We cannot commit an immutable type because H5Tclose()
@@ -307,11 +351,10 @@ H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id, hid_t tcpl_id, hid_t UNUSED
done:
if(ret_value < 0) {
- if(loc_init)
- {
+ if(loc_init) {
H5O_loc_free(&temp_oloc);
H5G_name_free(&temp_path);
- }
+ } /* end if */
if((type->shared->state == H5T_STATE_TRANSIENT || type->shared->state == H5T_STATE_RDONLY) && (type->sh_loc.flags & H5O_COMMITTED_FLAG)) {
if(H5O_close(&(type->sh_loc.u.oloc)) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header")
@@ -419,84 +462,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Topen
- *
- * Purpose: Opens a named datatype.
- *
- * Return: Success: Object ID of the named datatype.
- *
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * Monday, June 1, 1998
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-H5Topen(hid_t loc_id, const char *name)
-{
- H5T_t *type = NULL;
- H5G_loc_t loc;
- H5G_name_t path; /* Datatype group hier. path */
- H5O_loc_t oloc; /* Datatype object location */
- H5O_type_t obj_type; /* Type of object at location */
- H5G_loc_t type_loc; /* Group object for datatype */
- hbool_t obj_found = FALSE; /* Object at 'name' found */
- hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */
- hid_t ret_value = FAIL;
-
- FUNC_ENTER_API(H5Topen, FAIL)
- H5TRACE2("i", "i*s", loc_id, name);
-
- /* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
-
- /* Set up datatype location to fill in */
- type_loc.oloc = &oloc;
- type_loc.path = &path;
- H5G_loc_reset(&type_loc);
-
- /*
- * Find the named datatype object header and read the datatype message
- * from it.
- */
- if(H5G_loc_find(&loc, name, &type_loc/*out*/, H5P_DEFAULT, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found")
- obj_found = TRUE;
-
- /* Check that the object found is the correct type */
- if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_NAMED_DATATYPE)
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype")
-
- /* Open it */
- if((type = H5T_open(&type_loc, dxpl_id)) == NULL)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype")
-
- /* Register the type and return the ID */
- if((ret_value = H5I_register(H5I_DATATYPE, type)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named datatype")
-
-done:
- if(ret_value < 0) {
- if(type != NULL)
- H5T_close(type);
- else {
- if(obj_found && H5F_addr_defined(type_loc.oloc->addr))
- H5G_loc_free(&type_loc);
- } /* end else */
- } /* end if */
-
- FUNC_LEAVE_API(ret_value)
-} /* end H5Topen() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5Topen_expand
+ * Function: H5Topen2
*
* Purpose: Opens a named datatype using a Datatype Access Property
* List.
@@ -510,7 +476,7 @@ done:
*-------------------------------------------------------------------------
*/
hid_t
-H5Topen_expand(hid_t loc_id, const char *name, hid_t tapl_id)
+H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id)
{
H5T_t *type = NULL;
H5G_loc_t loc;
@@ -522,7 +488,7 @@ H5Topen_expand(hid_t loc_id, const char *name, hid_t tapl_id)
hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */
hid_t ret_value = FAIL;
- FUNC_ENTER_API(H5Topen_expand, FAIL)
+ FUNC_ENTER_API(H5Topen2, FAIL)
H5TRACE3("i", "i*si", loc_id, name, tapl_id);
/* Check args */
@@ -576,7 +542,7 @@ done:
} /* end if */
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Topen2() */
/*-------------------------------------------------------------------------
@@ -643,10 +609,9 @@ H5Tget_create_plist(hid_t dtype_id)
ret_value = new_tcpl_id;
done:
- if(ret_value < 0) {
+ if(ret_value < 0)
if(new_tcpl_id > 0)
(void)H5I_dec_ref(new_tcpl_id);
- } /* end if */
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_create_plist() */
@@ -806,10 +771,9 @@ H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id)
ret_value = dt;
done:
- if(ret_value == NULL) {
+ if(ret_value == NULL)
if(dt == NULL)
H5O_close(loc->oloc);
- } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_open_oid() */
diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c
new file mode 100644
index 0000000..63a576f
--- /dev/null
+++ b/src/H5Tdeprec.c
@@ -0,0 +1,223 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5Tdeprec.c
+ * April 5 2007
+ * Quincey Koziol <koziol@hdfgroup.org>
+ *
+ * Purpose: Deprecated functions from the H5T interface. These
+ * functions are here for compatibility purposes and may be
+ * removed in the future. Applications should switch to the
+ * newer APIs.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#define H5T_PACKAGE /*suppress error about including H5Tpkg */
+
+/* Interface initialization */
+#define H5_INTERFACE_INIT_FUNC H5T_init_deprec_interface
+
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FOprivate.h" /* File objects */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Tpkg.h" /* Datatypes */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Package Typedefs */
+/********************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+
+
+/*--------------------------------------------------------------------------
+NAME
+ H5T_init_deprec_interface -- Initialize interface-specific information
+USAGE
+ herr_t H5T_init_deprec_interface()
+RETURNS
+ Non-negative on success/Negative on failure
+DESCRIPTION
+ Initializes any interface-specific data or routines. (Just calls
+ H5T_init() currently).
+
+--------------------------------------------------------------------------*/
+static herr_t
+H5T_init_deprec_interface(void)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_deprec_interface)
+
+ FUNC_LEAVE_NOAPI(H5T_init())
+} /* H5T_init_deprec_interface() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tcommit
+ *
+ * Purpose: Save a transient datatype to a file and turn the type handle
+ * into a named, immutable type.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * Monday, June 1, 1998
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Tcommit(hid_t loc_id, const char *name, hid_t type_id)
+{
+ H5G_loc_t loc; /* Location to create datatype */
+ H5T_t *type; /* Datatype for ID */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(H5Tcommit, FAIL)
+ H5TRACE3("e", "i*si", loc_id, name, type_id);
+
+ /* Check arguments */
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+
+ /* Commit the datatype to the file, using default property list values */
+ if(H5T_commit_named(&loc, name, type, H5P_LINK_CREATE_DEFAULT,
+ H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Tcommit() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Topen
+ *
+ * Purpose: Opens a named datatype.
+ *
+ * Return: Success: Object ID of the named datatype.
+ *
+ * Failure: Negative
+ *
+ * Programmer: Robb Matzke
+ * Monday, June 1, 1998
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Topen(hid_t loc_id, const char *name)
+{
+ H5T_t *type = NULL;
+ H5G_loc_t loc;
+ H5G_name_t path; /* Datatype group hier. path */
+ H5O_loc_t oloc; /* Datatype object location */
+ H5O_type_t obj_type; /* Type of object at location */
+ H5G_loc_t type_loc; /* Group object for datatype */
+ hbool_t obj_found = FALSE; /* Object at 'name' found */
+ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_API(H5Topen, FAIL)
+ H5TRACE2("i", "i*s", loc_id, name);
+
+ /* Check args */
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+
+ /* Set up datatype location to fill in */
+ type_loc.oloc = &oloc;
+ type_loc.path = &path;
+ H5G_loc_reset(&type_loc);
+
+ /*
+ * Find the named datatype object header and read the datatype message
+ * from it.
+ */
+ if(H5G_loc_find(&loc, name, &type_loc/*out*/, H5P_DEFAULT, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found")
+ obj_found = TRUE;
+
+ /* Check that the object found is the correct type */
+ if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object type")
+ if(obj_type != H5O_TYPE_NAMED_DATATYPE)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype")
+
+ /* Open it */
+ if((type = H5T_open(&type_loc, dxpl_id)) == NULL)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype")
+
+ /* Register the type and return the ID */
+ if((ret_value = H5I_register(H5I_DATATYPE, type)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named datatype")
+
+done:
+ if(ret_value < 0) {
+ if(type != NULL)
+ H5T_close(type);
+ else {
+ if(obj_found && H5F_addr_defined(type_loc.oloc->addr))
+ H5G_loc_free(&type_loc);
+ } /* end else */
+ } /* end if */
+
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Topen() */
+
diff --git a/src/H5Toh.c b/src/H5Toh.c
index 2c952e1..6e851f6 100644
--- a/src/H5Toh.c
+++ b/src/H5Toh.c
@@ -18,6 +18,8 @@
/****************/
#define H5O_PACKAGE /*suppress error about including H5Opkg */
+#define H5T_PACKAGE /*suppress error about including H5Tpkg */
+
/***********/
/* Headers */
@@ -26,6 +28,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5Opkg.h" /* Object headers */
+#include "H5Tpkg.h" /* Datatypes */
/****************/
@@ -44,6 +47,8 @@
static htri_t H5O_dtype_isa(H5O_t *loc);
static hid_t H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t dxpl_id);
+static void *H5O_dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc,
+ hid_t dxpl_id);
static H5O_loc_t *H5O_dtype_get_oloc(hid_t obj_id);
@@ -69,6 +74,7 @@ const H5O_obj_class_t H5O_OBJ_DATATYPE[1] = {{
NULL, /* free 'copy file' user data */
H5O_dtype_isa, /* "isa" */
H5O_dtype_open, /* open an object of this class */
+ H5O_dtype_create, /* create an object of this class */
H5O_dtype_get_oloc /* get an object header location for an object */
}};
@@ -131,8 +137,8 @@ H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t dxpl_id)
HDassert(obj_loc);
/* Open the datatype */
- if((type = H5T_open(obj_loc, dxpl_id)) == NULL)
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open datatype")
+ if(NULL == (type = H5T_open(obj_loc, dxpl_id)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open datatype")
/* Register an ID for the datatype */
if((ret_value = H5I_register(H5I_DATATYPE, type)) < 0)
@@ -140,14 +146,58 @@ H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t dxpl_id)
done:
if(ret_value < 0)
- if(type != NULL)
- H5T_close(type);
+ if(type && H5T_close(type) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release datatype")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_dtype_open() */
/*-------------------------------------------------------------------------
+ * Function: H5O_dtype_create
+ *
+ * Purpose: Create a named datatype in a file
+ *
+ * Return: Success: Pointer to the named datatype data structure
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, April 11, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5O_dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id)
+{
+ H5T_obj_create_t *crt_info = (H5T_obj_create_t *)_crt_info; /* Named datatype creation parameters */
+ void *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_create)
+
+ /* Sanity checks */
+ HDassert(f);
+ HDassert(crt_info);
+ HDassert(obj_loc);
+
+ /* Commit the type to the file */
+ if(H5T_commit(f, crt_info->dt, crt_info->tcpl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype")
+
+ /* Set up the new named datatype's location */
+ if(NULL == (obj_loc->oloc = H5T_oloc(crt_info->dt)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get object location of named datatype")
+ if(NULL == (obj_loc->path = H5T_nameof(crt_info->dt)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get path of named datatype")
+
+ /* Set the return value */
+ ret_value = crt_info->dt;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dtype_create() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_dtype_get_oloc
*
* Purpose: Retrieve the object header location for an open object
@@ -169,11 +219,11 @@ H5O_dtype_get_oloc(hid_t obj_id)
FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_get_oloc)
/* Get the datatype */
- if((type = H5I_object(obj_id)) == NULL)
+ if(NULL == (type = H5I_object(obj_id)))
HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID")
/* Get the datatype's object header location */
- if((ret_value = H5T_oloc(type)) == NULL)
+ if(NULL == (ret_value = H5T_oloc(type)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from object")
done:
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index dc16aa0..d7cd35d 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -355,6 +355,12 @@ typedef enum H5T_sdir_t {
H5T_BIT_MSB /*search msb toward lsb */
} H5T_sdir_t;
+/* Typedef for named datatype creation operation */
+typedef struct {
+ H5T_t *dt; /* Datatype to commit */
+ hid_t tcpl_id; /* Named datatype creation property list */
+} H5T_obj_create_t;
+
/*
* Alignment information for native types. A value of N indicates that the
* data must be aligned on an address ADDR such that 0 == ADDR mod N. When
@@ -446,6 +452,9 @@ H5FL_EXTERN(H5T_shared_t);
/* Common functions */
H5_DLL H5T_t *H5T_create(H5T_class_t type, size_t size);
+H5_DLL herr_t H5T_commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id);
+H5_DLL herr_t H5T_commit_named(const H5G_loc_t *loc, const char *name,
+ H5T_t *dt, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id);
H5_DLL H5T_t *H5T_alloc(void);
H5_DLL herr_t H5T_free(H5T_t *dt);
H5_DLL H5T_sign_t H5T_get_sign(H5T_t const *dt);
@@ -1330,4 +1339,5 @@ H5_DLL size_t H5T_get_member_offset(const H5T_t *dt, unsigned membno);
H5_DLL size_t H5T_get_member_size(const H5T_t *dt, unsigned membno);
H5_DLL htri_t H5T_is_packed(const H5T_t *dt);
-#endif
+#endif /* _H5Tpkg_H */
+
diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h
index b3ebcdd..1a1275d 100644
--- a/src/H5Tpublic.h
+++ b/src/H5Tpublic.h
@@ -497,15 +497,15 @@ H5_DLLVAR hid_t H5T_NATIVE_INT_FAST64_g;
H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST64_g;
/* Operations defined on all datatypes */
-H5_DLL hid_t H5Topen(hid_t loc_id, const char *name);
-H5_DLL hid_t H5Topen_expand(hid_t loc_id, const char *name, hid_t tapl_id);
H5_DLL hid_t H5Tcreate(H5T_class_t type, size_t size);
H5_DLL hid_t H5Tcopy(hid_t type_id);
H5_DLL herr_t H5Tclose(hid_t type_id);
H5_DLL htri_t H5Tequal(hid_t type1_id, hid_t type2_id);
H5_DLL herr_t H5Tlock(hid_t type_id);
-H5_DLL herr_t H5Tcommit(hid_t loc_id, const char *name, hid_t type_id);
-H5_DLL herr_t H5Tcommit_expand(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id);
+H5_DLL herr_t H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id,
+ hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id);
+H5_DLL hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id);
+H5_DLL herr_t H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id);
H5_DLL hid_t H5Tget_create_plist(hid_t type_id);
H5_DLL htri_t H5Tcommitted(hid_t type_id);
H5_DLL herr_t H5Tencode(hid_t obj_id, void *buf, size_t *nalloc);
@@ -592,7 +592,16 @@ H5_DLL htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id);
H5_DLL herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts,
void *buf, void *background, hid_t plist_id);
+/* Functions and variables defined for compatibility with previous versions
+ * of the HDF5 API.
+ *
+ * Use of these functions and variables is deprecated.
+ */
+H5_DLL hid_t H5Topen(hid_t loc_id, const char *name);
+H5_DLL herr_t H5Tcommit(hid_t loc_id, const char *name, hid_t type_id);
+
#ifdef __cplusplus
}
#endif
-#endif
+#endif /* _H5Tpublic_H */
+
diff --git a/src/Makefile.am b/src/Makefile.am
index ced4713..7a2f3df 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,7 +45,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5A.c H5Abtree2.c H5Adense.c H5Adeprec.c H5Aint.c H5Atest.c \
H5AC.c H5B.c H5Bcache.c \
H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2stat.c H5B2test.c \
- H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c \
+ H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c H5Ddeprec.c \
H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \
H5E.c \
H5F.c H5Fdbg.c H5Ffake.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5Ftest.c \
@@ -53,7 +53,8 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5FDdirect.c H5FDfamily.c H5FDlog.c H5FDmpi.c H5FDmpio.c \
H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDstdio.c \
H5FDstream.c H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSsection.c \
- H5G.c H5Gbtree2.c H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c H5Glink.c \
+ H5G.c H5Gbtree2.c H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c \
+ H5Gint.c H5Glink.c \
H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Gstab.c H5Gtest.c \
H5Gtraverse.c \
H5HF.c H5HFbtree2.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c \
@@ -77,7 +78,8 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5RS.c H5S.c H5Sall.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \
H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \
H5SMcache.c H5SMtest.c H5ST.c H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c \
- H5Tcompound.c H5Tconv.c H5Tcset.c H5Tenum.c H5Tfields.c H5Tfixed.c \
+ H5Tcompound.c H5Tconv.c H5Tcset.c H5Tdeprec.c H5Tenum.c H5Tfields.c \
+ H5Tfixed.c \
H5Tfloat.c H5Tinit.c H5Tnative.c H5Toffset.c H5Toh.c H5Topaque.c \
H5Torder.c \
H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvlen.c H5TS.c H5V.c H5Z.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index 14972d9..017283b 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -83,14 +83,14 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \
H5Adeprec.lo H5Aint.lo H5Atest.lo H5AC.lo H5B.lo H5Bcache.lo \
H5B2.lo H5B2cache.lo H5B2dbg.lo H5B2int.lo H5B2stat.lo \
H5B2test.lo H5C.lo H5CS.lo H5D.lo H5Dcompact.lo H5Dcontig.lo \
- H5Defl.lo H5Dio.lo H5Distore.lo H5Dmpio.lo H5Doh.lo \
+ H5Ddeprec.lo H5Defl.lo H5Dio.lo H5Distore.lo H5Dmpio.lo H5Doh.lo \
H5Dselect.lo H5Dtest.lo H5E.lo H5F.lo H5Fdbg.lo H5Ffake.lo \
H5Fmount.lo H5Fsfile.lo H5Fsuper.lo H5Ftest.lo H5FD.lo \
H5FDcore.lo H5FDdirect.lo H5FDfamily.lo H5FDlog.lo H5FDmpi.lo \
H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo H5FDsec2.lo \
H5FDstdio.lo H5FDstream.lo H5FL.lo H5FO.lo H5FS.lo \
H5FScache.lo H5FSdbg.lo H5FSsection.lo H5G.lo H5Gbtree2.lo \
- H5Gcompact.lo H5Gdense.lo H5Gdeprec.lo H5Gent.lo H5Glink.lo \
+ H5Gcompact.lo H5Gdense.lo H5Gdeprec.lo H5Gent.lo H5Gint.lo H5Glink.lo \
H5Gloc.lo H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo H5Gstab.lo \
H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFbtree2.lo H5HFcache.lo \
H5HFdbg.lo H5HFdblock.lo H5HFdtable.lo H5HFhdr.lo H5HFhuge.lo \
@@ -110,7 +110,7 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \
H5S.lo H5Sall.lo H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo \
H5Sselect.lo H5Stest.lo H5SL.lo H5SM.lo H5SMbtree2.lo \
H5SMcache.lo H5SMtest.lo H5ST.lo H5T.lo H5Tarray.lo H5Tbit.lo \
- H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo H5Tenum.lo \
+ H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo H5Tdeprec.lo H5Tenum.lo \
H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo \
H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo \
H5Tprecis.lo H5Tstrpad.lo H5Tvlen.lo H5TS.lo H5V.lo H5Z.lo \
@@ -394,7 +394,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5A.c H5Abtree2.c H5Adense.c H5Adeprec.c H5Aint.c H5Atest.c \
H5AC.c H5B.c H5Bcache.c \
H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2stat.c H5B2test.c \
- H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c \
+ H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c H5Ddeprec.c \
H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \
H5E.c \
H5F.c H5Fdbg.c H5Ffake.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5Ftest.c \
@@ -402,7 +402,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5FDdirect.c H5FDfamily.c H5FDlog.c H5FDmpi.c H5FDmpio.c \
H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDstdio.c \
H5FDstream.c H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSsection.c \
- H5G.c H5Gbtree2.c H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c H5Glink.c \
+ H5G.c H5Gbtree2.c H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c H5Gint.c H5Glink.c \
H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Gstab.c H5Gtest.c \
H5Gtraverse.c \
H5HF.c H5HFbtree2.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c \
@@ -426,7 +426,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5RS.c H5S.c H5Sall.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \
H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \
H5SMcache.c H5SMtest.c H5ST.c H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c \
- H5Tcompound.c H5Tconv.c H5Tcset.c H5Tenum.c H5Tfields.c H5Tfixed.c \
+ H5Tcompound.c H5Tconv.c H5Tcset.c H5Tdeprec.c H5Tenum.c H5Tfields.c H5Tfixed.c \
H5Tfloat.c H5Tinit.c H5Tnative.c H5Toffset.c H5Toh.c H5Topaque.c \
H5Torder.c \
H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvlen.c H5TS.c H5V.c H5Z.c \
@@ -584,6 +584,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5D.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dcompact.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dcontig.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Ddeprec.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Defl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dio.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Distore.Plo@am__quote@
@@ -623,6 +624,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gdense.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gdeprec.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gent.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gint.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Glink.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gloc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gname.Plo@am__quote@
@@ -729,6 +731,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tcompound.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tconv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tcset.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tdeprec.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tenum.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tfields.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tfixed.Plo@am__quote@
diff --git a/test/links.c b/test/links.c
index 8b44494..ca0945c 100644
--- a/test/links.c
+++ b/test/links.c
@@ -727,16 +727,17 @@ test_h5l_create(hid_t fapl, hbool_t new_format)
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create and commit a datatype with no name */
- if((type_id =H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
- if(H5Tcommit_expand(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(! H5Tcommitted(type_id)) TEST_ERROR
+ if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if(H5Tcommit_anon(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(!H5Tcommitted(type_id)) TEST_ERROR
/* Create the dataspace */
dims[0] = H5L_DIM1;
dims[1] = H5L_DIM2;
- if((space_id=H5Screate_simple(2 ,dims, NULL)) < 0) TEST_ERROR
+ if((space_id = H5Screate_simple(2 ,dims, NULL)) < 0) TEST_ERROR
+
/* Create a dataset with no name using the committed datatype*/
- if ((dset_id = H5Dcreate_expand(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if ((dset_id = H5Dcreate_anon(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Verify that we can write to and read from the dataset */
/* Initialize the dataset */
@@ -757,7 +758,7 @@ test_h5l_create(hid_t fapl, hbool_t new_format)
TEST_ERROR
/* Create a group with no name*/
- if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Link nameless datatype into nameless group */
if(H5Llink(group_id, "datatype", type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
@@ -855,8 +856,7 @@ test_lcpl(hid_t fapl, hbool_t new_format)
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create and link a group with the default LCPL */
- if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, "/group", group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, "/group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Gclose(group_id) < 0) TEST_ERROR
/* Check that its character encoding is the default */
@@ -864,10 +864,9 @@ test_lcpl(hid_t fapl, hbool_t new_format)
if(linfo.cset != H5F_DEFAULT_CSET) TEST_ERROR
/* Create and commit a datatype with the default LCPL */
- if((type_id =H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
- if(H5Tcommit_expand(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Llink(file_id, "/type", type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Tclose(type_id) < 0) TEST_ERROR;
+ if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if(H5Tcommit2(file_id, "/type", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Tclose(type_id) < 0) TEST_ERROR
/* Check that its character encoding is the default */
if(H5Lget_info(file_id, "type", &linfo, H5P_DEFAULT) < 0) TEST_ERROR
@@ -879,8 +878,7 @@ test_lcpl(hid_t fapl, hbool_t new_format)
if((space_id=H5Screate_simple(2 ,dims, NULL)) < 0) TEST_ERROR
/* Create a dataset using the default LCPL */
- if ((dset_id = H5Dcreate_expand(file_id, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, "/dataset", dset_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((dset_id = H5Dcreate2(file_id, "/dataset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Dclose(dset_id) < 0) TEST_ERROR
/* Check that its character encoding is the default */
@@ -892,8 +890,7 @@ test_lcpl(hid_t fapl, hbool_t new_format)
if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR
/* Create and link a group with the new LCPL */
- if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, "/group2", group_id, lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, "/group2", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Gclose(group_id) < 0) TEST_ERROR
/* Check that its character encoding is UTF-8 */
@@ -901,18 +898,16 @@ test_lcpl(hid_t fapl, hbool_t new_format)
if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR
/* Create and commit a datatype with the new LCPL */
- if((type_id =H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
- if(H5Tcommit_expand(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Llink(file_id, "/type2", type_id, lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR;
- if(H5Tclose(type_id) < 0) TEST_ERROR;
+ if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if(H5Tcommit2(file_id, "/type2", type_id, lcpl_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Tclose(type_id) < 0) TEST_ERROR
/* Check that its character encoding is UTF-8 */
if(H5Lget_info(file_id, "type2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR
if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR
/* Create a dataset using the new LCPL */
- if ((dset_id = H5Dcreate_expand(file_id, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, "/dataset2", dset_id, lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR
+ if((dset_id = H5Dcreate2(file_id, "/dataset2", H5T_NATIVE_INT, space_id, lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Dclose(dset_id) < 0) TEST_ERROR
/* Check that its character encoding is UTF-8 */
@@ -1336,8 +1331,7 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format)
if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR
/* Create a group with that lcpl */
- if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, "group", group_id, lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, "group", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Gclose(group_id) < 0) TEST_ERROR
/* Get the group's link's information */
@@ -2028,18 +2022,16 @@ external_link_self(hid_t fapl, hbool_t new_format)
h5_fixname(FILENAME[3], fapl, filename3, sizeof filename1);
/* Create file */
- if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create an lcpl with intermediate group creation set */
- if((lcpl_id=H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR
+ if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR
if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR
/* Create a series of groups within the file: /A/B and /X/Y/Z */
- if((gid=H5Gcreate_expand(fid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(fid, "A/B", gid, lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(fid, "A/B", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) TEST_ERROR
- if((gid=H5Gcreate_expand(fid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(fid, "X/Y", gid, lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(fid, "X/Y", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Pclose (lcpl_id) < 0) TEST_ERROR
@@ -3427,10 +3419,10 @@ external_link_closing(hid_t fapl, hbool_t new_format)
if(H5Tclose(tid) < 0) TEST_ERROR
if(H5Dclose(did) < 0) TEST_ERROR
- /* Test H5*open_expand */
- if((gid = H5Gopen_expand(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
- if((tid = H5Topen_expand(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
- if((did = H5Dopen_expand(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
+ /* Test H5*open2 */
+ if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
/* Close objects */
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Tclose(tid) < 0) TEST_ERROR
@@ -5064,20 +5056,20 @@ lapl_nlinks(hid_t fapl, hbool_t new_format)
/* Try to open the objects using too many symlinks with default *APLs */
H5E_BEGIN_TRY {
- if((gid = H5Gopen_expand(fid, "soft17", H5P_DEFAULT)) >=0) {
- H5_FAILED();
- puts(" Should have failed for too many nested links.");
- TEST_ERROR
+ if((gid = H5Gopen2(fid, "soft17", H5P_DEFAULT)) >=0) {
+ H5_FAILED();
+ puts(" Should have failed for too many nested links.");
+ TEST_ERROR
}
- if((tid = H5Topen_expand(fid, "soft17/datatype", H5P_DEFAULT)) >=0) {
- H5_FAILED();
- puts(" Should have failed for too many nested links.");
- TEST_ERROR
+ if((tid = H5Topen2(fid, "soft17/datatype", H5P_DEFAULT)) >=0) {
+ H5_FAILED();
+ puts(" Should have failed for too many nested links.");
+ TEST_ERROR
}
- if((did = H5Dopen_expand(fid, "soft17/dataset", H5P_DEFAULT)) >=0) {
- H5_FAILED();
- puts(" Should have failed for too many nested links.");
- TEST_ERROR
+ if((did = H5Dopen2(fid, "soft17/dataset", H5P_DEFAULT)) >=0) {
+ H5_FAILED();
+ puts(" Should have failed for too many nested links.");
+ TEST_ERROR
}
} H5E_END_TRY
@@ -5094,9 +5086,9 @@ lapl_nlinks(hid_t fapl, hbool_t new_format)
/* We should now be able to use these property lists to open each kind
* of object.
*/
- if((gid = H5Gopen_expand(fid, "soft17", gapl)) < 0) TEST_ERROR
- if((tid = H5Topen_expand(fid, "soft17/datatype", tapl)) < 0) TEST_ERROR
- if((did = H5Dopen_expand(fid, "soft17/dataset", dapl)) < 0) TEST_ERROR
+ if((gid = H5Gopen2(fid, "soft17", gapl)) < 0) TEST_ERROR
+ if((tid = H5Topen2(fid, "soft17/datatype", tapl)) < 0) TEST_ERROR
+ if((did = H5Dopen2(fid, "soft17/dataset", dapl)) < 0) TEST_ERROR
/* Close objects */
if(H5Gclose(gid) < 0) TEST_ERROR
@@ -5329,8 +5321,7 @@ corder_create_empty(hid_t fapl)
if(crt_order_flags != (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) TEST_ERROR
/* Create group with creation order indexing & tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check on group's status */
if(H5G_is_empty_test(group_id) != TRUE) TEST_ERROR
@@ -5423,8 +5414,7 @@ corder_create_compact(hid_t fapl)
if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR
/* Create group with creation order indexing & tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check on group's initial status */
if(H5G_is_empty_test(group_id) != TRUE) TEST_ERROR
@@ -5544,8 +5534,7 @@ corder_create_dense(hid_t fapl)
if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR
/* Create group with creation order indexing & tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check on group's initial status */
if(H5G_is_empty_test(group_id) != TRUE) TEST_ERROR
@@ -5688,8 +5677,7 @@ corder_transition(hid_t fapl)
if(H5Pset_est_link_info(gcpl_id, max_compact, CORDER_EST_ENTRY_LEN) < 0) TEST_ERROR
/* Create group with creation order indexing & tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Close the group creation property list */
if(H5Pclose(gcpl_id) < 0) FAIL_STACK_ERROR
@@ -5931,8 +5919,7 @@ corder_delete(hid_t fapl)
if(H5Pset_est_link_info(gcpl_id, max_compact, CORDER_EST_ENTRY_LEN) < 0) TEST_ERROR
/* Create group with creation order indexing & tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Close the group creation property list */
if(H5Pclose(gcpl_id) < 0) FAIL_STACK_ERROR
@@ -6213,8 +6200,7 @@ link_info_by_idx(hid_t fapl)
if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR
/* Create group with creation order indexing & tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Query the group creation properties */
if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR
@@ -6587,8 +6573,7 @@ delete_by_idx(hid_t fapl)
if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR
/* Create group with creation order tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Query the group creation properties */
if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR
@@ -7443,8 +7428,7 @@ link_iterate(hid_t fapl)
if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR
/* Create group with creation order tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check for iteration on empty group */
@@ -8135,12 +8119,10 @@ open_by_idx(hid_t fapl)
if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR
/* Create group with creation order tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create group with creation order tracking on for soft links */
- if((soft_group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Try to open on object in an empty group */
@@ -8322,12 +8304,10 @@ open_by_idx_old(hid_t fapl)
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create old-style group */
- if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create old-style group for soft links */
- if((soft_group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Try to open on object in an empty group */
@@ -8592,12 +8572,10 @@ object_info(hid_t fapl)
if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR
/* Create group with creation order tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create group with creation order tracking on for soft links */
- if((soft_group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check for out of bound query by index on empty group */
@@ -8791,12 +8769,10 @@ object_info_old(hid_t fapl)
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create old-style group */
- if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create old-style group for soft links */
- if((soft_group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check for out of bound query by index on empty group */
@@ -8985,12 +8961,10 @@ group_info(hid_t fapl)
if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR
/* Create group with creation order tracking on */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create group with creation order tracking on for soft links */
- if((soft_group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check for out of bound query by index on empty group */
@@ -9007,8 +8981,7 @@ group_info(hid_t fapl)
sprintf(objname, "filler %02u", u);
/* Create hard link, with group object */
- if((group_id2 = H5Gcreate_expand(group_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(group_id, objname, group_id2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Retrieve group's information */
if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR
@@ -9097,8 +9070,7 @@ group_info(hid_t fapl)
sprintf(objname, "filler %02u", u);
/* Create hard link, with group object */
- if((group_id2 = H5Gcreate_expand(group_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(group_id, objname, group_id2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Retrieve group's information */
if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR
@@ -9256,12 +9228,10 @@ group_info_old(hid_t fapl)
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create old-style group */
- if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create old-style group for soft links */
- if((soft_group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check for out of bound query by index on empty group */
@@ -9442,15 +9412,13 @@ timestamps(hid_t fapl)
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create group with non-default object timestamp setting */
- if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, TIMESTAMP_GROUP_1, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id = H5Gcreate2(file_id, TIMESTAMP_GROUP_1, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
/* Close the group creation property list */
if(H5Pclose(gcpl_id) < 0) TEST_ERROR
/* Create group with default object timestamp setting */
- if((group_id2 = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, TIMESTAMP_GROUP_2, group_id2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((group_id2 = H5Gcreate2(file_id, TIMESTAMP_GROUP_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Retrieve the new groups' creation properties */
if((gcpl_id = H5Gget_create_plist(group_id)) < 0) TEST_ERROR
diff --git a/test/stab.c b/test/stab.c
index 18940ff..f8ede62 100644
--- a/test/stab.c
+++ b/test/stab.c
@@ -374,8 +374,7 @@ lifecycle(hid_t fapl)
if(H5Pset_est_link_info(gcpl, LIFECYCLE_EST_NUM_ENTRIES, LIFECYCLE_EST_NAME_LEN) < 0) TEST_ERROR
/* Create group for testing lifecycle */
- if((gid = H5Gcreate_expand(fid, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR
- if((H5Llink(fid, LIFECYCLE_TOP_GROUP, gid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(fid, LIFECYCLE_TOP_GROUP, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR
/* Query group creation property settings */
if(H5Pget_local_heap_size_hint(gcpl, &lheap_size_hint) < 0) TEST_ERROR
@@ -850,8 +849,7 @@ no_compact(hid_t fapl)
if(est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) TEST_ERROR
/* Create group for testing no compact form */
- if((gid = H5Gcreate_expand(fid, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR
- if((H5Llink(fid, NO_COMPACT_TOP_GROUP, gid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(fid, NO_COMPACT_TOP_GROUP, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR
/* Close GCPL */
if(H5Pclose(gcpl) < 0) TEST_ERROR
@@ -988,8 +986,7 @@ gcpl_on_root(hid_t fapl)
if(H5Pset_create_intermediate_group(lcpl, TRUE) < 0) TEST_ERROR
/* Create a group and intermediate groups, to check if root group settings are inherited */
- if((gid2 = H5Gcreate_expand(gid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if((H5Llink(fid, GCPL_ON_ROOT_BOTTOM_GROUP, gid2, lcpl, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((gid2 = H5Gcreate2(gid, GCPL_ON_ROOT_BOTTOM_GROUP, lcpl, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Close LCPL */
if(H5Pclose(lcpl) < 0) TEST_ERROR
diff --git a/test/th5o.c b/test/th5o.c
index f01bc40..09ba28f 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -629,17 +629,17 @@ test_h5o_plist(void)
* using the respective type of creation property lists.
*/
- /* Create the group */
- grp = H5Gcreate_expand(fid, gcpl, H5P_DEFAULT);
- CHECK(grp, FAIL, "H5Gcreate_expand");
+ /* Create the group anonymously and link it in */
+ grp = H5Gcreate_anon(fid, gcpl, H5P_DEFAULT);
+ CHECK(grp, FAIL, "H5Gcreate_anon");
ret = H5Llink(fid, "group", grp, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Llink");
- /* Commit the type inside the group */
+ /* Commit the type inside the group anonymously and link it in */
dtype = H5Tcopy(H5T_NATIVE_INT);
CHECK(dtype, FAIL, "H5Tcopy");
- ret = H5Tcommit_expand(fid, dtype, tcpl, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Tcommit_expand");
+ ret = H5Tcommit_anon(fid, dtype, tcpl, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Tcommit_anon");
ret = H5Llink(fid, "datatype", dtype, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Llink");
@@ -647,9 +647,9 @@ test_h5o_plist(void)
dspace = H5Screate(H5S_SCALAR);
CHECK(dspace, FAIL, "H5Screate");
- /* Create the dataset. */
- dset = H5Dcreate_expand(fid, H5T_NATIVE_INT, dspace, dcpl, H5P_DEFAULT);
- CHECK(dset, FAIL, "H5Dcreate_expand");
+ /* Create the dataset anonymously and link it in */
+ dset = H5Dcreate_anon(fid, H5T_NATIVE_INT, dspace, dcpl, H5P_DEFAULT);
+ CHECK(dset, FAIL, "H5Dcreate_anon");
ret = H5Llink(fid, "dataset", dset, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Llink");
ret = H5Sclose(dspace);
diff --git a/test/tmisc.c b/test/tmisc.c
index bd37a32..f55028b 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -3843,7 +3843,7 @@ test_misc23(void)
CHECK(status, FAIL, "H5Dclose");
/**********************************************************************
- * test H5Gcreate_expand()
+ * test H5Gcreate2()
**********************************************************************/
/* Create link creation property list */
@@ -3855,11 +3855,8 @@ test_misc23(void)
CHECK(status, FAIL, "H5Pset_create_intermediate_group");
- tmp_id = H5Gcreate_expand(file_id, H5P_DEFAULT, access_id);
- CHECK(tmp_id, FAIL, "H5Gcreate_expand");
-
- status = H5Llink(file_id, "/A/B01/grp", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ tmp_id = H5Gcreate2(file_id, "/A/B01/grp", create_id, H5P_DEFAULT, access_id);
+ CHECK(tmp_id, FAIL, "H5Gcreate2");
/* Query that the name of the new group is correct */
status = H5Iget_name( tmp_id, objname, (size_t)MISC23_NAME_BUF_SIZE );
@@ -3881,41 +3878,29 @@ test_misc23(void)
CHECK(status, FAIL, "H5Gclose");
- tmp_id = H5Gcreate_expand(file_id, H5P_DEFAULT, access_id);
- CHECK(tmp_id, FAIL, "H5Gcreate_expand");
-
- status = H5Llink(file_id, "/A/B02/C02/grp", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ tmp_id = H5Gcreate2(file_id, "/A/B02/C02/grp", create_id, H5P_DEFAULT, access_id);
+ CHECK(tmp_id, FAIL, "H5Gcreate2");
status = H5Gclose(tmp_id);
CHECK(status, FAIL, "H5Gclose");
- tmp_id = H5Gcreate_expand(group_id, H5P_DEFAULT, access_id);
- CHECK(tmp_id, FAIL, "H5Gcreate_expand");
-
- status = H5Llink(group_id, "B03/grp/", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ tmp_id = H5Gcreate2(group_id, "B03/grp/", create_id, H5P_DEFAULT, access_id);
+ CHECK(tmp_id, FAIL, "H5Gcreate2");
status = H5Gclose(tmp_id);
CHECK(status, FAIL, "H5Gclose");
- if ( (tmp_id = H5Gcreate_expand(group_id, H5P_DEFAULT, access_id)) < 0)
- CHECK(tmp_id, FAIL, "H5Gcreate_expand");
-
- status = H5Llink(group_id, "/A/B04/grp/", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ tmp_id = H5Gcreate2(group_id, "/A/B04/grp/", create_id, H5P_DEFAULT, access_id);
+ CHECK(tmp_id, FAIL, "H5Gcreate2");
status = H5Gclose(tmp_id);
CHECK(status, FAIL, "H5Gclose");
- if ( (tmp_id = H5Gcreate_expand(file_id, H5P_DEFAULT, access_id)) < 0)
- CHECK(tmp_id, FAIL, "H5Gcreate_expand");
-
- status = H5Llink(file_id, "/A/B05/C05/A", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ tmp_id = H5Gcreate2(file_id, "/A/B05/C05/A", create_id, H5P_DEFAULT, access_id);
+ CHECK(tmp_id, FAIL, "H5Gcreate2");
status = H5Gclose(tmp_id);
CHECK(status, FAIL, "H5Gclose");
@@ -3926,7 +3911,7 @@ test_misc23(void)
/**********************************************************************
- * test new H5Dcreate
+ * test H5Dcreate2()
**********************************************************************/
/* Create link creation property list */
@@ -3938,51 +3923,36 @@ test_misc23(void)
CHECK(status, FAIL, "H5Pset_create_intermediate_group");
- tmp_id = H5Dcreate_expand(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(tmp_id, FAIL, "H5Dcreate");
+ tmp_id = H5Dcreate2(file_id, "/A/B06/dset", type_id, space_id, create_id, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(tmp_id, FAIL, "H5Dcreate2");
- status = H5Llink(file_id, "/A/B06/dset", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
-
status = H5Dclose(tmp_id);
CHECK(status, FAIL, "H5Dclose");
- tmp_id = H5Dcreate_expand(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(tmp_id, FAIL, "H5Dcreate");
-
- status = H5Llink(file_id, "/A/B07/B07/dset", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ tmp_id = H5Dcreate2(file_id, "/A/B07/B07/dset", type_id, space_id, create_id, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(tmp_id, FAIL, "H5Dcreate2");
status = H5Dclose(tmp_id);
CHECK(status, FAIL, "H5Dclose");
- tmp_id = H5Dcreate_expand(group_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(tmp_id, FAIL, "H5Dcreate");
-
- status = H5Llink(group_id, "B08/dset", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ tmp_id = H5Dcreate2(group_id, "B08/dset", type_id, space_id, create_id, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(tmp_id, FAIL, "H5Dcreate2");
status = H5Dclose(tmp_id);
CHECK(status, FAIL, "H5Dclose");
- tmp_id = H5Dcreate_expand(group_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(tmp_id, FAIL, "H5Dcreate");
-
- status = H5Llink(group_id, "/A/B09/dset", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ tmp_id = H5Dcreate2(group_id, "/A/B09/dset", type_id, space_id, create_id, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(tmp_id, FAIL, "H5Dcreate2");
status = H5Dclose(tmp_id);
CHECK(status, FAIL, "H5Dclose");
- tmp_id = H5Dcreate_expand(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(tmp_id, FAIL, "H5Dcreate");
-
- status = H5Llink(file_id, "/A/B10/C10/A/dset", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ tmp_id = H5Dcreate2(file_id, "/A/B10/C10/A/dset", type_id, space_id, create_id, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(tmp_id, FAIL, "H5Dcreate2");
status = H5Dclose(tmp_id);
CHECK(status, FAIL, "H5Dclose");
@@ -3999,7 +3969,7 @@ test_misc23(void)
/**********************************************************************
- * test new H5Tcommit
+ * test H5Tcommit2()
**********************************************************************/
/* Create link creation property list */
@@ -4013,11 +3983,8 @@ test_misc23(void)
tmp_id = H5Tcopy(H5T_NATIVE_INT16);
CHECK(tmp_id, FAIL, "H5Tcopy");
- status = H5Tcommit_expand(file_id, tmp_id, H5P_DEFAULT, access_id);
- CHECK(status, FAIL, "H5Tcommit_expand");
-
- status = H5Llink(file_id, "/A/B11/dtype", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ status = H5Tcommit2(file_id, "/A/B11/dtype", tmp_id, create_id, H5P_DEFAULT, access_id);
+ CHECK(status, FAIL, "H5Tcommit2");
status = H5Tclose(tmp_id);
CHECK(status, FAIL, "H5Tclose");
@@ -4026,11 +3993,8 @@ test_misc23(void)
tmp_id = H5Tcopy(H5T_NATIVE_INT32);
CHECK(tmp_id, FAIL, "H5Tcopy");
- status = H5Tcommit_expand(file_id, tmp_id, H5P_DEFAULT, access_id);
- CHECK(status, FAIL, "H5Tcommit_expand");
-
- status = H5Llink(file_id, "/A/B12/C12/dtype", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ status = H5Tcommit2(file_id, "/A/B12/C12/dtype", tmp_id, create_id, H5P_DEFAULT, access_id);
+ CHECK(status, FAIL, "H5Tcommit2");
status = H5Tclose(tmp_id);
CHECK(status, FAIL, "H5Tclose");
@@ -4039,12 +4003,9 @@ test_misc23(void)
tmp_id = H5Tcopy(H5T_NATIVE_INT64);
CHECK(tmp_id, FAIL, "H5Tcopy");
- status = H5Tcommit_expand(group_id, tmp_id, H5P_DEFAULT, access_id);
- CHECK(status, FAIL, "H5Tcommit_expand");
+ status = H5Tcommit2(group_id, "B13/C12/dtype", tmp_id, create_id, H5P_DEFAULT, access_id);
+ CHECK(status, FAIL, "H5Tcommit2");
- status = H5Llink(group_id, "B13/C12/dtype", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
-
status = H5Tclose(tmp_id);
CHECK(status, FAIL, "H5Tclose");
@@ -4052,11 +4013,8 @@ test_misc23(void)
tmp_id = H5Tcopy(H5T_NATIVE_FLOAT);
CHECK(tmp_id, FAIL, "H5Tcopy");
- status = H5Tcommit_expand(group_id, tmp_id, H5P_DEFAULT, access_id);
- CHECK(status, FAIL, "H5Tcommit_expand");
-
- status = H5Llink(group_id, "/A/B14/dtype", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ status = H5Tcommit2(group_id, "/A/B14/dtype", tmp_id, create_id, H5P_DEFAULT, access_id);
+ CHECK(status, FAIL, "H5Tcommit2");
status = H5Tclose(tmp_id);
CHECK(status, FAIL, "H5Tclose");
@@ -4065,11 +4023,8 @@ test_misc23(void)
tmp_id = H5Tcopy(H5T_NATIVE_DOUBLE);
CHECK(tmp_id, FAIL, "H5Tcopy");
- status = H5Tcommit_expand(file_id, tmp_id, H5P_DEFAULT, access_id);
- CHECK(status, FAIL, "H5Tcommit_expand");
-
- status = H5Llink(file_id, "/A/B15/C15/A/dtype", tmp_id, create_id, H5P_DEFAULT);
- CHECK(status, FAIL, "H5Llink");
+ status = H5Tcommit2(file_id, "/A/B15/C15/A/dtype", tmp_id, create_id, H5P_DEFAULT, access_id);
+ CHECK(status, FAIL, "H5Tcommit2");
status = H5Tclose(tmp_id);
CHECK(status, FAIL, "H5Tclose");
diff --git a/test/unlink.c b/test/unlink.c
index 6b39ab0..27401ed 100644
--- a/test/unlink.c
+++ b/test/unlink.c
@@ -2292,8 +2292,7 @@ test_full_group_dense(hid_t fapl)
* another object header message chunk - in order to make the file size
* computation below easier/correct - QAK)
*/
- if((gid = H5Gcreate_expand(file_id, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Llink(file_id, "/delete", gid, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(file_id, "/delete", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR
/* Close GCPL */
if(H5Pclose(gcpl) < 0) TEST_ERROR
diff --git a/tools/misc/h5mkgrp.c b/tools/misc/h5mkgrp.c
index 048523a..f2fecbd 100644
--- a/tools/misc/h5mkgrp.c
+++ b/tools/misc/h5mkgrp.c
@@ -282,14 +282,8 @@ main(int argc, const char *argv[])
hid_t gid; /* Group ID */
/* Attempt to create a group */
- if((gid = H5Gcreate_expand(fid, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- error_msg(progname, "Could not create group\n");
- leave(EXIT_FAILURE);
- } /* end if */
-
- /* Link new group into group hierarchy */
- if(H5Llink(fid, params.groups[curr_group], gid, lcpl_id, H5P_DEFAULT) < 0) {
- error_msg(progname, "Could not create link to group '%s'\n", params.groups[curr_group]);
+ if((gid = H5Gcreate2(fid, params.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ error_msg(progname, "Could not create group '%s'\n", params.groups[curr_group]);
leave(EXIT_FAILURE);
} /* end if */
diff --git a/tools/testfiles/h5mkgrp_nested.ls b/tools/testfiles/h5mkgrp_nested.ls
index 5f3d479..2b9fb25 100644
--- a/tools/testfiles/h5mkgrp_nested.ls
+++ b/tools/testfiles/h5mkgrp_nested.ls
@@ -3,8 +3,8 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested.h5'
#############################
Opened "../testfiles/h5mkgrp_nested.h5" with sec2 driver.
/one Group
- Location: 1:1504
+ Location: 1:800
Links: 1
/one/two Group
- Location: 1:800
+ Location: 1:1832
Links: 1
diff --git a/tools/testfiles/h5mkgrp_nested_latest.ls b/tools/testfiles/h5mkgrp_nested_latest.ls
index a29489f..f0bab6f 100644
--- a/tools/testfiles/h5mkgrp_nested_latest.ls
+++ b/tools/testfiles/h5mkgrp_nested_latest.ls
@@ -3,10 +3,10 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_latest.h5'
#############################
Opened "../testfiles/h5mkgrp_nested_latest.h5" with sec2 driver.
/one Group
- Location: 1:342
+ Location: 1:195
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
/one/two Group
- Location: 1:195
+ Location: 1:342
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
diff --git a/tools/testfiles/h5mkgrp_nested_mult.ls b/tools/testfiles/h5mkgrp_nested_mult.ls
index 99082b6..4fccd83 100644
--- a/tools/testfiles/h5mkgrp_nested_mult.ls
+++ b/tools/testfiles/h5mkgrp_nested_mult.ls
@@ -3,14 +3,14 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_mult.h5'
#############################
Opened "../testfiles/h5mkgrp_nested_mult.h5" with sec2 driver.
/one Group
- Location: 1:1504
+ Location: 1:800
Links: 1
/one/two Group
- Location: 1:800
+ Location: 1:1832
Links: 1
/three Group
- Location: 1:3568
+ Location: 1:2864
Links: 1
/three/four Group
- Location: 1:2864
+ Location: 1:3568
Links: 1
diff --git a/tools/testfiles/h5mkgrp_nested_mult_latest.ls b/tools/testfiles/h5mkgrp_nested_mult_latest.ls
index d54b7f1..7835050 100644
--- a/tools/testfiles/h5mkgrp_nested_mult_latest.ls
+++ b/tools/testfiles/h5mkgrp_nested_mult_latest.ls
@@ -3,18 +3,18 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_mult_latest.h5'
#############################
Opened "../testfiles/h5mkgrp_nested_mult_latest.h5" with sec2 driver.
/one Group
- Location: 1:342
+ Location: 1:195
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
/one/two Group
- Location: 1:195
+ Location: 1:342
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
/three Group
- Location: 1:636
+ Location: 1:489
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
/three/four Group
- Location: 1:489
+ Location: 1:636
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX