### Eclipse Workspace Patch 1.0
#P org.eclipse.core.filesystem
Index: src/org/eclipse/core/internal/filesystem/local/LocalFile.java
===================================================================
RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/LocalFile.java,v
retrieving revision 1.30
diff -u -r1.30 LocalFile.java
--- src/org/eclipse/core/internal/filesystem/local/LocalFile.java 19 Nov 2008 15:09:14 -0000 1.30
+++ src/org/eclipse/core/internal/filesystem/local/LocalFile.java 5 Jan 2009 18:59:59 -0000
@@ -15,7 +15,7 @@
import org.eclipse.core.filesystem.*;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.filesystem.provider.FileInfo;
-import org.eclipse.core.filesystem.provider.FileStore;
+import org.eclipse.core.filesystem.provider.FileStore2;
import org.eclipse.core.internal.filesystem.Messages;
import org.eclipse.core.internal.filesystem.Policy;
import org.eclipse.core.runtime.*;
@@ -23,9 +23,9 @@
/**
* File system implementation based on storage of files in the local
- * operating system's file system.
+ * operating system's file system. The logical model and the physical model of the files are identical.
*/
-public class LocalFile extends FileStore {
+public class LocalFile extends FileStore2 {
/**
* The java.io.File that this store represents.
*/
@@ -84,6 +84,9 @@
}
}
+ /**
+ * @deprecated
+ */
public String[] childNames(int options, IProgressMonitor monitor) {
String[] names = file.list();
return (names == null ? EMPTY_STRING_ARRAY : names);
@@ -163,14 +166,23 @@
return info;
}
+ /**
+ * @deprecated
+ */
public IFileStore getChild(IPath path) {
return new LocalFile(new File(file, path.toOSString()));
}
+ /**
+ * @deprecated
+ */
public IFileStore getFileStore(IPath path) {
return new LocalFile(new Path(file.getPath()).append(path).toFile());
}
+ /**
+ * @deprecated
+ */
public IFileStore getChild(String name) {
return new LocalFile(new File(file, name));
}
@@ -183,10 +195,16 @@
return LocalFileSystem.getInstance();
}
+ /**
+ * @deprecated
+ */
public String getName() {
return file.getName();
}
+ /**
+ * @deprecated
+ */
public IFileStore getParent() {
File parent = file.getParentFile();
return parent == null ? null : new LocalFile(parent);
@@ -252,6 +270,9 @@
return false;
}
+ /**
+ * @deprecated
+ */
public boolean isParentOf(IFileStore other) {
if (!(other instanceof LocalFile))
return false;
@@ -425,4 +446,81 @@
public URI toURI() {
return URIUtil.toURI(filePath);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChild(java.lang.String)
+ */
+ public IFileStore getPhysicalChild(String name) {
+ return getLogicalChild(name); // physical and logical are the same in this case
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildInfos(int, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) throws CoreException {
+ return getLogicalChildInfos(options, monitor); // physical and logical are the same in this case
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildNames(int, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) throws CoreException {
+ return getLogicalChildNames(options, monitor); // physical and logical are the same in this case
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildren(int, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException {
+ return getLogicalChildren(options, monitor); // physical and logical are the same in this case
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalFilename()
+ */
+ public String getPhysicalName() {
+ return getLogicalName(); // physical and logical are the same in this case
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalParent()
+ */
+ public IFileStore getPhysicalParent() throws CoreException {
+ return getLogicalParent(); // physical and logical are the same in this case
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#isPhysicalFile()
+ */
+ public boolean isPhysical() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#isPhysicalParentOf(org.eclipse.core.filesystem.IFileStore)
+ */
+ public boolean isPhysicalParentOf(IFileStore other) {
+ return isLogicalParentOf(other); // physical and logical are the same in this case
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalLocation()
+ */
+ public String getPhysicalLocation() {
+ return filePath;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getFileStoreLogical(org.eclipse.core.runtime.IPath)
+ */
+ public IFileStore getFileStoreLogical(IPath logicalPath) {
+ return getFileStore(logicalPath);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getFileStorePhysical(org.eclipse.core.runtime.IPath)
+ */
+ public IFileStore getFileStorePhysical(IPath physicalPath) {
+ return getFileStoreLogical(physicalPath); // physical and logical are the same in this case
+ }
}
Index: src/org/eclipse/core/filesystem/provider/FileStore.java
===================================================================
RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/provider/FileStore.java,v
retrieving revision 1.29
diff -u -r1.29 FileStore.java
--- src/org/eclipse/core/filesystem/provider/FileStore.java 17 Apr 2008 12:54:59 -0000 1.29
+++ src/org/eclipse/core/filesystem/provider/FileStore.java 5 Jan 2009 18:59:59 -0000
@@ -98,6 +98,8 @@
* Subclasses should override this method where a more efficient implementation
* is possible. This default implementation calls {@link #fetchInfo()} on each
* child, which will result in a file system call for each child.
+ *
+ * @deprecated
*/
public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
IFileStore[] childStores = childStores(options, monitor);
@@ -108,14 +110,16 @@
return childInfos;
}
- /* (non-Javadoc)
+ /**
* @see org.eclipse.core.filesystem.IFileStore#childNames(int, org.eclipse.core.runtime.IProgressMonitor)
+ * @deprecated
*/
public abstract String[] childNames(int options, IProgressMonitor monitor) throws CoreException;
/**
* The default implementation of {@link IFileStore#childStores(int, IProgressMonitor)}.
* Subclasses may override.
+ * @deprecated
*/
public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
String[] children = childNames(options, monitor);
@@ -305,6 +309,7 @@
* Subclasses may override.
*
* @since org.eclipse.core.filesystem 1.2
+ * @deprecated
*/
public IFileStore getFileStore(IPath path) {
IFileStore result = this;
@@ -321,8 +326,9 @@
return result;
}
- /* (non-Javadoc)
+ /**
* @see org.eclipse.core.filesystem.IFileStore#getChild(java.lang.String)
+ * @deprecated
*/
public abstract IFileStore getChild(String name);
@@ -339,13 +345,15 @@
}
}
- /* (non-Javadoc)
+ /**
* @see org.eclipse.core.filesystem.IFileStore#getName()
+ * @deprecated
*/
public abstract String getName();
- /* (non-Javadoc)
+ /**
* @see org.eclipse.core.filesystem.IFileStore#getParent()
+ * @deprecated
*/
public abstract IFileStore getParent();
@@ -370,6 +378,7 @@
* @param other The store to test for parentage.
* @return true
if this store is a parent of the provided
* store, and false
otherwise.
+ * @deprecated
*/
public boolean isParentOf(IFileStore other) {
while (true) {
Index: src/org/eclipse/core/filesystem/IFileStore.java
===================================================================
RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/IFileStore.java,v
retrieving revision 1.29
diff -u -r1.29 IFileStore.java
--- src/org/eclipse/core/filesystem/IFileStore.java 7 Apr 2008 08:55:40 -0000 1.29
+++ src/org/eclipse/core/filesystem/IFileStore.java 5 Jan 2009 18:59:59 -0000
@@ -59,6 +59,9 @@
*
fetchInfo().getName()
.
*
* @return The name of this store
+ * @deprecated
+ * @see IFileStore2#getLogicalName()
+ * @see IFileStore2#getPhysicalName()
*/
public String getName();
@@ -282,6 +300,9 @@
*
* @return The parent store, or null
if this store is the root
* of a file system.
+ * @deprecated
+ * @see IFileStore2#getLogicalParent()
+ * @see IFileStore2#getPhysicalParent()
*/
public IFileStore getParent();
@@ -305,6 +326,9 @@
* @param other The store to test for parentage.
* @return true
if this store is a parent of the provided
* store, and false
otherwise.
+ * @deprecated
+ * @see IFileStore2#isLogicalParentOf(IFileStore)
+ * @see IFileStore2#isPhysicalParentOf(IFileStore)
*/
public boolean isParentOf(IFileStore other);
Index: src/org/eclipse/core/internal/filesystem/NullFileStore.java
===================================================================
RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/NullFileStore.java,v
retrieving revision 1.9
diff -u -r1.9 NullFileStore.java
--- src/org/eclipse/core/internal/filesystem/NullFileStore.java 3 Jun 2008 12:40:03 -0000 1.9
+++ src/org/eclipse/core/internal/filesystem/NullFileStore.java 5 Jan 2009 18:59:59 -0000
@@ -15,7 +15,7 @@
import java.net.URISyntaxException;
import org.eclipse.core.filesystem.*;
import org.eclipse.core.filesystem.provider.FileInfo;
-import org.eclipse.core.filesystem.provider.FileStore;
+import org.eclipse.core.filesystem.provider.FileStore2;
import org.eclipse.core.runtime.*;
/**
@@ -23,8 +23,10 @@
* such as a location based on an undefined variable. This store
* acts much like /dev/null on *nix: writes are ignored, reads return
* empty streams, and modifications such as delete, mkdir, will fail.
+ * The logical model and physical model of this file are identical,
+ * even though reads and writes all result in null operations.
*/
-public class NullFileStore extends FileStore {
+public class NullFileStore extends FileStore2 {
private IPath path;
/**
@@ -35,14 +37,23 @@
this.path = path;
}
+ /**
+ * @deprecated
+ */
public IFileInfo[] childInfos(int options, IProgressMonitor monitor) {
return EMPTY_FILE_INFO_ARRAY;
}
+ /**
+ * @deprecated
+ */
public String[] childNames(int options, IProgressMonitor monitor) {
return EMPTY_STRING_ARRAY;
}
+ /**
+ * @deprecated
+ */
public void delete(int options, IProgressMonitor monitor) throws CoreException {
//super implementation will always fail
super.delete(options, monitor);
@@ -54,6 +65,9 @@
return result;
}
+ /**
+ * @deprecated
+ */
public IFileStore getChild(String name) {
return new NullFileStore(path.append(name));
}
@@ -62,10 +76,16 @@
return NullFileSystem.getInstance();
}
+ /**
+ * @deprecated
+ */
public String getName() {
return String.valueOf(path.lastSegment());
}
+ /**
+ * @deprecated
+ */
public IFileStore getParent() {
return path.segmentCount() == 0 ? null : new NullFileStore(path.removeLastSegments(1));
}
@@ -105,4 +125,78 @@
return null;
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChild(java.lang.String)
+ */
+ public IFileStore getPhysicalChild(String name) {
+ return getLogicalChild(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildInfos(int, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) throws CoreException {
+ return getLogicalChildInfos(options, monitor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildNames(int, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) throws CoreException {
+ return getLogicalChildNames(options, monitor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildren(int, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException {
+ return getLogicalChildren(options, monitor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalFilename()
+ */
+ public String getPhysicalName() {
+ return getLogicalName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalParent()
+ */
+ public IFileStore getPhysicalParent() throws CoreException {
+ return getLogicalParent();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#isPhysicalFile()
+ */
+ public boolean isPhysical() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#isPhysicalParentOf(org.eclipse.core.filesystem.IFileStore)
+ */
+ public boolean isPhysicalParentOf(IFileStore other) {
+ return isLogicalParentOf(other);
+ }
+
+ public String getPhysicalLocation() {
+ return path.toOSString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getFileStoreLogical(org.eclipse.core.runtime.IPath)
+ */
+ public IFileStore getFileStoreLogical(IPath logicalPath) {
+ return getFileStore(logicalPath);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filesystem.IFileStore2#getFileStorePhysical(org.eclipse.core.runtime.IPath)
+ */
+ public IFileStore getFileStorePhysical(IPath physicalPath) {
+ return getFileStoreLogical(physicalPath); // physical and logical are the same in this case
+ }
}
Index: src/org/eclipse/core/filesystem/IFileStore2.java
===================================================================
RCS file: src/org/eclipse/core/filesystem/IFileStore2.java
diff -N src/org/eclipse/core/filesystem/IFileStore2.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/core/filesystem/IFileStore2.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,317 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.filesystem;
+
+import org.eclipse.core.runtime.*;
+
+/**
+ * Extension of IFileStore which provides a distinct notion between the
+ * logical model of a file and its physical model. The logical model can be any
+ * arbitrary model of the file as Eclipse sees it, but the physical model
+ * always reflects the file as it is modeled by the operating system on which
+ * the store physically resides on disk.
+ * @author crecoskie
+ * @since 3.5
+ *
+ */
+public interface IFileStore2 extends IFileStore {
+ /**
+ * Returns true
if this file has a physical, one-to-one representation
+ * with a file as modeled by the operating system where the store physically resides on disk.
+ * Stores which reside inside archive files, databases, etc. must respond false
.
+ * @return boolean
+ */
+ public boolean isPhysical();
+
+ /**
+ * Returns a String corresponding to the name of the physical file
+ * as modeled by the operating system where the store physically resides on disk.
+ *
+ * @return String
+ */
+ public String getPhysicalName();
+
+ /**
+ * Returns a String corresponding to the absolute path with which
+ * this store is associated, as modeled by the operating system where
+ * the store physically resides on disk.
+ *
+ * @return String
+ */
+ public String getPhysicalLocation();
+
+ /**
+ * Returns an IFileStore representing the file's physical parent + * as modeled by the operating system where the store physically resides on disk.
+ * + *This is a handle only method; the parent + * is returned regardless of whether this store or the parent store exists.
+ * + *This method returns null
when this store represents the root
+ * directory of a file system.
null
if this store is the root
+ * of a file system.
+ *
+ * @exception CoreException if this store does not have a physical representation (isPhysical() returns false);
+ */
+ public IFileStore getPhysicalParent() throws CoreException;
+
+ /**
+ * Returns an array of type IFileStore[] representing the store's physical children
+ * as modeled by the operating system where the store physically resides on disk.
+ * Returns an empty array if there are no children.
+ * Returns null if this file does not have a physical representation (isPhysical() returns false).
+ *
+ * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
+ * is applicable).
+ * @param monitor a progress monitor, or null
if progress
+ * reporting and cancellation are not desired
+ * @return The children of this store, or an empty array if this
+ * store has no children.
+ * @exception CoreException if this method fails. Reasons include:
+ * false
).
+ * false
).
+ */
+ public IFileStore getPhysicalChild(String name) throws CoreException;
+
+ /**
+ * Returns a handle to the member store identified by the given path. The
+ * path is treated as relative to this store's physical location.
+ *
+ * + * This is a handle-only method; a store is provided regardless + * of whether this store or the member store exists, or whether this store + * represents a directory or not. + *
+ * + * @param physicalPath the path of the member store + * @return the member store + * @exception CoreException if this store does not have a physical + * representation (isPhysical() returnsfalse
).
+ *
+ * @since 3.5
+ */
+ public IFileStore getFileStorePhysical(IPath physicalPath) throws CoreException;
+
+ /**
+ * Returns whether this store is a physical parent of the provided store. This
+ * is equivalent to, but typically more efficient than, the following:
+ *
+ * while (true) {
+ * other = other.getPhyisicalParent();
+ * if (other == null)
+ * return false;
+ * if (this.equals(other))
+ * return true;
+ * }
+ *
+ * + * This is a handle only method; this test works regardless of whether + * this store or the parameter store exists. + *
+ * + * @param other The store to test for parentage. + * @returntrue
if this store is a parent of the provided
+ * store, and false
otherwise.
+ * @exception CoreException if either or both of this store and/or other
+ * does not have a physical representation (isPhysical() returns false
).
+ */
+ public boolean isPhysicalParentOf(IFileStore other) throws CoreException;
+
+ /**
+ * Returns the names of the files and directories physically contained within this store.
+ *
+ * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
+ * is applicable).
+ * @param monitor a progress monitor, or null
if progress
+ * reporting and cancellation are not desired
+ * @return The names of the children of this store, or an empty array if this
+ * store has no children.
+ * @exception CoreException if this method fails. Reasons include:
+ * false
)
+ * null
if progress
+ * reporting and cancellation are not desired
+ * @return An array of information about the children of this store, or an empty
+ * array if this store has no children.
+ * @exception CoreException if this method fails. Reasons include:
+ * false
)
+ * Returns an IFileStore representing the store's logical parent. + * The parent need not be the same as the physical parent as modeled + * by the operating system where the store physically resides on disk.
+ * + *This is a handle only method; the parent
+ * is returned regardless of whether this store or the parent store exists. This
+ * method returns null
when this store represents the root
+ * directory of a file system.
null
if this store is the root
+ * of a file system.
+ *
+ */
+ public IFileStore getLogicalParent() throws CoreException;
+
+ /**
+ * Returns an array of type IFileStore[] representing the store's logical children.
+ * These children need not be the same as the phyiscal children as modeled by the
+ * operating system where the store physically resides on disk.
+ * Returns an empty array if there are no children.
+ * Returns null if this file does not have a physical representation (isPhysical() returns false).
+ *
+ * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
+ * is applicable).
+ * @param monitor a progress monitor, or null
if progress
+ * reporting and cancellation are not desired
+ * @return The children of this store, or an empty array if this
+ * store has no children.
+ * @exception CoreException if this method fails. Reasons include:
+ * + * This is a handle-only method; a store is provided regardless + * of whether this store or the member store exists, or whether this store + * represents a directory or not. + *
+ * + * @param logicalPath the path of the member store + * @return the member store + * + * @since 3.5 + */ + public IFileStore getFileStoreLogical(IPath logicalPath); + + /** + * Returns whether this store is a logical parent of the provided store. This + * is equivalent to, but typically more efficient than, the following: + *
+ * while (true) {
+ * other = other.getLogicalParent();
+ * if (other == null)
+ * return false;
+ * if (this.equals(other))
+ * return true;
+ * }
+ *
+ * + * This is a handle only method; this test works regardless of whether + * this store or the parameter store exists. + *
+ * + * @param other The store to test for parentage. + * @returntrue
if this store is a parent of the provided
+ * store, and false
otherwise.
+ */
+ public boolean isLogicalParentOf(IFileStore other);
+
+ /**
+ * Returns the names of the files and directories logically contained within this store.
+ *
+ * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
+ * is applicable).
+ * @param monitor a progress monitor, or null
if progress
+ * reporting and cancellation are not desired
+ * @return The names of the children of this store, or an empty array if this
+ * store has no children.
+ * @exception CoreException if this method fails. Reasons include:
+ * null
if progress
+ * reporting and cancellation are not desired
+ * @return An array of information about the children of this store, or an empty
+ * array if this store has no children.
+ * @exception CoreException if this method fails. Reasons include:
+ *