diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2003-10-29 17:04:58 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2003-10-29 17:04:58 (GMT) |
commit | d1f7c81a466c0bf041c380abee0f0c21ca30c86f (patch) | |
tree | 960def503380ca7737e93ae841bc2d4148b9d271 /src | |
parent | 219f713c6fdea98da7c1fdbb0eafa60a5f0bbe99 (diff) | |
download | hdf5-d1f7c81a466c0bf041c380abee0f0c21ca30c86f.zip hdf5-d1f7c81a466c0bf041c380abee0f0c21ca30c86f.tar.gz hdf5-d1f7c81a466c0bf041c380abee0f0c21ca30c86f.tar.bz2 |
[svn-r7784] *** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/H5F.c | 33 | ||||
-rw-r--r-- | src/H5Fpkg.h | 1 | ||||
-rw-r--r-- | src/H5Fprivate.h | 1 | ||||
-rw-r--r-- | src/H5Gprivate.h | 1 | ||||
-rw-r--r-- | src/H5I.c | 88 | ||||
-rw-r--r-- | src/H5Iprivate.h | 1 | ||||
-rw-r--r-- | src/H5Ipublic.h | 1 |
7 files changed, 126 insertions, 0 deletions
@@ -2137,6 +2137,9 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) if ((ret_value = H5I_register(H5I_FILE, new_file))<0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") + /* Keep this ID in file object structure */ + new_file->file_id = ret_value; + done: if (ret_value<0 && new_file) if(H5F_close(new_file)<0) @@ -4164,6 +4167,36 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_get_id + * + * Purpose: Quick and dirty routine to retrieve the file's 'file id' + * (Mainly added to stop non-file routines from poking about + * in the H5F_t data structure) + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Oct 29, 2003 + * + * Modifications: + *------------------------------------------------------------------------- + */ +hid_t +H5F_get_id(H5F_t *file) +{ + hid_t ret_value; + + FUNC_ENTER_NOINIT(H5F_get_id) + + assert(file); + ret_value = file->file_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_get_id() */ + + +/*------------------------------------------------------------------------- * Function: H5F_get_base_addr * * Purpose: Quick and dirty routine to retrieve the file's 'base_addr' value diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 8ba9806..ea11040 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -181,6 +181,7 @@ struct H5F_t { char *name; /* Name used to open file */ H5F_file_t *shared; /* The shared file info */ unsigned nopen_objs; /* Number of open object headers*/ + hid_t file_id; /* ID of this file */ hid_t closing; /* H5I_FILE_CLOSING ID or zero */ H5F_mtab_t mtab; /* File mount table */ }; diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 4f97e9a..800d14e 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -385,6 +385,7 @@ H5_DLL herr_t H5F_init(void); H5_DLL hid_t H5F_get_driver_id(const H5F_t *f); H5_DLL unsigned H5F_get_intent(const H5F_t *f); H5_DLL herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum); +H5_DLL hid_t H5F_get_id(H5F_t *file); H5_DLL int H5F_get_obj_count(const H5F_t *f, unsigned types); H5_DLL int H5F_get_obj_ids(const H5F_t *f, unsigned types, int max_objs, hid_t *obj_id_list); H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 2bf2c3f..b2bff6c 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -38,6 +38,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Bprivate.h" /* B-trees */ #include "H5Fprivate.h" /* File access */ +#include "H5Gprivate.h" /* Group */ #include "H5RSprivate.h" /* Reference-counted strings */ /* @@ -793,6 +793,94 @@ done: /*------------------------------------------------------------------------- + * Function: H5Iget_file_id + * + * Purpose: The public version of H5I_get_file_id(), obtains the file + * ID given an object ID. User has to close this ID. + * + * Return: Success: file ID + * + * Failure: a negative value + * + * Programmer: Raymond Lu + * Oct 27, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +H5Iget_file_id(hid_t obj_id) +{ + hid_t ret_value = FAIL; + + FUNC_ENTER_API(H5Iget_file_id, FAIL); + H5TRACE1("i","i",obj_id); + + ret_value = H5I_get_file_id(obj_id); + +done: + FUNC_LEAVE_API(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5I_get_file_id + * + * Purpose: The private version of H5Iget_file_id(), obtains the file + * ID given an object ID. + * + * Return: Success: file ID + * + * Failure: a negative value + * + * Programmer: Raymond Lu + * Oct 27, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +H5I_get_file_id(hid_t obj_id) +{ + hid_t ret_value = FAIL; + H5I_type_t obj_type = H5I_BADID; + H5G_entry_t *ent; + + FUNC_ENTER_NOAPI(H5I_get_file_id, FAIL); + + /* Get object type */ + obj_type = H5I_GRP(obj_id); + + switch(obj_type) { + case H5I_FILE: + ret_value = obj_id; + /* Increment reference count on atom. */ + if (H5I_inc_ref(ret_value)<0) + HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "incrementing file ID failed"); + + break; + case H5I_GROUP: + case H5I_DATASET: + case H5I_ATTR: + ent = H5G_loc(obj_id); + ret_value = H5F_get_id(ent->file); + /* Increment reference count on atom. */ + if (H5I_inc_ref(ret_value)<0) + HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "incrementing file ID failed"); + + break; + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value); +} + + +/*------------------------------------------------------------------------- * Function: H5I_remove * * Purpose: Removes the specified ID from its group. diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 79819a5..42369e3 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -67,6 +67,7 @@ H5_DLL hid_t H5I_register(H5I_type_t grp, void *object); H5_DLL void *H5I_object(hid_t id); H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); H5_DLL H5I_type_t H5I_get_type(hid_t id); +H5_DLL hid_t H5I_get_file_id(hid_t obj_id); H5_DLL void *H5I_remove(hid_t id); H5_DLL void *H5I_search(H5I_type_t grp, H5I_search_func_t func, void *key); H5_DLL int H5I_inc_ref(hid_t id); diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 1f4b845..eb97994 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -59,6 +59,7 @@ extern "C" { /* Public API functions */ H5_DLL H5I_type_t H5Iget_type(hid_t id); +H5_DLL hid_t H5Iget_file_id(hid_t obj_id); H5_DLL ssize_t H5Iget_name(hid_t object_id, char *name/*out*/, size_t size); #ifdef __cplusplus |