summaryrefslogtreecommitdiffstats
path: root/src/native/common/JarUtil.c
blob: c918f772f3e0b4e57dbb920fe7cc46dfc193c0c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <jni.h>

#include <assert.h>

#include "com_jogamp_common_util_JarUtil.h"

#if defined(__APPLE__)
    #include <sys/xattr.h>
    static const char kQuarantineAttrName[] = "com.apple.quarantine";
#endif

/*
 * Class:     com_jogamp_common_util_JarUtil
 * Method:    fixNativeLibAttribs
 * Signature: (Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_com_jogamp_common_util_JarUtil_fixNativeLibAttribs
  (JNIEnv *env, jclass _unused, jstring fname) {
  const char* _UTF8fname = NULL;
  int status = 0;
  if (fname != NULL) {
    if (fname != NULL) {
      _UTF8fname = (*env)->GetStringUTFChars(env, fname, (jboolean*)NULL);
    if (_UTF8fname == NULL) {
      (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"),
                       "Failed to get UTF-8 chars for argument \"fname\" in native dispatcher for \"removexattr\"");
      return 0;
    }
    }
  }
#if defined(__APPLE__)
  status = removexattr(_UTF8fname, kQuarantineAttrName, 0);
#endif
  if (fname != NULL) {
    (*env)->ReleaseStringUTFChars(env, fname, _UTF8fname);
  }
  return 0 == status ? JNI_TRUE : JNI_FALSE;
}