View | Details | Raw Unified | Return to bug 290318
Collapse All | Expand All

(-)src/org/eclipse/core/tests/filesystem/SymlinkTest.java (-9 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2007, 2009 Wind River Systems, Inc. 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 14-20 Link Here
14
 *******************************************************************************/
14
 *******************************************************************************/
15
package org.eclipse.core.tests.filesystem;
15
package org.eclipse.core.tests.filesystem;
16
16
17
import java.io.*;
17
import java.io.OutputStream;
18
import org.eclipse.core.filesystem.*;
18
import org.eclipse.core.filesystem.*;
19
import org.eclipse.core.resources.IWorkspace;
19
import org.eclipse.core.resources.IWorkspace;
20
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.resources.ResourcesPlugin;
Lines 115-127 Link Here
115
		ensureDoesNotExist(aFile);
115
		ensureDoesNotExist(aFile);
116
		fetchFileInfos();
116
		fetchFileInfos();
117
117
118
		assertFalse(ilFile.exists());
118
		assertTrue(ilFile.exists());
119
		assertFalse(ilFile.isDirectory());
119
		assertFalse(ilFile.isDirectory());
120
		assertFalse(illFile.exists());
120
		assertTrue(illFile.exists());
121
		assertFalse(illFile.isDirectory());
121
		assertFalse(illFile.isDirectory());
122
		assertFalse(ilDir.exists());
122
		assertTrue(ilDir.exists());
123
		assertFalse(ilDir.isDirectory());
123
		assertFalse(ilDir.isDirectory());
124
		assertFalse(illDir.exists());
124
		assertTrue(illDir.exists());
125
		assertFalse(illDir.isDirectory());
125
		assertFalse(illDir.isDirectory());
126
		assertEquals(ilFile.getLastModified(), 0);
126
		assertEquals(ilFile.getLastModified(), 0);
127
		assertEquals(ilFile.getLength(), 0);
127
		assertEquals(ilFile.getLength(), 0);
Lines 133-144 Link Here
133
		assertEquals(illDir.getLength(), 0);
133
		assertEquals(illDir.getLength(), 0);
134
		if (haveSymlinks()) {
134
		if (haveSymlinks()) {
135
			assertTrue(ilFile.getAttribute(EFS.ATTRIBUTE_SYMLINK));
135
			assertTrue(ilFile.getAttribute(EFS.ATTRIBUTE_SYMLINK));
136
			assertFalse(ilFile.getAttribute(EFS.ATTRIBUTE_ACCESSIBLE));
136
			assertEquals(ilFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "aFile");
137
			assertEquals(ilFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "aFile");
137
			assertTrue(ilDir.getAttribute(EFS.ATTRIBUTE_SYMLINK));
138
			assertTrue(ilDir.getAttribute(EFS.ATTRIBUTE_SYMLINK));
139
			assertFalse(ilDir.getAttribute(EFS.ATTRIBUTE_ACCESSIBLE));
138
			assertEquals(ilDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "aDir");
140
			assertEquals(ilDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "aDir");
139
			assertTrue(illFile.getAttribute(EFS.ATTRIBUTE_SYMLINK));
141
			assertTrue(illFile.getAttribute(EFS.ATTRIBUTE_SYMLINK));
142
			assertFalse(illFile.getAttribute(EFS.ATTRIBUTE_ACCESSIBLE));
140
			assertEquals(illFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lFile");
143
			assertEquals(illFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lFile");
141
			assertTrue(illDir.getAttribute(EFS.ATTRIBUTE_SYMLINK));
144
			assertTrue(illDir.getAttribute(EFS.ATTRIBUTE_SYMLINK));
145
			assertFalse(illDir.getAttribute(EFS.ATTRIBUTE_ACCESSIBLE));
142
			assertEquals(illDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lDir");
146
			assertEquals(illDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lDir");
143
		}
147
		}
144
	}
148
	}
Lines 170-176 Link Here
170
		mkLink(baseStore, "l2", "l1", false);
174
		mkLink(baseStore, "l2", "l1", false);
171
		IFileStore l1 = baseStore.getChild("l1");
175
		IFileStore l1 = baseStore.getChild("l1");
172
		IFileInfo i1 = l1.fetchInfo();
176
		IFileInfo i1 = l1.fetchInfo();
173
		assertFalse(i1.exists());
177
		assertTrue(i1.exists());
174
		assertFalse(i1.isDirectory());
178
		assertFalse(i1.isDirectory());
175
		if (haveSymlinks()) {
179
		if (haveSymlinks()) {
176
			assertTrue(i1.getAttribute(EFS.ATTRIBUTE_SYMLINK));
180
			assertTrue(i1.getAttribute(EFS.ATTRIBUTE_SYMLINK));
Lines 192-198 Link Here
192
			assertTrue(exceptionThrown);
196
			assertTrue(exceptionThrown);
193
			assertTrue(i1.getAttribute(EFS.ATTRIBUTE_READ_ONLY));
197
			assertTrue(i1.getAttribute(EFS.ATTRIBUTE_READ_ONLY));
194
		}
198
		}
195
		assertFalse(i1.exists());
199
		assertTrue(i1.exists());
196
200
197
		i1.setLastModified(12345);
201
		i1.setLastModified(12345);
198
		exceptionThrown = false;
202
		exceptionThrown = false;
Lines 205-211 Link Here
205
		//FIXME bug: putInfo neither sets attributes nor throws an exception for broken symbolic links
209
		//FIXME bug: putInfo neither sets attributes nor throws an exception for broken symbolic links
206
		//assertTrue(exceptionThrown);
210
		//assertTrue(exceptionThrown);
207
		//assertEquals(i1.getLastModified(), 12345);
211
		//assertEquals(i1.getLastModified(), 12345);
208
		assertFalse(i1.exists());
212
		assertTrue(i1.exists());
209
213
210
		l1.delete(EFS.NONE, getMonitor());
214
		l1.delete(EFS.NONE, getMonitor());
211
		infos = baseStore.childInfos(EFS.NONE, getMonitor());
215
		infos = baseStore.childInfos(EFS.NONE, getMonitor());
(-)natives/localfile.h (-1 / +3 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 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 35-40 Link Here
35
#define ATTRIBUTE_SYMLINK 0x20l
35
#define ATTRIBUTE_SYMLINK 0x20l
36
#undef ATTRIBUTE_LINK_TARGET
36
#undef ATTRIBUTE_LINK_TARGET
37
#define ATTRIBUTE_LINK_TARGET 0x40l
37
#define ATTRIBUTE_LINK_TARGET 0x40l
38
#undef ATTRIBUTE_ACCESSIBLE
39
#define ATTRIBUTE_ACCESSIBLE 0x80l
38
#undef SET_ATTRIBUTES
40
#undef SET_ATTRIBUTES
39
#define SET_ATTRIBUTES 0x01l
41
#define SET_ATTRIBUTES 0x01l
40
#undef SET_LAST_MODIFIED
42
#undef SET_LAST_MODIFIED
(-)src/org/eclipse/core/filesystem/EFS.java (-4 / +22 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 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 170-178 Link Here
170
	 * <p>
170
	 * <p>
171
	 * Broken symbolic links (which do not reference any valid file or directory)
171
	 * Broken symbolic links (which do not reference any valid file or directory)
172
	 * are being returned by {@link IFileStore#childInfos(int, IProgressMonitor)},
172
	 * are being returned by {@link IFileStore#childInfos(int, IProgressMonitor)},
173
	 * but {@link IFileInfo#exists()} returns <code>false</code> for these.
173
	 * and {@link IFileInfo#exists()} returns <code>true</code> for these. The fact
174
	 * Operations like reading or writing on broken symbolic links throw 
174
	 * whether link is broken can be checked by calling {@link IFileInfo#getAttribute(int)}
175
	 * a "file not found" exception.  
175
	 * with {@link #ATTRIBUTE_ACCESSIBLE} which returns <code>false</code> in such
176
	 * cases. Operations like reading or writing on broken symbolic links throw 
177
	 * a "file not found" exception.
176
	 * </p>
178
	 * </p>
177
	 * 
179
	 * 
178
	 * @see IFileStore#fetchInfo()
180
	 * @see IFileStore#fetchInfo()
Lines 202-207 Link Here
202
	public static final int ATTRIBUTE_LINK_TARGET = 1 << 6;
204
	public static final int ATTRIBUTE_LINK_TARGET = 1 << 6;
203
205
204
	/**
206
	/**
207
	 * Attribute constant (value 1 &lt;&lt;7) indicating file accessibility.
208
	 * This attribute is set to <code>false</code> by file system implementation in
209
	 * case the file is present but its content cannot be reached.
210
	 * <p>
211
	 * Note that setting the accessible attribute does not cause a file to be
212
	 * marked as inaccessible. Rather, this attribute is set by file system
213
	 * implementations based on the current state of a file.
214
	 * </p>
215
	 * 
216
	 * @see IFileInfo#getAttribute(int)
217
	 * @see FileInfo#setAttribute(int, boolean)
218
	 * @since org.eclipse.core.filesystem 1.3
219
	 */
220
	public static final int ATTRIBUTE_ACCESSIBLE = 1 << 7;
221
222
	/**
205
	 * Scheme constant (value "file") indicating the local file system scheme.
223
	 * Scheme constant (value "file") indicating the local file system scheme.
206
	 * @see EFS#getLocalFileSystem()
224
	 * @see EFS#getLocalFileSystem()
207
	 */
225
	 */
(-)natives/unix/localfile.c (-7 / +42 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 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 68-74 Link Here
68
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_filesystem_local_LocalFileNatives_nativeAttributes
68
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_filesystem_local_LocalFileNatives_nativeAttributes
69
  (JNIEnv *env, jclass clazz) {
69
  (JNIEnv *env, jclass clazz) {
70
#if defined(EFS_SYMLINK_SUPPORT)
70
#if defined(EFS_SYMLINK_SUPPORT)
71
    return ATTRIBUTE_READ_ONLY | ATTRIBUTE_EXECUTABLE | ATTRIBUTE_SYMLINK | ATTRIBUTE_LINK_TARGET;
71
    return ATTRIBUTE_READ_ONLY | ATTRIBUTE_EXECUTABLE | ATTRIBUTE_SYMLINK | ATTRIBUTE_LINK_TARGET | ATTRIBUTE_ACCESSIBLE;
72
#else
72
#else
73
    return ATTRIBUTE_READ_ONLY | ATTRIBUTE_EXECUTABLE;
73
    return ATTRIBUTE_READ_ONLY | ATTRIBUTE_EXECUTABLE;
74
#endif
74
#endif
Lines 101-107 Link Here
101
    mid = (*env)->GetMethodID(env, cls, "setExists", "(Z)V");
101
    mid = (*env)->GetMethodID(env, cls, "setExists", "(Z)V");
102
    if (mid == 0) return JNI_FALSE;
102
    if (mid == 0) return JNI_FALSE;
103
    (*env)->CallVoidMethod(env, fileInfo, mid, JNI_TRUE);
103
    (*env)->CallVoidMethod(env, fileInfo, mid, JNI_TRUE);
104
	
104
105
    // set accessible attribute
106
    mid = (*env)->GetMethodID(env, cls, "setAttribute", "(IZ)V");
107
    if (mid == 0) return JNI_FALSE;
108
    (*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_ACCESSIBLE, JNI_TRUE);
109
105
	// last modified
110
	// last modified
106
    mid = (*env)->GetMethodID(env, cls, "setLastModified", "(J)V");
111
    mid = (*env)->GetMethodID(env, cls, "setLastModified", "(J)V");
107
    if (mid == 0) return JNI_FALSE;
112
    if (mid == 0) return JNI_FALSE;
Lines 156-161 Link Here
156
    mid = (*env)->GetMethodID(env, cls, "setStringAttribute", "(ILjava/lang/String;)V");
161
    mid = (*env)->GetMethodID(env, cls, "setStringAttribute", "(ILjava/lang/String;)V");
157
    if (mid == 0) return JNI_FALSE;
162
    if (mid == 0) return JNI_FALSE;
158
    (*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_LINK_TARGET, linkTarget);
163
    (*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_LINK_TARGET, linkTarget);
164
165
    return JNI_TRUE;
166
}
167
168
/*
169
 * Set exists and non accessible in IFileInfo 
170
 */
171
jboolean setExistsNonAccessibleInFileInfo (JNIEnv *env, jobject fileInfo) {
172
    jclass cls;
173
    jmethodID mid;
174
175
    cls = (*env)->GetObjectClass(env, fileInfo);
176
    if (cls == 0) return JNI_FALSE;
177
178
    // exists
179
    mid = (*env)->GetMethodID(env, cls, "setExists", "(Z)V");
180
    if (mid == 0) return JNI_FALSE;
181
    (*env)->CallVoidMethod(env, fileInfo, mid, JNI_TRUE);
182
183
	// set accessible attribute to false
184
    mid = (*env)->GetMethodID(env, cls, "setAttribute", "(IZ)V");
185
    if (mid == 0) return JNI_FALSE;
186
    (*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_ACCESSIBLE, JNI_FALSE);
187
188
     return JNI_TRUE;
159
}
189
}
160
#endif
190
#endif
161
191
Lines 175-184 Link Here
175
	/* get stat */
205
	/* get stat */
176
	name = getByteArray(env, target);
206
	name = getByteArray(env, target);
177
#if defined(EFS_SYMLINK_SUPPORT)
207
#if defined(EFS_SYMLINK_SUPPORT)
178
	//do an lstat first to see if it is a symbolic link
208
	// do an lstat first to see if it is a symbolic link
179
	code = lstat((const char*)name, &info);
209
	code = lstat((const char*)name, &info);
180
	if (code == 0 && (info.st_mode & S_IFLNK) == S_IFLNK) {
210
	if (code == 0 && (info.st_mode & S_IFLNK) == S_IFLNK) {
181
		//symbolic link: read link target
211
		// symbolic link: read link target
182
		char buf[PATH_MAX+1];
212
		char buf[PATH_MAX+1];
183
		int len;
213
		int len;
184
		jbyteArray barr;
214
		jbyteArray barr;
Lines 192-206 Link Here
192
		linkTarget = getString(env, barr);
222
		linkTarget = getString(env, barr);
193
		setSymlinkInFileInfo(env, fileInfo, linkTarget);
223
		setSymlinkInFileInfo(env, fileInfo, linkTarget);
194
224
195
		//stat link target (will fail for broken links)
225
		// stat link target
196
		code = stat((const char*)name, &info);
226
		code = stat((const char*)name, &info);
227
228
		// link is broken
229
		if (code == -1) {
230
			return setExistsNonAccessibleInFileInfo(env, fileInfo);
231
		}
197
	}
232
	}
198
#else
233
#else
199
	code = stat((const char*)name, &info);
234
	code = stat((const char*)name, &info);
200
#endif
235
#endif
201
	free(name);
236
	free(name);
202
237
203
	/* test if an error occurred */
238
	// test if an error occurred
204
	if (code == -1)
239
	if (code == -1)
205
	  return 0;
240
	  return 0;
206
	return convertStatToFileInfo(env, info, fileInfo);
241
	return convertStatToFileInfo(env, info, fileInfo);
(-)src/org/eclipse/core/internal/filesystem/local/LocalFileSystem.java (-4 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 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 97-107 Link Here
97
		String os = getOS();
97
		String os = getOS();
98
		String arch = System.getProperty("osgi.arch", ""); //$NON-NLS-1$ //$NON-NLS-2$
98
		String arch = System.getProperty("osgi.arch", ""); //$NON-NLS-1$ //$NON-NLS-2$
99
		if (os.equals(Constants.OS_WIN32))
99
		if (os.equals(Constants.OS_WIN32))
100
			attributes |= EFS.ATTRIBUTE_ARCHIVE | EFS.ATTRIBUTE_HIDDEN;
100
			attributes |= EFS.ATTRIBUTE_ARCHIVE | EFS.ATTRIBUTE_HIDDEN | EFS.ATTRIBUTE_ACCESSIBLE;
101
		else if (os.equals(Constants.OS_LINUX) || (os.equals(Constants.OS_SOLARIS) && arch.equals(Constants.ARCH_SPARC)))
101
		else if (os.equals(Constants.OS_LINUX) || (os.equals(Constants.OS_SOLARIS) && arch.equals(Constants.ARCH_SPARC)))
102
			attributes |= EFS.ATTRIBUTE_EXECUTABLE | EFS.ATTRIBUTE_SYMLINK | EFS.ATTRIBUTE_LINK_TARGET;
102
			attributes |= EFS.ATTRIBUTE_EXECUTABLE | EFS.ATTRIBUTE_SYMLINK | EFS.ATTRIBUTE_LINK_TARGET | EFS.ATTRIBUTE_ACCESSIBLE;
103
		else if (os.equals(Constants.OS_MACOSX) || os.equals(Constants.OS_HPUX) || os.equals(Constants.OS_QNX))
103
		else if (os.equals(Constants.OS_MACOSX) || os.equals(Constants.OS_HPUX) || os.equals(Constants.OS_QNX))
104
			attributes |= EFS.ATTRIBUTE_EXECUTABLE;
104
			attributes |= EFS.ATTRIBUTE_EXECUTABLE | EFS.ATTRIBUTE_ACCESSIBLE;
105
		return attributes;
105
		return attributes;
106
	}
106
	}
107
107
(-)src/org/eclipse/core/filesystem/provider/FileInfo.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 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 35-41 Link Here
35
	/**
35
	/**
36
	 * Bit field of file attributes
36
	 * Bit field of file attributes
37
	 */
37
	 */
38
	private int attributes = 0;
38
	private int attributes = EFS.ATTRIBUTE_ACCESSIBLE;
39
39
40
	/**
40
	/**
41
	 * The last modified time.
41
	 * The last modified time.
(-)natives/unix/linux/Makefile_new (+32 lines)
Added Link Here
1
#**********************************************************************
2
# Copyright (c) 2000, 2004 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials 
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#********************************************************************** 
8
#
9
# makefile for libcore.so
10
11
CORE.C = ../localfile.c
12
CORE.O = localfile.o
13
LIB_NAME = liblocalfile.so
14
LIB_NAME_FULL = liblocalfile_1_0_0.so
15
16
#Set this to be your OS type
17
OS_TYPE = linux
18
19
#Set this to be the location of your JRE
20
JAVA_HOME = /home/tzarna/java_install/j2sdk1.4.2_17
21
22
JDK_INCLUDE = -I ${JAVA_HOME}/include -I ${JAVA_HOME}/include/${OS_TYPE}
23
COMMON_INCLUDE = -I include
24
#OPT_FLAGS=-g
25
OPT_FLAGS=-O -s -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
26
27
core :
28
	gcc $(OPT_FLAGS) -fPIC -c $(JDK_INCLUDE) $(COMMON_INCLUDE) -o $(CORE.O) $(CORE.C)
29
	gcc $(OPT_FLAGS) -shared -Wl,-soname,$(LIB_NAME) -o $(LIB_NAME_FULL) $(CORE.O) -lc
30
31
clean :
32
	rm *.o *.so
(-)src/org/eclipse/core/resources/IResource.java (-3 / +3 lines)
Lines 1595-1603 Link Here
1595
1595
1596
	/**
1596
	/**
1597
	 * Returns whether this resource is accessible.  For files and folders,
1597
	 * Returns whether this resource is accessible.  For files and folders,
1598
	 * this is equivalent to existing; for projects, 
1598
	 * this is equivalent to existing and having reachable content; for projects, 
1599
	 * this is equivalent to existing and being open.  The workspace root
1599
	 * this is equivalent to existing, being open and having reachable content.
1600
	 * is always accessible.
1600
	 * The workspace root is always accessible.
1601
	 *
1601
	 *
1602
	 * @return <code>true</code> if this resource is accessible, and
1602
	 * @return <code>true</code> if this resource is accessible, and
1603
	 *   <code>false</code> otherwise
1603
	 *   <code>false</code> otherwise
(-)src/org/eclipse/core/resources/ResourceAttributes.java (-2 / +26 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 Red Hat Incorporated and others
2
 * Copyright (c) 2004, 2009 Red Hat Incorporated 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 103-109 Link Here
103
	}
103
	}
104
104
105
	/**
105
	/**
106
	 * Returns whether this ResourceAttributes object is marked read only.
106
	 * Returns whether this ResourceAttributes object is marked as symbolic link.
107
	 *
107
	 *
108
	 * @return <code>true</code> if this resource is marked as symbolic link, 
108
	 * @return <code>true</code> if this resource is marked as symbolic link, 
109
	 *		<code>false</code> otherwise
109
	 *		<code>false</code> otherwise
Lines 115-120 Link Here
115
	}
115
	}
116
116
117
	/**
117
	/**
118
	 * Returns whether this ResourceAttributes object is marked as accessible.
119
	 * 
120
	 * @return <code>true</code> if this resource is marked as accessible, 
121
	 *		<code>false</code> otherwise
122
	 * @see #setAccessible(boolean)
123
	 * @since 3.6
124
	 */
125
	public boolean isAccessible() {
126
		return (attributes & EFS.ATTRIBUTE_ACCESSIBLE) != 0;
127
	}
128
129
	/**
118
	 * Sets or unsets whether this ResourceAttributes object is marked archive.
130
	 * Sets or unsets whether this ResourceAttributes object is marked archive.
119
	 *
131
	 *
120
	 * @param archive <code>true</code> to set it to be archive, 
132
	 * @param archive <code>true</code> to set it to be archive, 
Lines 182-187 Link Here
182
	}
194
	}
183
195
184
	/**
196
	/**
197
	 * Sets or unsets whether this ResourceAttributes object is marked as accessible.
198
	 *
199
	 * @param accessible <code>true</code> to set it to be marked as accessible, 
200
	 *		<code>false</code> to unset
201
	 * @see #isAccessible()
202
	 * @since 3.6
203
	 */
204
	public void setAccessible(boolean accessible) {
205
		set(EFS.ATTRIBUTE_ACCESSIBLE, accessible);
206
	}
207
208
	/**
185
	 * Returns a string representation of the attributes, suitable 
209
	 * Returns a string representation of the attributes, suitable 
186
	 * for debugging purposes only.
210
	 * for debugging purposes only.
187
	 */
211
	 */
(-)src/org/eclipse/core/internal/resources/Resource.java (-1 / +5 lines)
Lines 1436-1442 Link Here
1436
	 * @see IResource#isAccessible()
1436
	 * @see IResource#isAccessible()
1437
	 */
1437
	 */
1438
	public boolean isAccessible() {
1438
	public boolean isAccessible() {
1439
		return exists();
1439
		if (exists()) {
1440
			ResourceAttributes attributes = getLocalManager().attributes(this);
1441
			return attributes != null && attributes.isAccessible();
1442
		}
1443
		return false;
1440
	}
1444
	}
1441
1445
1442
	/* (non-Javadoc)
1446
	/* (non-Javadoc)
(-)src/org/eclipse/core/internal/utils/FileUtil.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 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 144-149 Link Here
144
		attributes.setExecutable(fileInfo.getAttribute(EFS.ATTRIBUTE_EXECUTABLE));
144
		attributes.setExecutable(fileInfo.getAttribute(EFS.ATTRIBUTE_EXECUTABLE));
145
		attributes.setHidden(fileInfo.getAttribute(EFS.ATTRIBUTE_HIDDEN));
145
		attributes.setHidden(fileInfo.getAttribute(EFS.ATTRIBUTE_HIDDEN));
146
		attributes.setSymbolicLink(fileInfo.getAttribute(EFS.ATTRIBUTE_SYMLINK));
146
		attributes.setSymbolicLink(fileInfo.getAttribute(EFS.ATTRIBUTE_SYMLINK));
147
		attributes.setAccessible(fileInfo.getAttribute(EFS.ATTRIBUTE_ACCESSIBLE));
147
		return attributes;
148
		return attributes;
148
	}
149
	}
149
150
(-)plugin.xml (+17 lines)
Lines 349-354 Link Here
349
         </enablement>
349
         </enablement>
350
      </decorator>
350
      </decorator>
351
      <decorator
351
      <decorator
352
            lightweight="true"
353
            adaptable="true"
354
            location="BOTTOM_RIGHT"
355
            label="%DecoratorInaccessibleResource.label"
356
            class="org.eclipse.ui.internal.ide.InaccessibleResourceDecorator"
357
            state="true"
358
            id="org.eclipse.ui.InaccessibleResourceDecorator">
359
         <description>
360
            %DecoratorInaccessibleResource.description
361
         </description>
362
         <enablement>
363
            <objectClass
364
                  name="org.eclipse.core.resources.IResource">
365
            </objectClass>
366
         </enablement>
367
      </decorator>
368
      <decorator
352
            adaptable="false"
369
            adaptable="false"
353
            class="org.eclipse.ui.internal.ide.ContentTypeDecorator"
370
            class="org.eclipse.ui.internal.ide.ContentTypeDecorator"
354
            id="org.eclipse.ui.ContentTypeDecorator"
371
            id="org.eclipse.ui.ContentTypeDecorator"
(-)plugin.properties (+2 lines)
Lines 92-97 Link Here
92
GoToResourceAction.label = &Resource...
92
GoToResourceAction.label = &Resource...
93
DecoratorLinkedResource.label = Linked Resources
93
DecoratorLinkedResource.label = Linked Resources
94
DecoratorLinkedResource.description = Adds an icon decoration to linked resources.
94
DecoratorLinkedResource.description = Adds an icon decoration to linked resources.
95
DecoratorInaccessibleResource.label = Inaccessible Resources
96
DecoratorInaccessibleResource.description = Adds an icon decoration to inaccessible resources
95
DecoratorSpecificContentType.label = File Icons Based On Content Analysis
97
DecoratorSpecificContentType.label = File Icons Based On Content Analysis
96
DecoratorSpecificContentType.description = Displays an icon based on the examination of the contents of a file. This yields a more precise answer than one derived simply from the file name.
98
DecoratorSpecificContentType.description = Displays an icon based on the examination of the contents of a file. This yields a more precise answer than one derived simply from the file name.
97
OpenWorkspaceFileAction.label = Open Reso&urce...
99
OpenWorkspaceFileAction.label = Open Reso&urce...
(-)src/org/eclipse/ui/internal/ide/InaccessibleResourceDecorator.java (+86 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.ide;
12
13
import org.eclipse.core.resources.IResource;
14
import org.eclipse.jface.resource.ImageDescriptor;
15
import org.eclipse.jface.viewers.IDecoration;
16
import org.eclipse.jface.viewers.ILabelProviderListener;
17
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
18
import org.eclipse.ui.plugin.AbstractUIPlugin;
19
20
/**
21
 * A InaccessibleResourceDecorator decorates an element's image with a inaccessible
22
 * resource overlay. 
23
 * 
24
 * @since 3.6
25
 */
26
public class InaccessibleResourceDecorator implements ILightweightLabelDecorator {
27
28
    private static final ImageDescriptor LINK_WARNING;
29
30
    static {
31
        LINK_WARNING = AbstractUIPlugin.imageDescriptorFromPlugin(
32
                IDEWorkbenchPlugin.IDE_WORKBENCH,
33
                "$nl$/icons/full/ovr16/linkwarn_ovr.gif"); //$NON-NLS-1$
34
    }
35
36
    /**
37
     * Creates a new <code>InaccessibleResourceDecorator</code>.
38
     */
39
    public InaccessibleResourceDecorator() {
40
    }
41
42
    /**
43
     * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(ILabelProviderListener)
44
     */
45
    public void addListener(ILabelProviderListener listener) {
46
    }
47
48
    /**
49
     * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
50
     */
51
    public void dispose() {
52
        // no resources to dispose
53
    }
54
55
    /**
56
     * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
57
     */
58
    public boolean isLabelProperty(Object element, String property) {
59
        return false;
60
    }
61
62
    /**
63
     * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(ILabelProviderListener)
64
     */
65
    public void removeListener(ILabelProviderListener listener) {
66
    }
67
68
    /**
69
     * Adds the inaccessible overlay if the given element is an inaccessible resource.
70
     * 
71
     * @param element element to decorate
72
     * @param decoration  The decoration we are adding to
73
     * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(Object, IDecoration)
74
     */
75
	public void decorate(Object element, IDecoration decoration) {
76
77
		if (element instanceof IResource == false) {
78
			return;
79
		}
80
		IResource resource = (IResource) element;
81
		if (!resource.isAccessible()) {
82
			decoration.addOverlay(LINK_WARNING);
83
		}
84
	}
85
86
}

Return to bug 290318