summaryrefslogtreecommitdiffstats
path: root/src/H5Gname.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-07-28 12:33:13 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-07-28 12:33:13 (GMT)
commit73ee20aeb7724483d3e95fbcd81ab1589f481572 (patch)
tree04664ea9aac0bfa453053b06049c59714135d40e /src/H5Gname.c
parentf99e0b9f75df7b9964c650b0ac0a0378dbb1a209 (diff)
downloadhdf5-73ee20aeb7724483d3e95fbcd81ab1589f481572.zip
hdf5-73ee20aeb7724483d3e95fbcd81ab1589f481572.tar.gz
hdf5-73ee20aeb7724483d3e95fbcd81ab1589f481572.tar.bz2
[svn-r19134] Description:
Bring r19133 from trunk to 1.8 branch: Correct traversal of user-defined links (including external links) to retain path information of object, allowing H5Iget_name() queries to work quickly (without searching entire destination file). This required some refactoring and addition of a mechanism to detect if a "fast" query was performed (for the tests). Minor code cleanups, etc. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode (h5committest performed on trunk)
Diffstat (limited to 'src/H5Gname.c')
-rw-r--r--src/H5Gname.c72
1 files changed, 40 insertions, 32 deletions
diff --git a/src/H5Gname.c b/src/H5Gname.c
index a0d11da..8a62d5e 100644
--- a/src/H5Gname.c
+++ b/src/H5Gname.c
@@ -426,49 +426,57 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth)
*-------------------------------------------------------------------------
*/
ssize_t
-H5G_get_name(hid_t id, char *name/*out*/, size_t size, hid_t lapl_id,
- hid_t dxpl_id)
+H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size,
+ hbool_t *cached, hid_t lapl_id, hid_t dxpl_id)
{
- H5G_loc_t loc; /* Object location */
- ssize_t ret_value = FAIL;
+ ssize_t len = 0; /* Length of object's name */
+ ssize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_get_name, FAIL)
- /* get object location */
- if(H5G_loc(id, &loc) >= 0) {
- ssize_t len = 0;
+ /* Sanity check */
+ HDassert(loc);
- /* If the user path is available and it's not "hidden", use it */
- if(loc.path->user_path_r != NULL && loc.path->obj_hidden == 0) {
- len = H5RS_len(loc.path->user_path_r);
+ /* If the user path is available and it's not "hidden", use it */
+ if(loc->path->user_path_r != NULL && loc->path->obj_hidden == 0) {
+ len = H5RS_len(loc->path->user_path_r);
- if(name) {
- HDstrncpy(name, H5RS_get_str(loc.path->user_path_r), MIN((size_t)(len + 1), size));
- if((size_t)len >= size)
- name[size - 1] = '\0';
- } /* end if */
+ if(name) {
+ HDstrncpy(name, H5RS_get_str(loc->path->user_path_r), MIN((size_t)(len + 1), size));
+ if((size_t)len >= size)
+ name[size - 1] = '\0';
} /* end if */
- else if(!loc.path->obj_hidden) {
- hid_t file;
- /* Retrieve file ID for name search */
- if((file = H5I_get_file_id(id, FALSE)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve file ID")
+ /* Indicate that the name is cached, if requested */
+ /* (Currently only used for testing - QAK, 2010/07/26) */
+ if(cached)
+ *cached = TRUE;
+ } /* end if */
+ else if(!loc->path->obj_hidden) {
+ hid_t file;
- /* Search for name of object */
- if((len = H5G_get_name_by_addr(file, lapl_id, dxpl_id, loc.oloc, name, size)) < 0) {
- H5I_dec_ref(file, FALSE);
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name")
- } /* end if */
+ /* Retrieve file ID for name search */
+ if((file = H5F_get_id(loc->oloc->file, FALSE)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get file ID")
- /* Close file ID used for search */
- if(H5I_dec_ref(file, FALSE) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTCLOSEFILE, FAIL, "can't determine name")
- } /* end else */
+ /* Search for name of object */
+ if((len = H5G_get_name_by_addr(file, lapl_id, dxpl_id, loc->oloc, name, size)) < 0) {
+ H5I_dec_ref(file, FALSE);
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name")
+ } /* end if */
- /* Set return value */
- ret_value = len;
- } /* end if */
+ /* Close file ID used for search */
+ if(H5I_dec_ref(file, FALSE) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCLOSEFILE, FAIL, "can't determine name")
+
+ /* Indicate that the name is _not_ cached, if requested */
+ /* (Currently only used for testing - QAK, 2010/07/26) */
+ if(cached)
+ *cached = FALSE;
+ } /* end else */
+
+ /* Set return value */
+ ret_value = len;
done:
FUNC_LEAVE_NOAPI(ret_value)