diff options
Diffstat (limited to 'java/src/jni')
-rw-r--r-- | java/src/jni/h5util.c | 68 | ||||
-rw-r--r-- | java/src/jni/h5util.h | 8 |
2 files changed, 76 insertions, 0 deletions
diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index b684d05..4568880 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -3512,6 +3512,74 @@ done: /* * Class: hdf_hdf5lib_H5 + * Method: _H5export_dataset_string + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5__1H5export_1dataset_1string(JNIEnv *env, jclass clss, jstring file_export_name, + jstring file_name, jstring object_path, jint binary_order) +{ + const char *file_export = NULL; + const char *fileName = NULL; + const char *object_name = NULL; + jboolean isCopy; + herr_t ret_val = FAIL; + hid_t file_id = H5I_INVALID_HID; + hid_t dataset_id = H5I_INVALID_HID; + FILE * stream = NULL; + + UNUSED(clss); + + if (NULL == file_export_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5export_dataset: file_export_name is NULL"); + + if (NULL == file_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5export_dataset: file_name is NULL"); + + if (NULL == object_path) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5export_dataset: object_path is NULL"); + + PIN_JAVA_STRING(ENVONLY, file_name, fileName, NULL, "H5export_dataset: file name not pinned"); + + if ((file_id = H5Fopen(fileName, (unsigned)H5F_ACC_RDWR, (hid_t)H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + PIN_JAVA_STRING(ENVONLY, object_path, object_name, &isCopy, "H5export_dataset: object_path not pinned"); + + if ((dataset_id = H5Dopen2(file_id, object_name, H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + PIN_JAVA_STRING(ENVONLY, file_export_name, file_export, NULL, + "H5export_dataset: file_export name not pinned"); + + if (NULL == (stream = HDfopen(file_export, "w+"))) + H5_JNI_FATAL_ERROR(ENVONLY, "HDfopen failed"); + + if ((ret_val = h5str_dump_simple_dset(ENVONLY, stream, dataset_id, binary_order)) < 0) + H5_ASSERTION_ERROR(ENVONLY, "h5str_dump_simple_dset failed"); + + if (stream) { + HDfclose(stream); + stream = NULL; + } + +done: + if (stream) + HDfclose(stream); + if (file_export) + UNPIN_JAVA_STRING(ENVONLY, file_export_name, file_export); + if (object_name) + UNPIN_JAVA_STRING(ENVONLY, object_path, object_name); + if (fileName) + UNPIN_JAVA_STRING(ENVONLY, file_name, fileName); + if (dataset_id >= 0) + H5Dclose(dataset_id); + if (file_id >= 0) + H5Fclose(file_id); +} /* end Java_hdf_hdf5lib_H5_H5export_1dataset */ + +/* + * Class: hdf_hdf5lib_H5 * Method: H5export_attribute * Signature: (Ljava/lang/String;JLjava/lang/String;I)V */ diff --git a/java/src/jni/h5util.h b/java/src/jni/h5util.h index 33f1ea7..b7f12bd 100644 --- a/java/src/jni/h5util.h +++ b/java/src/jni/h5util.h @@ -111,6 +111,14 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5export_1dataset(JNIEnv *, jclass, j /* * Class: hdf_hdf5lib_H5 + * Method: _H5export_dataset_string + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5__1H5export_1dataset_1string(JNIEnv *, jclass, jstring, jstring, + jstring, jint); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5export_attribute * Signature: (Ljava/lang/String;JLjava/lang/String;I)V */ |