### Eclipse Workspace Patch 1.0 #P org.eclipse.core.filesystem Index: src/org/eclipse/core/internal/filesystem/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/messages.properties,v retrieving revision 1.5 diff -u -r1.5 messages.properties --- src/org/eclipse/core/internal/filesystem/messages.properties 19 Oct 2006 22:00:40 -0000 1.5 +++ src/org/eclipse/core/internal/filesystem/messages.properties 1 Mar 2007 16:59:42 -0000 @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2005, 2006 IBM Corporation and others. +# Copyright (c) 2005, 2007 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 @@ -7,6 +7,7 @@ # # Contributors: # IBM Corporation - initial API and implementation +# Martin Oberhuber (Wind River) - [176051] Add generic file property support ############################################################################### ### File store plugin messages. @@ -31,3 +32,4 @@ noScheme=Must specify a URI scheme: notAFile = Resource is not a file: {0}. readOnlyParent = Parent of resource: {0} is marked as read-only. +labelLinkTarget = Link Target \ No newline at end of file Index: src/org/eclipse/core/internal/filesystem/Messages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/Messages.java,v retrieving revision 1.5 diff -u -r1.5 Messages.java --- src/org/eclipse/core/internal/filesystem/Messages.java 19 Oct 2006 22:00:40 -0000 1.5 +++ src/org/eclipse/core/internal/filesystem/Messages.java 1 Mar 2007 16:59:42 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2007 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Martin Oberhuber (Wind River) - [176051] Add generic file property support *******************************************************************************/ package org.eclipse.core.internal.filesystem; @@ -40,6 +41,7 @@ public static String noScheme; public static String notAFile; public static String readOnlyParent; + public static String labelLinkTarget; static { // initialize resource bundles Index: natives/unix/localfile.c =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/natives/unix/localfile.c,v retrieving revision 1.6 diff -u -r1.6 localfile.c --- natives/unix/localfile.c 1 Feb 2007 22:54:12 -0000 1.6 +++ natives/unix/localfile.c 1 Mar 2007 16:59:41 -0000 @@ -8,7 +8,8 @@ * Contributors: * IBM Corporation - initial API and implementation * Red Hat Incorporated - get/setResourceAttribute code - * Martin Oberhuber (Wind River) - [170317] add symbolic link support to API + * Martin Oberhuber (Wind River) - [170317] add symbolic link support to API + * Martin Oberhuber (Wind River) - [176051] Add generic file property support *******************************************************************************/ #include #include @@ -121,12 +122,16 @@ } #ifdef LINUX + /* * Set symbolic link information in IFileInfo */ jboolean setSymlinkInFileInfo (JNIEnv *env, jobject fileInfo, jstring linkTarget) { jclass cls; jmethodID mid; + jclass clsEFS; + jfieldID fidPROPERTY_LINK_TARGET; + jobject PROPERTY_LINK_TARGET; cls = (*env)->GetObjectClass(env, fileInfo); if (cls == 0) return JNI_FALSE; @@ -137,9 +142,17 @@ (*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_SYMLINK, JNI_TRUE); // set link target - mid = (*env)->GetMethodID(env, cls, "setStringAttribute", "(ILjava/lang/String;)V"); + mid = (*env)->GetMethodID(env, cls, "setProperty", "(Lorg/eclipse/core/filesystem/IFilePropertyType;Ljava/lang/Object;)V"); if (mid == 0) return JNI_FALSE; - (*env)->CallVoidMethod(env, fileInfo, mid, ATTRIBUTE_LINK_TARGET, linkTarget); + // looks like we cannot cache the PROPERTY_LINK_TARGET object, + // although it is final... I do not know why... + clsEFS = (*env)->FindClass(env, "org/eclipse/core/filesystem/EFS"); + if (clsEFS == 0) return JNI_FALSE; + fidPROPERTY_LINK_TARGET = (*env)->GetStaticFieldID(env, clsEFS, "PROPERTY_LINK_TARGET", "Lorg/eclipse/core/filesystem/IFilePropertyType;"); + if (fidPROPERTY_LINK_TARGET == 0) return JNI_FALSE; + PROPERTY_LINK_TARGET = (*env)->GetStaticObjectField(env, clsEFS, fidPROPERTY_LINK_TARGET); + if (PROPERTY_LINK_TARGET == 0) return JNI_FALSE; + (*env)->CallVoidMethod(env, fileInfo, mid, PROPERTY_LINK_TARGET, linkTarget); } #endif Index: src/org/eclipse/core/filesystem/IFileSystem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/IFileSystem.java,v retrieving revision 1.12 diff -u -r1.12 IFileSystem.java --- src/org/eclipse/core/filesystem/IFileSystem.java 19 Jul 2006 22:11:21 -0000 1.12 +++ src/org/eclipse/core/filesystem/IFileSystem.java 1 Mar 2007 16:59:42 -0000 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Martin Oberhuber (Wind River) - [176051] Add generic file property support *******************************************************************************/ package org.eclipse.core.filesystem; @@ -41,6 +42,29 @@ public int attributes(); /** + * Returns the extended file properties supported by this file system. + * + * @return the extended file properties supported by this file system. + * + * @since org.eclipse.core.filesystem 1.1 + */ + public IFilePropertyType[] getSupportedFileProperties(); + + /** + * Creates an empty file information object. The resulting information + * will represent a non-existent file with no name and no attributes set, + * and will be capable of holding extended file property information + * supported by this file system provider. + * + * @return an empty file information object capable of holding all information + * and properties supported by this file system. + * + * @see IFileStore#putInfo(IFileInfo, int, IProgressMonitor) + * @since org.eclipse.core.filesystem 1.1 + */ + public IFileInfo createFileInfo(); + + /** * Returns whether this file system supports deletion * * @return true if this file system allows deletion Index: src/org/eclipse/core/filesystem/IFileStore.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/IFileStore.java,v retrieving revision 1.22 diff -u -r1.22 IFileStore.java --- src/org/eclipse/core/filesystem/IFileStore.java 1 Feb 2007 22:54:12 -0000 1.22 +++ src/org/eclipse/core/filesystem/IFileStore.java 1 Mar 2007 16:59:42 -0000 @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [170317] add symbolic link support to API + * Martin Oberhuber (Wind River) - [176051] Add generic file property support *******************************************************************************/ package org.eclipse.core.filesystem; @@ -394,9 +395,8 @@ * The {@link EFS#SET_ATTRIBUTES} update flag controls * whether the file's attributes are changed. When this flag is specified, * the EFS#ATTRIBUTE_* values, with - * the exception of EFS#ATTRIBUTE_DIRECTORY, - * EFS#ATTRIBUTE_SYMLINK and - * EFS#ATTRIBUTE_LINK_TARGET, + * the exception of EFS#ATTRIBUTE_DIRECTORY and + * EFS#ATTRIBUTE_SYMLINK, * are set for this file. When this flag is not specified, changed attributes * on the provided file info are ignored. *

