Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2005 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2007 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 8-13
Link Here
|
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
10 |
* Red Hat Incorporated - get/setResourceAttribute code |
10 |
* Red Hat Incorporated - get/setResourceAttribute code |
|
|
11 |
* Martin Oberhuber (Wind River) - [170317] add symbolic link support to API |
11 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
12 |
#include <jni.h> |
13 |
#include <jni.h> |
13 |
#include <sys/types.h> |
14 |
#include <sys/types.h> |
Lines 17-22
Link Here
|
17 |
#include <string.h> |
18 |
#include <string.h> |
18 |
#include "../localfile.h" |
19 |
#include "../localfile.h" |
19 |
#include <os_custom.h> |
20 |
#include <os_custom.h> |
|
|
21 |
#ifdef LINUX |
22 |
#include <unistd.h> |
23 |
#endif |
20 |
|
24 |
|
21 |
/* |
25 |
/* |
22 |
* Get a null-terminated byte array from a java byte array. |
26 |
* Get a null-terminated byte array from a java byte array. |
Lines 94-105
Link Here
|
94 |
(*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_EXECUTABLE, JNI_TRUE); |
98 |
(*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_EXECUTABLE, JNI_TRUE); |
95 |
} |
99 |
} |
96 |
|
100 |
|
|
|
101 |
#ifdef LINUX |
97 |
// sym link? |
102 |
// sym link? |
98 |
// if ((info.st_mode & S_IFLNK) == S_IFLNK) { |
103 |
if ((info.st_mode & S_IFLNK) == S_IFLNK) { |
99 |
// mid = (*env)->GetMethodID(env, cls, "setAttribute", "(IZ)V"); |
104 |
mid = (*env)->GetMethodID(env, cls, "setAttribute", "(IZ)V"); |
100 |
// if (mid == 0) return JNI_FALSE; |
105 |
if (mid == 0) return JNI_FALSE; |
101 |
// (*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_LINK, JNI_TRUE); |
106 |
(*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_SYMLINK, JNI_TRUE); |
102 |
// } |
107 |
} |
|
|
108 |
#endif |
103 |
return JNI_TRUE; |
109 |
return JNI_TRUE; |
104 |
} |
110 |
} |
105 |
|
111 |
|
Lines 246-248
Link Here
|
246 |
// shouldn't ever be called - there is no Unicode-specific calls on *nix |
252 |
// shouldn't ever be called - there is no Unicode-specific calls on *nix |
247 |
return JNI_FALSE; |
253 |
return JNI_FALSE; |
248 |
} |
254 |
} |
|
|
255 |
|
256 |
/* |
257 |
* Class: org_eclipse_core_internal_filesystem_local_LocalFileNatives |
258 |
* Method: internalReadlink |
259 |
* Signature: ([B)[B |
260 |
*/ |
261 |
JNIEXPORT jbyteArray JNICALL Java_org_eclipse_core_internal_filesystem_local_LocalFileNatives_internalReadlink |
262 |
(JNIEnv *env, jclass clazz, jbyteArray fileName) { |
263 |
jbyteArray jb; |
264 |
#ifdef LINUX |
265 |
int len; |
266 |
jbyte *sourceFile; |
267 |
char buf[256]; |
268 |
|
269 |
len = 0; |
270 |
sourceFile = getByteArray(env, fileName); |
271 |
len = readlink((const char*)sourceFile, buf, 256); |
272 |
if (len>0) { |
273 |
jb=(*env)->NewByteArray(env, len); |
274 |
(*env)->SetByteArrayRegion(env, jb, 0, len, (jbyte *)buf); |
275 |
} else { |
276 |
jb=(*env)->NewByteArray(env, 0); |
277 |
} |
278 |
|
279 |
free(sourceFile); |
280 |
#else |
281 |
jb=(*env)->NewByteArray(env, 0); |
282 |
#endif |
283 |
return jb; |
284 |
} |