author | Markus Bröker<broeker.markus@googlemail.com> |
Sat, 21 Oct 2017 13:45:05 +0200 | |
changeset 171 | c6e0af68825a |
parent 151 | a8c2649cf277 |
permissions | -rw-r--r-- |
151
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
1 |
/** |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
2 |
* unix.c |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
3 |
* Copyright (C) 2010 Markus Broeker |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
4 |
*/ |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
5 |
|
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
6 |
#include <sys/types.h> |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
7 |
#include <sys/stat.h> |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
8 |
#include <unistd.h> |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
9 |
#include <assert.h> |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
10 |
#include <jni.h> |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
11 |
|
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
12 |
int isUnixLink (const char *name) |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
13 |
{ |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
14 |
struct stat st; |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
15 |
|
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
16 |
assert (lstat (name, &st) == 0); |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
17 |
return (S_ISLNK (st.st_mode)); |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
18 |
} |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
19 |
|
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
20 |
JNIEXPORT jint JNICALL Java_Unix_isUnixLink (JNIEnv * env, jclass jc, jstring s) |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
21 |
{ |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
22 |
const char *c_string = (*env)->GetStringUTFChars (env, s, NULL); |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
23 |
return isUnixLink (c_string); |
a8c2649cf277
FileTraverser Demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
24 |
} |