filetraverser/unix.c
changeset 151 a8c2649cf277
equal deleted inserted replaced
150:75133486ba7e 151:a8c2649cf277
       
     1 /**
       
     2  * unix.c
       
     3  * Copyright (C) 2010 Markus Broeker
       
     4  */
       
     5 
       
     6 #include <sys/types.h>
       
     7 #include <sys/stat.h>
       
     8 #include <unistd.h>
       
     9 #include <assert.h>
       
    10 #include <jni.h>
       
    11 
       
    12 int isUnixLink (const char *name)
       
    13 {
       
    14     struct stat st;
       
    15 
       
    16     assert (lstat (name, &st) == 0);
       
    17     return (S_ISLNK (st.st_mode));
       
    18 }
       
    19 
       
    20 JNIEXPORT jint JNICALL Java_Unix_isUnixLink (JNIEnv * env, jclass jc, jstring s)
       
    21 {
       
    22     const char *c_string = (*env)->GetStringUTFChars (env, s, NULL);
       
    23     return isUnixLink (c_string);
       
    24 }