Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 150214 Details for
Bug 290201
Symbolic link support doesn't work on the Mac
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch_v03
290201_v03.txt (text/plain), 11.14 KB, created by
Pawel Pogorzelski
on 2009-10-22 05:49:36 EDT
(
hide
)
Description:
Patch_v03
Filename:
MIME Type:
Creator:
Pawel Pogorzelski
Created:
2009-10-22 05:49:36 EDT
Size:
11.14 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.filesystem >Index: natives/macosx/Makefile >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/natives/macosx/Makefile,v >retrieving revision 1.4 >diff -u -r1.4 Makefile >--- natives/macosx/Makefile 6 Jan 2009 13:17:19 -0000 1.4 >+++ natives/macosx/Makefile 22 Oct 2009 09:50:28 -0000 >@@ -12,8 +12,7 @@ > LIB_NAME = liblocalfile_1_0_0.jnilib > > core: >- cc -I /System/Library/Frameworks/JavaVM.framework/Headers localfile.c -o $(LIB_NAME) -bundle -framework JavaVM -framework CoreServices -arch i386 -arch ppc -arch x86_64 >+ cc -I /System/Library/Frameworks/JavaVM.framework/Headers localfile.c -o $(LIB_NAME) -bundle -framework JavaVM -framework CoreServices -arch i386 -arch ppc -arch x86_64 -mmacosx-version-min=10.4 > > clean: >- rm *.o >- >\ No newline at end of file >+ rm *.jnilib >Index: natives/macosx/localfile.c >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/natives/macosx/localfile.c,v >retrieving revision 1.3 >diff -u -r1.3 localfile.c >--- natives/macosx/localfile.c 5 Oct 2005 15:29:22 -0000 1.3 >+++ natives/macosx/localfile.c 22 Oct 2009 09:50:29 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -23,6 +23,7 @@ > > #define USE_IMMUTABLE_FLAG 1 > #define USE_ARCHIVE_FLAG 0 >+#define EFS_SYMLINK_SUPPORT 1 > > /* > * Get a null-terminated byte array from a java char array. >@@ -120,6 +121,31 @@ > return JNI_TRUE; > } > >+#if defined(EFS_SYMLINK_SUPPORT) >+/* >+ * Set symbolic link information in IFileInfo >+ */ >+jboolean setSymlinkInFileInfo (JNIEnv *env, jobject fileInfo, jstring linkTarget) { >+ jclass cls; >+ jmethodID mid; >+ >+ cls = (*env)->GetObjectClass(env, fileInfo); >+ if (cls == 0) return JNI_FALSE; >+ >+ // set symlink attribute >+ mid = (*env)->GetMethodID(env, cls, "setAttribute", "(IZ)V"); >+ if (mid == 0) return JNI_FALSE; >+ (*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_SYMLINK, JNI_TRUE); >+ >+ // set link target >+ mid = (*env)->GetMethodID(env, cls, "setStringAttribute", "(ILjava/lang/String;)V"); >+ if (mid == 0) return JNI_FALSE; >+ (*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_LINK_TARGET, linkTarget); >+ >+ return JNI_TRUE; >+} >+#endif >+ > /* > * Class: org_eclipse_core_internal_filesystem_local_LocalFileNatives > * Method: internalGetFileInfo >@@ -141,15 +167,38 @@ > > struct stat info; > jint code; >+ jstring linkTarget = NULL; > > /* get stat */ > char *name= (char*) getUTF8ByteArray(env, target); >+#if defined(EFS_SYMLINK_SUPPORT) >+ //do an lstat first to see if it is a symbolic link >+ code = lstat(name, &info); >+ if (code == 0 && (info.st_mode & S_IFLNK) == S_IFLNK) { >+ //symbolic link: read link target >+ char buf[PATH_MAX+1]; >+ int len; >+ len = readlink((const char*)name, buf, PATH_MAX); >+ if (len>0) { >+ buf[len]=0; >+ } else { >+ buf[0]=0; >+ } >+ // Mac OS encodes symlink target using UTF-8, ignoring platform default >+ linkTarget = (*env)->NewStringUTF(env, buf); >+ setSymlinkInFileInfo(env, fileInfo, linkTarget); >+ >+ //stat link target (will fail for broken links) >+ code = stat((const char*)name, &info); >+ } >+#else > code = stat(name, &info); >+#endif > free(name); > > /* test if an error occurred */ > if (code == -1) >- return 0; >+ return JNI_FALSE; > return convertStatToFileInfo(env, info, fileInfo); > } > >Index: src/org/eclipse/core/internal/filesystem/local/LocalFileSystem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/LocalFileSystem.java,v >retrieving revision 1.18 >diff -u -r1.18 LocalFileSystem.java >--- src/org/eclipse/core/internal/filesystem/local/LocalFileSystem.java 27 Jun 2007 18:17:56 -0000 1.18 >+++ src/org/eclipse/core/internal/filesystem/local/LocalFileSystem.java 22 Oct 2009 09:50:29 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -101,7 +101,7 @@ > else if (os.equals(Constants.OS_LINUX) || (os.equals(Constants.OS_SOLARIS) && arch.equals(Constants.ARCH_SPARC))) > attributes |= EFS.ATTRIBUTE_EXECUTABLE | EFS.ATTRIBUTE_SYMLINK | EFS.ATTRIBUTE_LINK_TARGET; > else if (os.equals(Constants.OS_MACOSX) || os.equals(Constants.OS_HPUX) || os.equals(Constants.OS_QNX)) >- attributes |= EFS.ATTRIBUTE_EXECUTABLE; >+ attributes |= EFS.ATTRIBUTE_EXECUTABLE | EFS.ATTRIBUTE_SYMLINK | EFS.ATTRIBUTE_LINK_TARGET; > return attributes; > } > >#P org.eclipse.core.tests.resources >Index: src/org/eclipse/core/tests/filesystem/SymlinkTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/SymlinkTest.java,v >retrieving revision 1.9 >diff -u -r1.9 SymlinkTest.java >--- src/org/eclipse/core/tests/filesystem/SymlinkTest.java 21 Aug 2008 08:54:27 -0000 1.9 >+++ src/org/eclipse/core/tests/filesystem/SymlinkTest.java 22 Oct 2009 09:50:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. >+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -14,7 +14,7 @@ > *******************************************************************************/ > package org.eclipse.core.tests.filesystem; > >-import java.io.*; >+import java.io.OutputStream; > import org.eclipse.core.filesystem.*; > import org.eclipse.core.resources.IWorkspace; > import org.eclipse.core.resources.ResourcesPlugin; >@@ -48,8 +48,8 @@ > public static boolean isTestablePlatform() { > // A Platform is testable if it supports the "ln -s" command. > String os = Platform.getOS(); >- //currently we only support linux and solaris >- if (os.equals(Platform.OS_LINUX) || os.equals(Platform.OS_SOLARIS) >+ //currently we only support linux, solaris and mac os >+ if (os.equals(Platform.OS_LINUX) || os.equals(Platform.OS_SOLARIS) || os.equals(Platform.OS_MACOSX) > // ||os.equals(Platform.OS_AIX) > // ||os.equals(Platform.OS_HPUX) > // ||isWindowsVista() >@@ -295,7 +295,7 @@ > public void testSymlinkEnabled() { > String os = Platform.getOS(); > String arch = Platform.getOSArch(); >- if (Platform.OS_LINUX.equals(os) || (Platform.OS_SOLARIS.equals(os) && Platform.ARCH_SPARC.equals(arch))) { >+ if (Platform.OS_LINUX.equals(os) || (Platform.OS_SOLARIS.equals(os) && Platform.ARCH_SPARC.equals(arch)) || Platform.OS_MACOSX.equals(os)) { > assertTrue(haveSymlinks()); > } else { > assertFalse(haveSymlinks()); >@@ -332,30 +332,92 @@ > } > } > >- public void testSymlinkPutInfo() throws Exception { >+ public void testSymlinkPutLastModified() throws Exception { > if (!isTestablePlatform()) { > return; > } >+ if (Platform.OS_MACOSX.equals(Platform.getOS())) { >+ // flag EFS.SET_LAST_MODIFIED is set by java.io and it fails on Mac OS >+ return; >+ } > //check that putInfo() "writes through" the symlink > makeLinkStructure(); > long oldTime = iFile.getLastModified(); > long timeToSet = oldTime - 100000; > illFile.setLastModified(timeToSet); >- illFile.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); > llFile.putInfo(illFile, EFS.SET_ATTRIBUTES | EFS.SET_LAST_MODIFIED, getMonitor()); > iFile = aFile.fetchInfo(); > assertEquals(iFile.getLastModified(), timeToSet); >- assertTrue(iFile.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); > > oldTime = iDir.getLastModified(); > timeToSet = oldTime - 100000; > illDir.setLastModified(timeToSet); >- illDir.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); > llDir.putInfo(illDir, EFS.SET_ATTRIBUTES | EFS.SET_LAST_MODIFIED, getMonitor()); > iDir = aDir.fetchInfo(); > assertTrue(iDir.getLastModified() != oldTime); > assertEquals(iDir.getLastModified(), timeToSet); >+ if (haveSymlinks()) { >+ //check that link properties are maintained even through putInfo >+ illFile = llFile.fetchInfo(); >+ illDir = llDir.fetchInfo(); >+ assertTrue(illFile.getAttribute(EFS.ATTRIBUTE_SYMLINK)); >+ assertTrue(illDir.getAttribute(EFS.ATTRIBUTE_SYMLINK)); >+ assertEquals(illFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lFile"); >+ assertEquals(illDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lDir"); >+ } >+ } >+ >+ public void testSymlinkPutReadOnly() throws Exception { >+ if (!isTestablePlatform()) { >+ return; >+ } >+ //check that putInfo() "writes through" the symlink >+ makeLinkStructure(); >+ illFile.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); >+ llFile.putInfo(illFile, EFS.SET_ATTRIBUTES, getMonitor()); >+ iFile = aFile.fetchInfo(); >+ assertTrue(iFile.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); >+ >+ illFile.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false); >+ llFile.putInfo(illFile, EFS.SET_ATTRIBUTES, getMonitor()); >+ iFile = aFile.fetchInfo(); >+ assertFalse(iFile.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); >+ >+ illDir.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); >+ llDir.putInfo(illDir, EFS.SET_ATTRIBUTES, getMonitor()); >+ iDir = aDir.fetchInfo(); > assertTrue(iDir.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); >+ >+ illDir.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false); >+ llDir.putInfo(illDir, EFS.SET_ATTRIBUTES, getMonitor()); >+ iDir = aDir.fetchInfo(); >+ assertFalse(iDir.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); >+ if (haveSymlinks()) { >+ //check that link properties are maintained even through putInfo >+ illFile = llFile.fetchInfo(); >+ illDir = llDir.fetchInfo(); >+ assertTrue(illFile.getAttribute(EFS.ATTRIBUTE_SYMLINK)); >+ assertTrue(illDir.getAttribute(EFS.ATTRIBUTE_SYMLINK)); >+ assertEquals(illFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lFile"); >+ assertEquals(illDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lDir"); >+ } >+ } >+ >+ public void testSymlinkPutExecutable() throws Exception { >+ if (!isTestablePlatform()) { >+ return; >+ } >+ //check that putInfo() "writes through" the symlink >+ makeLinkStructure(); >+ illFile.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, true); >+ llFile.putInfo(illFile, EFS.SET_ATTRIBUTES, getMonitor()); >+ iFile = aFile.fetchInfo(); >+ assertTrue(iFile.getAttribute(EFS.ATTRIBUTE_EXECUTABLE)); >+ >+ illDir.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, false); >+ llDir.putInfo(illDir, EFS.SET_ATTRIBUTES, getMonitor()); >+ iDir = aDir.fetchInfo(); >+ assertFalse(iDir.getAttribute(EFS.ATTRIBUTE_EXECUTABLE)); > if (haveSymlinks()) { > //check that link properties are maintained even through putInfo > illFile = llFile.fetchInfo();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 290201
:
150138
|
150139
|
150210
|
150211
| 150214 |
150215
|
150216
|
150217
|
152830
|
152832