diff --git a/README.txt b/README.txt index 1fcbcf0..64027bb 100644 --- a/README.txt +++ b/README.txt @@ -3,7 +3,7 @@ Build requirements - JDK - Apache Ant -- OpenSlide +- OpenSlide >= 3.4.0 Building on Linux or Mac OS X ----------------------------- diff --git a/openslide-jni.c b/openslide-jni.c index bd5f8bc..26570b9 100644 --- a/openslide-jni.c +++ b/openslide-jni.c @@ -24,17 +24,20 @@ #include -static jboolean osj_can_open(JNIEnv *env, jobject obj, jstring filename) { +static jstring osj_detect_vendor(JNIEnv *env, jobject obj, jstring filename) { const char *filename2 = (*env)->GetStringUTFChars(env, filename, NULL); if (filename2 == NULL) { - return JNI_FALSE; + return NULL; } - jboolean result = openslide_can_open(filename2); + const char *val = openslide_detect_vendor(filename2); (*env)->ReleaseStringUTFChars(env, filename, filename2); - return result; + if (val == NULL) { + return NULL; + } + return (*env)->NewStringUTF(env, val); } static jlong osj_open(JNIEnv *env, jobject obj, jstring filename) { @@ -190,7 +193,7 @@ static jstring osj_get_version(JNIEnv *env, jobject obj) { } static JNINativeMethod methods[] = { - { "openslide_can_open", "(Ljava/lang/String;)Z", (void *) osj_can_open }, + { "openslide_detect_vendor", "(Ljava/lang/String;)Ljava/lang/String;", (void *) osj_detect_vendor }, { "openslide_open", "(Ljava/lang/String;)J", (void *) osj_open }, { "openslide_get_level_count", "(J)I", (void *) osj_get_level_count }, { "openslide_get_level_dimensions", "(JI[J)V", (void *) osj_get_level_dimensions }, diff --git a/src/org/openslide/OpenSlide.java b/src/org/openslide/OpenSlide.java index 8d7fb46..f3dfb3d 100644 --- a/src/org/openslide/OpenSlide.java +++ b/src/org/openslide/OpenSlide.java @@ -40,7 +40,7 @@ private static final FileFilter FILE_FILTER = new FileFilter() { @Override public boolean accept(File f) { - return f.isDirectory() || OpenSlide.fileIsValid(f); + return f.isDirectory() || OpenSlide.detectVendor(f) != null; } @Override @@ -84,8 +84,8 @@ public String getDescription() { final private int hashCodeVal; - public static boolean fileIsValid(File file) { - return OpenSlideJNI.openslide_can_open(file.getPath()); + public static String detectVendor(File file) { + return OpenSlideJNI.openslide_detect_vendor(file.getPath()); } public OpenSlide(File file) throws IOException { diff --git a/src/org/openslide/OpenSlideJNI.java b/src/org/openslide/OpenSlideJNI.java index 2e652a8..32c14d4 100644 --- a/src/org/openslide/OpenSlideJNI.java +++ b/src/org/openslide/OpenSlideJNI.java @@ -56,7 +56,7 @@ private OpenSlideJNI() { } } - native static boolean openslide_can_open(String file); + native static String openslide_detect_vendor(String file); native static long openslide_open(String file); diff --git a/src/org/openslide/TestCLI.java b/src/org/openslide/TestCLI.java index 53213d1..10dde39 100644 --- a/src/org/openslide/TestCLI.java +++ b/src/org/openslide/TestCLI.java @@ -48,8 +48,8 @@ public static void main(String args[]) throws IOException { File f = new File(args[0]); - System.out.printf("openslide_can_open returns %s\n", OpenSlide - .fileIsValid(f) ? "true" : "false"); + System.out.printf("openslide_detect_vendor returns %s\n", + OpenSlide.detectVendor(f)); OpenSlide osr = new OpenSlide(f); long w, h;