Index: src/org/eclipse/core/filesystem/EFS.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/EFS.java,v retrieving revision 1.14 diff -u -r1.14 EFS.java --- src/org/eclipse/core/filesystem/EFS.java 29 Jan 2007 23:21:08 -0000 1.14 +++ src/org/eclipse/core/filesystem/EFS.java 1 Mar 2007 16:59:42 -0000 @@ -8,12 +8,14 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [170317] add symbolic link support to API + * Martin Oberhuber (Wind River) - [176051] Add generic file property support *******************************************************************************/ package org.eclipse.core.filesystem; import java.net.URI; -import org.eclipse.core.filesystem.provider.FileInfo; +import org.eclipse.core.filesystem.provider.*; import org.eclipse.core.internal.filesystem.InternalFileSystemCore; +import org.eclipse.core.internal.filesystem.Messages; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -154,8 +156,8 @@ * If this attribute is true for a given {@link IFileInfo} * instance, a String value may be associated with the attribute * holding the symbolic link target. This link target can be - * retrieved with {@link IFileInfo#getStringAttribute(int)} with attribute - * type {@link #ATTRIBUTE_LINK_TARGET}. + * retrieved with {@link IFileInfo#getProperty(IFilePropertyType)} with property + * type {@link #PROPERTY_LINK_TARGET}. *

*

* Symbolic links are handled transparently, as implemented by the @@ -187,23 +189,27 @@ */ public static final int ATTRIBUTE_SYMLINK = 1 << 5; + /** @deprecated use {@link #PROPERTY_LINK_TARGET} instead */ + public static final int ATTRIBUTE_LINK_TARGET = 1 << 6; + /** - * Attribute constant (value 1 <<6) for a string attribute indicating the - * target file name of a symbolic link. - *

+ * Property type for a String property indicating the target file name of + * a symbolic link. *

- * Note that setting the link target attribute does not cause a symbolic + * Note that setting the link target property does not cause a symbolic * link to be created, or changed to link to a different file. Rather, this - * attribute is set by file system implementations based on the current + * property is set by file system implementations based on the current * state of a link. *

* - * @see IFileInfo#getStringAttribute(int) - * @see FileInfo#setStringAttribute(int, String) + * @see IFileInfo#getProperty(IPropertyType) + * @see FileInfo#setProperty(IPropertyType, Object) * @see #ATTRIBUTE_SYMLINK * @since org.eclipse.core.filesystem 1.1 */ - public static final int ATTRIBUTE_LINK_TARGET = 1 << 6; + public static final IFilePropertyType PROPERTY_LINK_TARGET = new FilePropertyType( + "org.eclipse.core.filesystem.PROPERTY_LINK_TARGET", String.class, //$NON-NLS-1$ + Messages.labelLinkTarget, false); /** * Scheme constant (value "file") indicating the local file system scheme. @@ -290,13 +296,21 @@ /** * Creates an empty file information object. The resulting information - * will represent a non-existent file with no name and no attributes set. + * will represent a non-existent file with no name and no attributes set, + * and capable of holding extended properties for any file system provider. + *

+ * The IFileInfo object returned may not be optimized for + * a particular file system provider, and using {@link IFileSystem#createFileInfo()} + * instead of this method is recommended when the file system to use the + * IFileInfo on is known in advance. + *

* * @see IFileStore#putInfo(IFileInfo, int, IProgressMonitor) + * @see IFileSystem#createFileInfo() * @return an empty file information object. */ public static IFileInfo createFileInfo() { - return new FileInfo(); + return new DefaultFileInfo(); } /** Index: src/org/eclipse/core/filesystem/IFileInfo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/IFileInfo.java,v retrieving revision 1.16 diff -u -r1.16 IFileInfo.java --- src/org/eclipse/core/filesystem/IFileInfo.java 30 Jan 2007 21:17:58 -0000 1.16 +++ src/org/eclipse/core/filesystem/IFileInfo.java 1 Mar 2007 16:59:42 -0000 @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [170317] add symbolic link support to API + * Martin Oberhuber (Wind River) - [176051] Add generic file property support *******************************************************************************/ package org.eclipse.core.filesystem; @@ -20,8 +21,9 @@ * on disk are not reflected in this object. At best, an IFileInfo represents a snapshot * of the state of a file at a particular moment in time. *

- * This interface is not intended to be implemented by clients. File store - * implementations should use the concrete class {@link org.eclipse.core.filesystem.provider.FileStore} + * This interface is not intended to be implemented by clients. File system + * providers should use the concrete class {@link org.eclipse.core.filesystem.provider.FileInfo} + * or a subclass of it instead, or subclass a specialized one for their own need. *

* * @see IFileStore#fetchInfo(int, IProgressMonitor) @@ -51,20 +53,35 @@ */ public abstract boolean getAttribute(int attribute); + /** @deprecated use {@link #getProperty(IFilePropertyType)} instead */ + public abstract String getStringAttribute(int attribute); + /** - * Returns the value of the specified attribute for this file. The attribute - * must be one of the EFS#ATTRIBUTE_* - * constants. Returns null if this file does not exist, - * could not be accessed, or the provided attribute does not apply to this + * Returns the value of the specified property for this file. + *

+ * Returns null if this file does not exist, could not be accessed, + * has not yet been queried or the requested property type does not apply to this * file system. - * - * @param attribute The kind of attribute to return. Currently only - * {@link EFS#ATTRIBUTE_LINK_TARGET} is supported. - * @return the value of the extended String attribute for this file. - * @see IFileSystem#attributes() + *

+ * @param type The kind of property to return. + * @return the value of the specified property for this file, or null + * if the property has not been set. + * @see IFileSystem#getSupportedFileProperties() * @since org.eclipse.core.filesystem 1.1 */ - public abstract String getStringAttribute(int attribute); + public abstract Object getProperty(IFilePropertyType type); + + /** + * Returns the list of extended property keys which are set for this file. + *

+ * Returns an empty array if this file does not exist, could not be + * accessed, or does not hold any extended properties. + *

+ * @return an array of file property keys which are set for this file. + * @see IFileSystem#getSupportedFileProperties() + * @since org.eclipse.core.filesystem 1.1 + */ + public abstract IFilePropertyType[] getPropertyKeys(); /** * Returns the last modified time for this file, or {@link EFS#NONE} 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.12 diff -u -r1.12 LocalFileSystem.java --- src/org/eclipse/core/internal/filesystem/local/LocalFileSystem.java 1 Feb 2007 22:54:12 -0000 1.12 +++ src/org/eclipse/core/internal/filesystem/local/LocalFileSystem.java 1 Mar 2007 16:59:42 -0000 @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [170317] add symbolic link support to API + * Martin Oberhuber (Wind River) - [176051] Add generic file property support *******************************************************************************/ package org.eclipse.core.internal.filesystem.local; @@ -40,6 +41,14 @@ * to indicate that the attributes have not yet been computed. */ private int attributes = -1; + + /** + * The file fileProperties supported by this file system. The initial value of + * null is used to indicate that the file fileProperties have not yet + * been computed. + */ + private IFilePropertyType[] fileProperties = null; + /** * The singleton instance of this file system. */ @@ -78,24 +87,44 @@ public int attributes() { if (attributes != -1) return attributes; - attributes = 0; - if (!LocalFileNatives.usingNatives()) - return attributes; - - //all known platforms with native implementation support the read only flag - attributes |= EFS.ATTRIBUTE_READ_ONLY; - //this must be kept in sync with the actual native implementations. - String os = getOS(); - if (os.equals(Platform.OS_WIN32)) - attributes |= EFS.ATTRIBUTE_ARCHIVE | EFS.ATTRIBUTE_HIDDEN; - else if (os.equals(Platform.OS_LINUX)) - attributes |= EFS.ATTRIBUTE_EXECUTABLE | EFS.ATTRIBUTE_SYMLINK | EFS.ATTRIBUTE_LINK_TARGET; - else if (os.equals(Platform.OS_MACOSX) || os.equals(Platform.OS_HPUX) || os.equals(Platform.OS_QNX)) - attributes |= EFS.ATTRIBUTE_EXECUTABLE; + //Local temporary variable in order to be thread-safe: If another thread queries the + //attributes while they are being computed, that other thread needs to compute + //attributes itself as well in order to obtain a correct result. + int newAttributes = 0; + if (LocalFileNatives.usingNatives()) { + //Without natives, no attributes are supported (value==0) + //all known platforms with native implementation support the read only flag + newAttributes |= EFS.ATTRIBUTE_READ_ONLY; + + //this must be kept in sync with the actual native implementations. + String os = getOS(); + if (os.equals(Platform.OS_WIN32)) + newAttributes |= EFS.ATTRIBUTE_ARCHIVE | EFS.ATTRIBUTE_HIDDEN; + else if (os.equals(Platform.OS_LINUX)) + newAttributes |= EFS.ATTRIBUTE_EXECUTABLE | EFS.ATTRIBUTE_SYMLINK; + else if (os.equals(Platform.OS_MACOSX) || os.equals(Platform.OS_HPUX) || os.equals(Platform.OS_QNX)) + newAttributes |= EFS.ATTRIBUTE_EXECUTABLE; + } + attributes = newAttributes; return attributes; } + /* (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileSystem#getSupportedFileProperties() + */ + public IFilePropertyType[] getSupportedFileProperties() { + if (fileProperties != null) { + return fileProperties; + } + if ((attributes() & EFS.ATTRIBUTE_SYMLINK) == 0) { + fileProperties = FileSystem.NO_FILE_PROPERTIES; + } else { + fileProperties = new IFilePropertyType[] { EFS.PROPERTY_LINK_TARGET }; + } + return fileProperties; + } + /* * (non-Javadoc) * @see org.eclipse.core.filesystem.IFileSystem#canDelete() Index: src/org/eclipse/core/internal/filesystem/local/LocalFileNatives.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/LocalFileNatives.java,v retrieving revision 1.9 diff -u -r1.9 LocalFileNatives.java --- src/org/eclipse/core/internal/filesystem/local/LocalFileNatives.java 21 Nov 2006 18:43:10 -0000 1.9 +++ src/org/eclipse/core/internal/filesystem/local/LocalFileNatives.java 1 Mar 2007 16:59:42 -0000 @@ -55,7 +55,7 @@ * @return The file info */ public static FileInfo fetchFileInfo(String fileName) { - FileInfo info = new FileInfo(); + FileInfo info = new LocalFileInfo(); if (isUnicode) internalGetFileInfoW(Convert.toPlatformChars(fileName), info); else Index: natives/localfile.h =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/natives/localfile.h,v retrieving revision 1.4 diff -u -r1.4 localfile.h --- natives/localfile.h 29 Jan 2007 23:21:08 -0000 1.4 +++ natives/localfile.h 1 Mar 2007 16:59:41 -0000 @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [170317] add symbolic link support to API + * Martin Oberhuber (Wind River) - [176051] Add generic file property support */ /* DO NOT EDIT THIS FILE - it is machine generated */ #include @@ -32,8 +33,6 @@ #define ATTRIBUTE_HIDDEN 0x10l #undef ATTRIBUTE_SYMLINK #define ATTRIBUTE_SYMLINK 0x20l -#undef ATTRIBUTE_LINK_TARGET -#define ATTRIBUTE_LINK_TARGET 0x40l #undef SET_ATTRIBUTES #define SET_ATTRIBUTES 0x01l #undef SET_LAST_MODIFIED Index: src/org/eclipse/core/filesystem/provider/FileSystem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/provider/FileSystem.java,v retrieving revision 1.12 diff -u -r1.12 FileSystem.java --- src/org/eclipse/core/filesystem/provider/FileSystem.java 9 Nov 2006 22:16:49 -0000 1.12 +++ src/org/eclipse/core/filesystem/provider/FileSystem.java 1 Mar 2007 16:59:42 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2007 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Martin Oberhuber (Wind River) - [176051] Add generic file property support *******************************************************************************/ package org.eclipse.core.filesystem.provider; @@ -30,6 +31,13 @@ */ public abstract class FileSystem extends PlatformObject implements IFileSystem { private String scheme; + + /** + * An empty array of IFilePropertyType[0] indicating that no extended + * properties are supported by a particular file system provider. + * @since org.eclipse.core.filesystem 1.1 + */ + public static IFilePropertyType[] NO_FILE_PROPERTIES = new FilePropertyType[0]; /** * Creates a new file system instance. @@ -51,6 +59,39 @@ } /** + * This is the default implementation of {@link IFileSystem#getSupportedFileProperties()}. + * This implementation always returns an empty array. + * Subclasses may override this method. + * + * @return An empty array, IFilePropertyType[0] + * + * @see IFileSystem#getSupportedFileProperties() + * @since org.eclipse.core.filesystem 1.1 + */ + public IFilePropertyType[] getSupportedFileProperties() { + return NO_FILE_PROPERTIES; + } + + /** + * Creates an empty file information object. + *

+ * This default implementation always returns a simple {@link FileInfo} + * object that is capable of holding standard file attributes, but not + * any extended file properties. Subclasses are encouraged to override + * this method when extended properties should be supported by the + * file system. + *

+ * + * @return an empty file information object. + * + * @see IFileSystem#createFileInfo() + * @since org.eclipse.core.filesystem 1.1 + */ + public IFileInfo createFileInfo() { + return new DefaultFileInfo(); + } + + /** * This is the default implementation of {@link IFileSystem#canDelete()}. * This implementation always returns false. * Subclasses may override this method. Index: src/org/eclipse/core/filesystem/provider/FileInfo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/provider/FileInfo.java,v retrieving revision 1.10 diff -u -r1.10 FileInfo.java --- src/org/eclipse/core/filesystem/provider/FileInfo.java 1 Feb 2007 22:54:12 -0000 1.10 +++ src/org/eclipse/core/filesystem/provider/FileInfo.java 1 Mar 2007 16:59:42 -0000 @@ -8,17 +8,24 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [170317] add symbolic link support to API + * Martin Oberhuber (Wind River) - [176051] Add generic file property support *******************************************************************************/ package org.eclipse.core.filesystem.provider; -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.*; /** - * This class should be used by file system providers in their implementation - * of API methods that return {@link IFileInfo} objects. + * This class (or a subclass of it) should be used by file system providers + * in their implementation of API methods that return {@link IFileInfo} objects. *

- * This class is not intended to be subclassed by clients. + * This implementation does not support any extended file properties. File + * system providers which do support generic properties should use + * {@link DefaultFileInfo} instead, or subclass from this class in order + * to provide an optimized implementation of + * {@link #getProperty(IFilePropertyType)}, + * {@link #getPropertyKeys()} and + * {@link #setProperty(IFilePropertyType, Object)} + * for their needs. *

* @since org.eclipse.core.filesystem 1.0 */ @@ -54,11 +61,6 @@ private String name = ""; //$NON-NLS-1$ /** - * The target file name if this is a symbolic link - */ - private String linkTarget = null; - - /** * Creates a new file information object with default values. */ public FileInfo() { @@ -77,6 +79,21 @@ } /** + * Creates a new file information object by copying an existing + * object's contents. + * + * @param info The existing file information object to copy. + * @since org.eclipse.core.filesystem 1.1 + */ + public FileInfo(FileInfo info) { + super(); + this.attributes = info.attributes; + this.lastModified = info.lastModified; + this.length = info.length; + this.name = info.name; + } + + /** * Convenience method to clear a masked region of the attributes bit field. * * @param mask The mask to be cleared @@ -122,10 +139,26 @@ */ public String getStringAttribute(int attribute) { if (attribute == EFS.ATTRIBUTE_LINK_TARGET) - return this.linkTarget; + return (String)getProperty(EFS.PROPERTY_LINK_TARGET); + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileInfo#getProperty(org.eclipse.core.filesystem.IFilePropertyType) + */ + public Object getProperty(IFilePropertyType type) { return null; } + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileInfo#getPropertyKeys() + */ + public IFilePropertyType[] getPropertyKeys() { + return FileSystem.NO_FILE_PROPERTIES; + } + /* (non-Javadoc) * @see org.eclipse.core.filesystem.IFileInfo#lastModified() */ @@ -229,15 +262,30 @@ /** * Sets or clears a String attribute, e.g. symbolic link target. * - * @param attribute The kind of attribute to set. Currently only - * {@link EFS#ATTRIBUTE_LINK_TARGET} is supported. - * @param value The String attribute, or null to clear - * the attribute - * @since org.eclipse.core.filesystem 1.1 + * @deprecated use {@link #setProperty(IFilePropertyType, Object)} instead */ public void setStringAttribute(int attribute, String value) { if (attribute == EFS.ATTRIBUTE_LINK_TARGET) - this.linkTarget = value; + setProperty(EFS.PROPERTY_LINK_TARGET, value); + } + + /** + * Sets or clears a file property, e.g. symbolic link target. + *

+ * This default implementation does nothing, since no extended + * properties are supported by default. File system providers + * should use subclasses of this class in order to get an + * implementation that's suitable for them. + *

+ * + * @param type The property type to set. + * @param value The property value, or null to clear + * the property. If not null, the value must be of the + * type specified by {@link IFilePropertyType#getType()}. + * @since org.eclipse.core.filesystem 1.1 + */ + public void setProperty(IFilePropertyType type, Object value) { + //do nothing in default implementation } /** Index: src/org/eclipse/core/filesystem/provider/DefaultFileInfo.java =================================================================== RCS file: src/org/eclipse/core/filesystem/provider/DefaultFileInfo.java diff -N src/org/eclipse/core/filesystem/provider/DefaultFileInfo.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/core/filesystem/provider/DefaultFileInfo.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,148 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Oberhuber (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.filesystem.provider; + +import java.util.Set; +import java.util.TreeMap; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFilePropertyType; + +/** + * Generic file information container supporting any kinds of properties. + *

+ * This class may be used by file system providers in their implementation + * of API methods that return {@link IFileInfo} objects. This class is not + * thread-safe. File system providers may subclass this class in order + * to provide optimized implementations of the + * {@link #getProperty(IFilePropertyType)}, + * {@link #getPropertyKeys()} and + * {@link #setProperty(IFilePropertyType, Object)} + * methods. + *

+ * @since org.eclipse.core.filesystem 1.1 + */ +public class DefaultFileInfo extends FileInfo { + + /** + * The container for extended file properties. + */ + private TreeMap properties = null; + + /** + * Creates a new default file information object with default values. + */ + public DefaultFileInfo() { + super(); + } + + /** + * Creates a new default file information object. All values except + * the file name will have default values. + * + * @param name The name of this file + */ + public DefaultFileInfo(String name) { + super(name); + } + + /** + * Creates a new file information object by copying an existing + * object's contents. + * + * @param info The existing file information object to copy. + * @since org.eclipse.core.filesystem 1.1 + */ + public DefaultFileInfo(FileInfo info) { + super(info); + IFilePropertyType[] keys = info.getPropertyKeys(); + for(int i=0; i + * All normal attributes of this object are cloned, and the map of + * extended properties is also cloned. Keys and values in the + * property map, however, are not cloned, so clients are encouraged + * to use immutable objects as keys and values of the Properties, + * or override clone() in a subclass in order to provide deep + * clone functionality. + *

+ * @see java.lang.Object#clone() + */ + public Object clone() { + DefaultFileInfo clone = (DefaultFileInfo)super.clone(); + if (properties!=null) { + //we do not do a deep clone of properties. + clone.properties = (TreeMap)properties.clone(); + } + return clone; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileInfo#getProperty(org.eclipse.core.filesystem.IFilePropertyType) + */ + public Object getProperty(IFilePropertyType type) { + if (properties==null) return null; + return properties.get(type); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileInfo#getPropertyKeys() + */ + public IFilePropertyType[] getPropertyKeys() { + if (properties==null) return FileSystem.NO_FILE_PROPERTIES; + Set keyset = properties.keySet(); + return (IFilePropertyType[])keyset.toArray(new IFilePropertyType[keyset.size()]); + } + + /** + * Sets or clears a file property, e.g. symbolic link target. + *

+ * This implementation is not thread-safe: multiple threads may not try + * and set different properties at the same time, and property queries + * from a different thread may not happen at the same time as setting + * a property. This should not be a problem for most implementations, + * since file system providers are expected to set all properties in a + * single thread during execution of + * {@link IFileStore#fetchInfo(int, org.eclipse.core.runtime.IProgressMonitor))}, + * and inspect properties in the same thread or only long after the properties + * are set. + *

+ * The properties are set in a Map, for which only a shallow copy is + * created in case the {@link #clone()} method is called. This is not + * a problem for the keys, which are immutable by definition. But + * clients are encouraged to only use immutable objects as property + * values as well, or override the clone() method in a + * subclass in order to provide deep clone functionality. + *

+ * @param type The property type to set. + * @param value The property value, or null to clear + * the property. If not null, the value must be of the + * type specified by {@link IFilePropertyType#getType()}. + * @since org.eclipse.core.filesystem 1.1 + */ + public void setProperty(IFilePropertyType type, Object value) { + if (properties==null) { + //We expect very few properties typically, so an ObjectMap might + //be more appropriate, but that is internal to core. On the other + //hand, this implementation may rarely be used since actual providers + //will fill properties into their specialized, optimized subclasses. + properties = new TreeMap(); + } + properties.put(type, value); + } + +} Index: src/org/eclipse/core/filesystem/IFilePropertyType.java =================================================================== RCS file: src/org/eclipse/core/filesystem/IFilePropertyType.java diff -N src/org/eclipse/core/filesystem/IFilePropertyType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/core/filesystem/IFilePropertyType.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Oberhuber (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.filesystem; + +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * This interfaces serves as the key for an extended file property supported by a + * particular file system provider, and holds meta-information about this type. + * This information is always immutable: once created or queried from a provider, + * it never changes. + *

+ * Multiple file system providers can declare the same property type independently, provided + * that the types are compatible: when the key returned by {@link getKey()} is the same for two + * property type instances, they are considered equal. In this case, the Java type returned + * by {@link getType()} must also be the same. + *

+ * This interface is not intended to be implemented by clients. File system providers + * should use the concrete class {@link org.eclipse.core.filesystem.provider.FilePropertyType}. + *

+ * @see IFileStore#fetchInfo(int, IProgressMonitor) + * @see IFileStore#putInfo(IFileInfo, int, IProgressMonitor) + * @since org.eclipse.core.filesystem 1.1 + */ +public interface IFilePropertyType extends Comparable { + + /** + * Return the internal key of this property type. The key uniquely identifies a property + * type. It is is the only attribute used for comparing property types, computing a + * hash code or placing them into collections. + *

+ * Two file system providers can declare the same property type independently, + * provided that the types have the same key, same type and the same semantics. + *

+ * @return the unique key of this property type. + */ + public abstract String getKey(); + + /** + * Return the Java type of properties of this type. + *

+ * When properties of this type are intended to be shown in the UI (so {@link getLabel()} + * does not return null), the Java type's toString() method must + * return a text representation of the Property that's meaningful for the user. + *

+ * @return the Java type for properties of this type. + */ + public abstract Class getType(); + + /** + * Return the translated label for properties of this type, or null if properties + * of this type are not intended to be shown to users in the UI. + * + * @return the label for showing properties of this type in the UI, or null + * if they are not intended to be shown in the UI. + */ + public abstract String getLabel(); + + /** + * Test if the file system provider supports writing modified properties of this type + * back to the underlying file system through the {@link IFileStore#putInfo(IFileInfo, int, IProgressMonitor)} + * method. + * + * @return true if the file system provider supports writing properties of + * this type to the underlying file system. + */ + public abstract boolean canWrite(); + +} Index: src/org/eclipse/core/filesystem/provider/FilePropertyType.java =================================================================== RCS file: src/org/eclipse/core/filesystem/provider/FilePropertyType.java diff -N src/org/eclipse/core/filesystem/provider/FilePropertyType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/core/filesystem/provider/FilePropertyType.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Oberhuber (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.filesystem.provider; + +import org.eclipse.core.filesystem.IFilePropertyType; + +/** + * This class should be used by file system providers in their implementation + * of API methods that return {@link IFilePropertyType} objects. + *

+ * This class is not intended to be subclassed by clients. + *

+ * @since org.eclipse.core.filesystem 1.1 + */ +public class FilePropertyType implements IFilePropertyType { + + private String key; + private Class type; + private String label; + private boolean canWrite; + + /** + * Construct a new file property type. + * + * @param key The unique key identifying this property type. + * @param type The Java type for properties of this type. When properties of this type + * are intended to be shown in the UI (so the label is not null), + * the Java type's toString() method must return a text + * representation of the Property that's meaningful for the user. + * @param label The label for properties of this type in the UI, or null + * if properties of this type are not intended to be shown in the UI. + * @param canWrite true when the file system provider supports writing + * properties of this type back to the underlying file system. + */ + public FilePropertyType(String key, Class type, String label, boolean canWrite) { + this.key = key.intern(); //internalizing the key in order to support == in equals() + this.type = type; + this.label = label; + this.canWrite = canWrite; + } + + /* (non-Javadoc) + * @see org.eclipse.core.filesystem.IFilePropertyType#canWrite() + */ + public boolean canWrite() { + return this.canWrite; + } + + /* (non-Javadoc) + * @see org.eclipse.core.filesystem.IFilePropertyType#getKey() + */ + public String getKey() { + return this.key; + } + + /* (non-Javadoc) + * @see org.eclipse.core.filesystem.IFilePropertyType#getLabel() + */ + public String getLabel() { + return this.label; + } + + /* (non-Javadoc) + * @see org.eclipse.core.filesystem.IFilePropertyType#getType() + */ + public Class getType() { + return this.type; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object obj) { + if (obj instanceof FilePropertyType) { + //keys can be compared with == because they are internalized in the Constructor + return ((FilePropertyType)obj).key == this.key; + } + return false; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return this.key.hashCode(); + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public int compareTo(Object o) { + return key.compareTo((FilePropertyType)o); + } + +} Index: src/org/eclipse/core/internal/filesystem/local/LocalFileInfo.java =================================================================== RCS file: src/org/eclipse/core/internal/filesystem/local/LocalFileInfo.java diff -N src/org/eclipse/core/internal/filesystem/local/LocalFileInfo.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/core/internal/filesystem/local/LocalFileInfo.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Oberhuber (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.internal.filesystem.local; + +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFilePropertyType; +import org.eclipse.core.filesystem.provider.FileInfo; +import org.eclipse.core.filesystem.provider.FileSystem; + +/** + * File info container for files in the local operating system's + * file system. + * + * Currently supports {@link EFS#PROPERTY_LINK_TARGET} properties only. + * + * @since org.eclipse.core.filesystem 1.1 + */ +public class LocalFileInfo extends FileInfo { + + /** + * The target file name if this is a symbolic link + */ + private String linkTarget = null; + + /** + * Supported Property Keys. + */ + private static final IFilePropertyType[] FILE_PROPERTIES_LINK_TARGET + = { EFS.PROPERTY_LINK_TARGET }; + + /** + * Creates a new local file information object with default values. + */ + public LocalFileInfo() { + super(); + } + + /** + * Creates a new local file information object. All values except + * the file name will have default values. + * + * @param name The name of this file + */ + public LocalFileInfo(String name) { + super(name); + } + + /* (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileInfo#getProperty(IFilePropertyType) + */ + public Object getProperty(IFilePropertyType type) { + if (EFS.PROPERTY_LINK_TARGET.equals(type)) + return this.linkTarget; + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileInfo#getPropertyKeys() + */ + public IFilePropertyType[] getPropertyKeys() { + if (this.linkTarget==null) { + return FileSystem.NO_FILE_PROPERTIES; + } + return FILE_PROPERTIES_LINK_TARGET; + } + + /** + * Creates a new file information object by copying an existing + * object's contents. + * + * @param info The existing file information object to copy. + * @since org.eclipse.core.filesystem 1.1 + */ + public LocalFileInfo(FileInfo info) { + super(info); + this.linkTarget = (String)info.getProperty(EFS.PROPERTY_LINK_TARGET); + } + + /** + * Sets or clears a file property, e.g. symbolic link target. + * Currently supports {@link EFS#PROPERTY_LINK_TARGET} properties + * only. + * + * @param type The property type to set. + * @param value The property value, or null to clear + * the property. If not null, the value must be of the + * type specified by {@link IFilePropertyType#getType()}. + * @since org.eclipse.core.filesystem 1.1 + */ + public void setProperty(IFilePropertyType type, Object value) { + //Note: Since EFS.PROPERTY_LINK_TARGET is an officially known + //property that cannot be overridden, we can compare with == + //if (EFS.PROPERTY_LINK_TARGET.equals(type)) { + if (EFS.PROPERTY_LINK_TARGET == type) { + this.linkTarget = (String)value; + } + } + +} #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.6 diff -u -r1.6 SymlinkTest.java --- src/org/eclipse/core/tests/filesystem/SymlinkTest.java 2 Feb 2007 14:50:29 -0000 1.6 +++ src/org/eclipse/core/tests/filesystem/SymlinkTest.java 1 Mar 2007 16:59:45 -0000 @@ -107,7 +107,7 @@ p = Runtime.getRuntime().exec(cmd, envp, basedir); } int exitcode = p.waitFor(); - assertEquals(exitcode, 0); + assertEquals(0, exitcode); } catch (IOException e) { fail("mkLink", e); } catch (CoreException e) { @@ -144,23 +144,23 @@ assertFalse(ilDir.isDirectory()); assertFalse(illDir.exists()); assertFalse(illDir.isDirectory()); - assertEquals(ilFile.getLastModified(), 0); + assertEquals(0, ilFile.getLastModified()); assertEquals(ilFile.getLength(), 0); - assertEquals(ilDir.getLastModified(), 0); + assertEquals(0, ilDir.getLastModified()); assertEquals(ilDir.getLength(), 0); - assertEquals(illFile.getLastModified(), 0); + assertEquals(0, illFile.getLastModified()); assertEquals(illFile.getLength(), 0); - assertEquals(illDir.getLastModified(), 0); - assertEquals(illDir.getLength(), 0); + assertEquals(0, illDir.getLastModified()); + assertEquals(0, illDir.getLength()); if (haveSymlinks()) { assertTrue(ilFile.getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertEquals(ilFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "aFile"); + assertEquals("aFile", ilFile.getProperty(EFS.PROPERTY_LINK_TARGET)); assertTrue(ilDir.getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertEquals(ilDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "aDir"); + assertEquals("aDir", ilDir.getProperty(EFS.PROPERTY_LINK_TARGET)); assertTrue(illFile.getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertEquals(illFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lFile"); + assertEquals("lFile", illFile.getProperty(EFS.PROPERTY_LINK_TARGET)); assertTrue(illDir.getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertEquals(illDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lDir"); + assertEquals("lDir", illDir.getProperty(EFS.PROPERTY_LINK_TARGET)); } } @@ -173,15 +173,15 @@ ensureDoesNotExist(aFile); ensureDoesNotExist(aDir); IFileInfo[] infos = baseStore.childInfos(EFS.NONE, getMonitor()); - assertEquals(infos.length, 4); + assertEquals(4, infos.length); llFile.delete(EFS.NONE, getMonitor()); llDir.delete(EFS.NONE, getMonitor()); infos = baseStore.childInfos(EFS.NONE, getMonitor()); - assertEquals(infos.length, 2); + assertEquals(2, infos.length); lFile.delete(EFS.NONE, getMonitor()); lDir.delete(EFS.NONE, getMonitor()); infos = baseStore.childInfos(EFS.NONE, getMonitor()); - assertEquals(infos.length, 0); + assertEquals(0, infos.length); } public void testRecursiveSymlink() throws Exception { @@ -195,10 +195,10 @@ assertFalse(i1.isDirectory()); if (haveSymlinks()) { assertTrue(i1.getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertEquals("l2", i1.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET)); + assertEquals("l2", i1.getProperty(EFS.PROPERTY_LINK_TARGET)); } IFileInfo[] infos = baseStore.childInfos(EFS.NONE, getMonitor()); - assertEquals(infos.length, 2); + assertEquals(2, infos.length); i1.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); boolean exceptionThrown = false; try { @@ -225,12 +225,12 @@ i1 = l1.fetchInfo(); //FIXME bug: putInfo neither sets attributes nor throws an exception for broken symbolic links //assertTrue(exceptionThrown); - //assertEquals(i1.getLastModified(), 12345); + //assertEquals(12345, i1.getLastModified()); assertFalse(i1.exists()); l1.delete(EFS.NONE, getMonitor()); infos = baseStore.childInfos(EFS.NONE, getMonitor()); - assertEquals(infos.length, 1); + assertEquals(1, infos.length); } public void testSymlinkAttributes() { @@ -255,13 +255,13 @@ assertEquals(iDir.getLength(), illDir.getLength()); if (haveSymlinks()) { assertTrue(ilFile.getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertEquals(ilFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "aFile"); + assertEquals("aFile", ilFile.getProperty(EFS.PROPERTY_LINK_TARGET)); assertTrue(ilDir.getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertEquals(ilDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "aDir"); + assertEquals("aDir", ilDir.getProperty(EFS.PROPERTY_LINK_TARGET)); assertTrue(illFile.getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertEquals(illFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lFile"); + assertEquals("lFile", illFile.getProperty(EFS.PROPERTY_LINK_TARGET)); assertTrue(illDir.getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertEquals(illDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lDir"); + assertEquals("lDir", illDir.getProperty(EFS.PROPERTY_LINK_TARGET)); } } @@ -274,11 +274,11 @@ IFileStore childDir = aDir.getChild("subDir"); ensureExists(childDir, true); IFileInfo[] infos = llDir.childInfos(EFS.NONE, getMonitor()); - assertEquals(infos.length, 1); + assertEquals(1, infos.length); assertTrue(infos[0].isDirectory()); assertFalse(infos[0].getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertNull(infos[0].getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET)); - assertEquals(infos[0].getName(), "subDir"); + assertNull(infos[0].getProperty(EFS.PROPERTY_LINK_TARGET)); + assertEquals("subDir", infos[0].getName()); ensureDoesNotExist(childDir); } @@ -291,11 +291,11 @@ IFileStore childFile = llDir.getChild("subFile"); ensureExists(childFile, false); IFileInfo[] infos = aDir.childInfos(EFS.NONE, getMonitor()); - assertEquals(infos.length, 1); + assertEquals(1, infos.length); assertFalse(infos[0].isDirectory()); assertFalse(infos[0].getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertNull(infos[0].getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET)); - assertEquals(infos[0].getName(), "subFile"); + assertNull(infos[0].getProperty(EFS.PROPERTY_LINK_TARGET)); + assertEquals("subFile", infos[0].getName()); //writing to broken symlink ensureDoesNotExist(aDir); @@ -346,7 +346,7 @@ } if (haveSymlinks() && infos[i].getName().charAt(0) == 'l') { assertTrue("5." + infoName, infos[i].getAttribute(EFS.ATTRIBUTE_SYMLINK)); - assertTrue("6." + infoName, infos[i].getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET).endsWith(specialCharName)); + assertTrue("6." + infoName, ((String)infos[i].getProperty(EFS.PROPERTY_LINK_TARGET)).endsWith(specialCharName)); } } } @@ -363,7 +363,7 @@ 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); + assertEquals(timeToSet, iFile.getLastModified()); assertTrue(iFile.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); oldTime = iDir.getLastModified(); @@ -373,7 +373,7 @@ llDir.putInfo(illDir, EFS.SET_ATTRIBUTES | EFS.SET_LAST_MODIFIED, getMonitor()); iDir = aDir.fetchInfo(); assertTrue(iDir.getLastModified() != oldTime); - assertEquals(iDir.getLastModified(), timeToSet); + assertEquals(timeToSet, iDir.getLastModified()); assertTrue(iDir.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); if (haveSymlinks()) { //check that link properties are maintained even through putInfo @@ -381,8 +381,8 @@ 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"); + assertEquals("lFile", illFile.getProperty(EFS.PROPERTY_LINK_TARGET)); + assertEquals("lDir", illDir.getProperty(EFS.PROPERTY_LINK_TARGET)); } }