diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5F.c | 68 | ||||
-rw-r--r-- | src/H5Fpkg.h | 1 | ||||
-rw-r--r-- | src/H5I.c | 92 | ||||
-rw-r--r-- | src/H5Ipublic.h | 1 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 52 | ||||
-rw-r--r-- | src/H5Ppublic.h | 1 | ||||
-rw-r--r-- | src/H5Z.c | 72 | ||||
-rw-r--r-- | src/H5Zprivate.h | 1 | ||||
-rw-r--r-- | src/H5Zpublic.h | 1 |
9 files changed, 288 insertions, 1 deletions
@@ -2322,7 +2322,7 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, * reading and writing. */ if (0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) - flags |= H5F_ACC_EXCL; /*default*/ + flags |= H5F_ACC_EXCL; /*default*/ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; /* @@ -2335,6 +2335,9 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_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) H5F_close(new_file); @@ -2411,6 +2414,9 @@ H5Fopen(const char *filename, unsigned flags, 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 handle"); + /* Keep this ID in file object structure */ + new_file->file_id = ret_value; + done: if (ret_value<0 && new_file) H5F_close(new_file); @@ -2979,6 +2985,10 @@ H5F_close(H5F_t *f) /* Register an ID for closing the file later */ if (!f->closing) f->closing = H5I_register(H5I_FILE_CLOSING, f); + + /* Invalidate file ID */ + f->file_id = -1; + HGOTO_DONE(SUCCEED); } else { if (f->closing) { @@ -3009,6 +3019,10 @@ H5F_close(H5F_t *f) /* Register an ID for closing the file later */ if (!f->closing) f->closing = H5I_register(H5I_FILE_CLOSING, f); + + /* Invalidate file ID */ + f->file_id = -1; + HGOTO_DONE(SUCCEED); } else { if (!f->closing && f->shared->nrefs>1) @@ -3071,6 +3085,9 @@ H5F_close(H5F_t *f) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, unknown file close degree"); } /* end switch */ + /* Invalidate file ID */ + f->file_id = -1; + /* Only flush at this point if the file will be closed */ if (closing) { /* Dump debugging info */ @@ -3691,6 +3708,9 @@ H5Freopen(hid_t file_id) if ((ret_value=H5I_register(H5I_FILE, new_file))<0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle"); + /* Keep this ID in file object structure */ + new_file->file_id = ret_value; + done: if (ret_value<0 && new_file) H5F_close(new_file); @@ -4432,3 +4452,49 @@ H5F_debug(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, FILE * stream, int inden done: FUNC_LEAVE_NOAPI(ret_value); } + + +/*------------------------------------------------------------------------- + * Function: H5F_get_id + * + * Purpose: Get the file ID, incrementing it, or "resurrecting" it as + * appropriate. + * + * 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_NOAPI_NOINIT(H5F_get_id) + + assert(file); + + if(file->file_id == -1) { + if(H5I_remove(file->closing)==NULL) + HGOTO_ERROR(H5E_ATOM, H5E_READERROR, FAIL, "unable to remove from closing list") + + /* Get an atom for the file */ + if ((file->file_id = H5I_register(H5I_FILE, file))<0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") + + /* Indicate file is not closing */ + file->closing = 0; + } else { + /* Increment reference count on atom. */ + if (H5I_inc_ref(file->file_id)<0) + HGOTO_ERROR (H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed"); + } + + ret_value = file->file_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_get_id() */
\ No newline at end of file diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index b99cdba..d33d553 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 */ }; @@ -1434,3 +1434,95 @@ done: } #endif /* H5I_DEBUG_OUTPUT */ + + +/*------------------------------------------------------------------------- + * 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; + + FUNC_ENTER_API(H5Iget_file_id, FAIL); + H5TRACE1("i","i",obj_id); + + if((ret_value = H5I_get_file_id(obj_id))<0) + HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file 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: + * + *------------------------------------------------------------------------- + */ +static hid_t +H5I_get_file_id(hid_t obj_id) +{ + H5G_entry_t *ent; + hid_t ret_value; + + FUNC_ENTER_NOAPI_NOINIT(H5I_get_file_id); + + /* Get object type */ + switch(H5I_GROUP(obj_id)) { + case H5I_FILE: + ret_value = obj_id; + + /* Increment reference count on atom. */ + if (H5I_inc_ref(ret_value)<0) + HGOTO_ERROR (H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed"); + + break; + + case H5I_DATATYPE: + if((ent = H5G_loc(obj_id))==NULL) + HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "not a named datatype"); + ret_value = H5F_get_id(ent->file); + break; + + case H5I_GROUP: + case H5I_DATASET: + case H5I_ATTR: + if((ent = H5G_loc(obj_id))==NULL) + HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "can't get symbol table info"); + ret_value = H5F_get_id(ent->file); + break; + + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value); +}
\ No newline at end of file diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 7f67d62..6069fd1 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -62,6 +62,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 id); H5_DLL ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size); H5_DLL int H5Iinc_ref(hid_t id); H5_DLL int H5Idec_ref(hid_t id); diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 61f179e..1906fb9 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1591,3 +1591,55 @@ done: FUNC_LEAVE_API(ret_value); } + +/*------------------------------------------------------------------------- + * Function: H5Premove_filter + * + * Purpose: Deletes a filter from the dataset creation property list; + * deletes all filters if FILTER is H5Z_FILTER_NONE + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Pedro Vicente + * January 26, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_pline_t pline; /* Filter pipeline */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(H5Premove_filter, FAIL) + H5TRACE2("e","iZf",plist_id,filter); + + /* Get the property list structure */ + if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Get pipeline info */ + if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline") + + /* Check if there are any filters */ + if (pline.filter) { + /* Delete filter */ + if(H5Z_delete(&pline, filter) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't delete filter") + + /* Put the I/O pipeline information back into the property list */ + if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value); +} + + + diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 621524e..eedcda6 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -300,6 +300,7 @@ H5_DLL herr_t H5Pset_hyper_vector_size(hid_t fapl_id, size_t size); H5_DLL herr_t H5Pget_hyper_vector_size(hid_t fapl_id, size_t *size/*out*/); H5_DLL herr_t H5Pset_small_data_block_size(hid_t fapl_id, hsize_t size); H5_DLL herr_t H5Pget_small_data_block_size(hid_t fapl_id, hsize_t *size/*out*/); +H5_DLL herr_t H5Premove_filter(hid_t plist_id, H5Z_filter_t filter); #ifdef __cplusplus } @@ -1134,3 +1134,75 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5Z_all_filters_avail() */ + + +/*------------------------------------------------------------------------- + * Function: H5Z_delete + * + * Purpose: Delete filter FILTER from pipeline PLINE; + * deletes all filters if FILTER is H5Z_FILTER_NONE + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Pedro Vicente + * Monday, January 26, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) +{ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5Z_delete, FAIL) + + /* Check args */ + assert(pline); + assert(filter>=0 && filter<=H5Z_FILTER_MAX); + + /* if the pipeline has no filters, just return */ + if(pline->nfilters==0) + HGOTO_DONE(SUCCEED) + + /* Delete all filters */ + if (H5Z_FILTER_ALL==filter) { + if(H5O_reset(H5O_PLINE_ID, pline)<0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFREE, FAIL, "can't release pipeline info") + } /* end if */ + /* Delete filter */ + else { + size_t idx; /* Index of filter in pipeline */ + unsigned found=0; /* Indicate filter was found in pipeline */ + + /* Locate the filter in the pipeline */ + for(idx=0; idx<pline->nfilters; idx++) + if(pline->filter[idx].id==filter) { + found=1; + break; + } + + /* filter was not found in the pipeline */ + if (!found) + HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") + + /* Free information for deleted filter */ + H5MM_xfree(pline->filter[idx].name); + H5MM_xfree(pline->filter[idx].cd_values); + + /* Remove filter from pipeline array */ + if((idx+1)<pline->nfilters) + HDmemcpy(&pline->filter[idx], &pline->filter[idx+1], + sizeof (H5Z_filter_info_t)*(pline->nfilters-(idx+1))); + + /* Decrement number of used filters */ + pline->nfilters--; + + /* Reset information for previous last filter in pipeline */ + HDmemset(&pline->filter[pline->nfilters], 0, sizeof (H5Z_filter_info_t)); + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index 103aeff..4ca0662 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -58,5 +58,6 @@ H5_DLL herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id); H5_DLL H5Z_filter_info_t *H5Z_filter_info(struct H5O_pline_t *pline, H5Z_filter_t filter); H5_DLL htri_t H5Z_all_filters_avail(struct H5O_pline_t *pline); +H5_DLL herr_t H5Z_delete(struct H5O_pline_t *pline, H5Z_filter_t filter); #endif diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index 1463598..8fd775d 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -29,6 +29,7 @@ typedef int H5Z_filter_t; #define H5Z_FILTER_ERROR (-1) /*no filter */ #define H5Z_FILTER_NONE 0 /*reserved indefinitely */ +#define H5Z_FILTER_ALL 0 /*symbol to remove all filters in H5Premove_filter */ #define H5Z_FILTER_DEFLATE 1 /*deflation like gzip */ #define H5Z_FILTER_SHUFFLE 2 /*shuffle the data */ #define H5Z_FILTER_FLETCHER32 3 /*fletcher32 checksum of EDC */ |