diff --git a/filetraverser/unix.c b/filetraverser/unix.c new file mode 100644 --- /dev/null +++ b/filetraverser/unix.c @@ -0,0 +1,24 @@ +/** + * unix.c + * Copyright (C) 2010 Markus Broeker + */ + +#include +#include +#include +#include +#include + +int isUnixLink (const char *name) +{ + struct stat st; + + assert (lstat (name, &st) == 0); + return (S_ISLNK (st.st_mode)); +} + +JNIEXPORT jint JNICALL Java_Unix_isUnixLink (JNIEnv * env, jclass jc, jstring s) +{ + const char *c_string = (*env)->GetStringUTFChars (env, s, NULL); + return isUnixLink (c_string); +}