diff options
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools.h | 1 | ||||
-rw-r--r-- | tools/lib/h5tools_filters.c | 92 |
2 files changed, 92 insertions, 1 deletions
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index f5731a0..93f926e 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -509,5 +509,6 @@ extern void h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid extern int h5tools_canreadf(const char* name, hid_t dcpl_id); +extern int h5tools_can_encode(H5Z_filter_t filtn); #endif /* H5TOOLS_H__ */ diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index 368283f..3370409 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -150,5 +150,95 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr } +/*------------------------------------------------------------------------- + * Function: h5tools_canwritef + * + * Purpose: check if the filter is available and can write data. + * At this time, all filters that are available can write data, + * except SZIP, which may be configured decoder-only. + * + * Return: 1, can write, 0, cannot, -1 error + * + * Programmer: + * + * Date: October 5, 2004 + * + *------------------------------------------------------------------------- + */ +int h5tools_can_encode( H5Z_filter_t filtn) +{ - + int have_deflate=0; /* assume initially we do not have filters */ + int have_szip=0; + int have_shuffle=0; + int have_fletcher=0; + herr_t status; + unsigned int filter_config_flags; + +#ifdef H5_HAVE_FILTER_DEFLATE + have_deflate=1; +#endif +#ifdef H5_HAVE_FILTER_SZIP + have_szip=1; +#endif +#ifdef H5_HAVE_FILTER_SHUFFLE + have_shuffle=1; +#endif +#ifdef H5_HAVE_FILTER_FLETCHER32 + have_fletcher=1; +#endif + + switch (filtn) + { + /* user defined filter */ + default: + return 0; + break; + case H5Z_FILTER_DEFLATE: + if (!have_deflate) + { + return 0; + } + break; + case H5Z_FILTER_SZIP: + if (!have_szip) + { + return 0; + } + status =H5Zget_filter_info(filtn, &filter_config_flags); + if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) { + /* filter present but neither encode nor decode is supported (???) */ + return -1; + } else if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == + H5Z_FILTER_CONFIG_DECODE_ENABLED) { + /* decoder only: read but not write */ + return 0; + } else if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == + H5Z_FILTER_CONFIG_ENCODE_ENABLED) { + /* encoder only: write but not read (???) */ + return -1; + } else if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == + (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) { + return 1; + } + break; + case H5Z_FILTER_SHUFFLE: + if (!have_shuffle) + { + return 0; + } + break; + case H5Z_FILTER_FLETCHER32: + if (!have_fletcher) + { + return 0; + } + break; + }/*switch*/ + + return 1; +} |