summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/src/hdf/hdf5lib/H5.java19
-rw-r--r--java/src/jni/h5fImp.c29
-rw-r--r--java/src/jni/h5fImp.h9
-rw-r--r--java/test/TestH5Fbasic.java13
-rw-r--r--java/test/TestH5Fparams.java5
-rw-r--r--java/test/testfiles/JUnit-TestH5Fbasic.txt3
-rw-r--r--java/test/testfiles/JUnit-TestH5Fparams.txt3
7 files changed, 78 insertions, 3 deletions
diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java
index 1138e50..bce0034 100644
--- a/java/src/hdf/hdf5lib/H5.java
+++ b/java/src/hdf/hdf5lib/H5.java
@@ -3077,10 +3077,29 @@ public class H5 implements java.io.Serializable {
* - Error from the HDF-5 Library.
* @exception NullPointerException
* - name is null.
+ *
+ * @deprecated As of HDF5 1.10.5 in favor of H5Fis_accessible.
**/
public synchronized static native boolean H5Fis_hdf5(String name) throws HDF5LibraryException, NullPointerException;
/**
+ * H5Fis_accessible determines if the file can be opened with the given fapl.
+ *
+ * @param name
+ * IN: File name to check.
+ * @param file_id
+ * IN: File identifier for a currently-open HDF5 file
+ *
+ * @return true if file is accessible, false if not.
+ *
+ * @exception HDF5LibraryException
+ * - Error from the HDF-5 Library.
+ * @exception NullPointerException
+ * - name is null.
+ **/
+ public synchronized static native boolean H5Fis_accessible(String name, long file_id) throws HDF5LibraryException, NullPointerException;
+
+ /**
* H5Fmount mounts the file specified by child_id onto the group specified by loc_id and name using the mount
* properties plist_id.
*
diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c
index 9d68290..248e654 100644
--- a/java/src/jni/h5fImp.c
+++ b/java/src/jni/h5fImp.c
@@ -168,6 +168,33 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5Fis_accessible
+ * Signature: (Ljava/lang/String;J)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_hdf_hdf5lib_H5_H5Fis_1accessible
+ (JNIEnv *env, jclass clss, jstring name, jlong file_id)
+{
+ htri_t bval = JNI_FALSE;
+ const char *fileName;
+
+ PIN_JAVA_STRING(name, fileName);
+ if (fileName != NULL) {
+ bval = H5Fis_accessible(fileName, (hid_t)file_id);
+
+ UNPIN_JAVA_STRING(name, fileName);
+
+ if (bval > 0)
+ bval = JNI_TRUE;
+ else if (bval < 0)
+ h5libraryError(env);
+ }
+
+ return (jboolean)bval;
+} /* end Java_hdf_hdf5lib_H5_H5Fis_1accessible */
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Fget_create_plist
* Signature: (J)J
*/
@@ -177,7 +204,7 @@ Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist
{
hid_t retVal = -1;
- retVal = H5Fget_create_plist((hid_t)file_id );
+ retVal = H5Fget_create_plist((hid_t)file_id);
if (retVal < 0)
h5libraryError(env);
diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h
index fcfdedf..af0fa1d 100644
--- a/java/src/jni/h5fImp.h
+++ b/java/src/jni/h5fImp.h
@@ -68,6 +68,15 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5Fis_accessible
+ * Signature: (Ljava/lang/String;J)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_hdf_hdf5lib_H5_H5Fis_1ccessible
+ (JNIEnv*, jclass, jstring, jlong);
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Fget_create_plist
* Signature: (J)J
*/
diff --git a/java/test/TestH5Fbasic.java b/java/test/TestH5Fbasic.java
index 11d6644..a5afb6e 100644
--- a/java/test/TestH5Fbasic.java
+++ b/java/test/TestH5Fbasic.java
@@ -81,6 +81,19 @@ public class TestH5Fbasic {
assertTrue(isH5 == true);
}
+ @Test
+ public void testH5Fis_accessible() {
+ boolean isH5 = false;
+
+ try {
+ isH5 = H5.H5Fis_accessible(H5_FILE, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Throwable err) {
+ fail("H5.H5Fis_accessible failed on " + H5_FILE + ": " + err);
+ }
+ assertTrue(isH5 == true);
+ }
+
@Test(expected = HDF5LibraryException.class)
public void testH5Fcreate_EXCL() throws Throwable {
H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_EXCL,
diff --git a/java/test/TestH5Fparams.java b/java/test/TestH5Fparams.java
index fffded1..3d64aa9 100644
--- a/java/test/TestH5Fparams.java
+++ b/java/test/TestH5Fparams.java
@@ -60,6 +60,11 @@ public class TestH5Fparams {
}
@Test(expected = NullPointerException.class)
+ public void testH5Fis_accessible_null() throws Throwable {
+ H5.H5Fis_accessible(null, -1);
+ }
+
+ @Test(expected = NullPointerException.class)
public void testH5Fmount_null() throws Throwable {
H5.H5Fmount(-1, null, -1, HDF5Constants.H5P_DEFAULT);
}
diff --git a/java/test/testfiles/JUnit-TestH5Fbasic.txt b/java/test/testfiles/JUnit-TestH5Fbasic.txt
index 467e2fb..2654624 100644
--- a/java/test/testfiles/JUnit-TestH5Fbasic.txt
+++ b/java/test/testfiles/JUnit-TestH5Fbasic.txt
@@ -9,6 +9,7 @@ JUnit version 4.11
.testH5Freopen_closed
.testH5Freset_mdc_hit_rate_stats
.testH5Fget_name
+.testH5Fis_accessible
.testH5Fcreate
.testH5Fclear_elink_file_cache
.testH5Fclose_twice
@@ -17,5 +18,5 @@ JUnit version 4.11
Time: XXXX
-OK (15 tests)
+OK (16 tests)
diff --git a/java/test/testfiles/JUnit-TestH5Fparams.txt b/java/test/testfiles/JUnit-TestH5Fparams.txt
index 9d35220..e91cbdc 100644
--- a/java/test/testfiles/JUnit-TestH5Fparams.txt
+++ b/java/test/testfiles/JUnit-TestH5Fparams.txt
@@ -1,4 +1,5 @@
JUnit version 4.11
+.testH5Fis_accessible_null
.testH5Fcreate_null
.testH5Fflush_local
.testH5Fget_info
@@ -13,5 +14,5 @@ JUnit version 4.11
Time: XXXX
-OK (11 tests)
+OK (12 tests)