Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2007-12-28 21:29:45 +0000
committerDoug Schaefer2007-12-28 21:29:45 +0000
commit0d50d5b2223b085f5d1855e5b461f1fb5e26395d (patch)
treedc0794b88fec6ce154e744ffbbe047bb41adfdc3 /core/org.eclipse.cdt.core/src
parent5ff70f6e9757e595d211fb7d7b6a8f5dbb9121d9 (diff)
downloadorg.eclipse.cdt-0d50d5b2223b085f5d1855e5b461f1fb5e26395d.tar.gz
org.eclipse.cdt-0d50d5b2223b085f5d1855e5b461f1fb5e26395d.tar.xz
org.eclipse.cdt-0d50d5b2223b085f5d1855e5b461f1fb5e26395d.zip
Get more of the FFS working. Also turned on Java 5 for cdt.core.
Diffstat (limited to 'core/org.eclipse.cdt.core/src')
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSEcprojFile.java45
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSFileStore.java157
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSFileSystem.java46
3 files changed, 241 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSEcprojFile.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSEcprojFile.java
new file mode 100644
index 00000000000..c0addc1c63d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSEcprojFile.java
@@ -0,0 +1,45 @@
+/**********************************************************************
+ * Copyright (c) 2007 Wind River Systems 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:
+ * Wind River Systems - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.internal.core.ffs;
+
+import java.net.URI;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * @author Doug Schaefer
+ *
+ * Contents of the ecproj file.
+ */
+public class FFSEcprojFile {
+
+ private final URI uri;
+ private final IFileStore root;
+ private final FFSFileSystem fileSystem;
+
+ public FFSEcprojFile(FFSFileSystem fileSystem, URI uri) throws CoreException {
+ this.uri = uri;
+ this.fileSystem = fileSystem;
+ this.root = EFS.getStore(uri);
+ }
+
+ public FFSFileSystem getFileSystem() {
+ return fileSystem;
+ }
+
+ public IFileStore getRoot() {
+ return new FFSFileStore(this, null, root);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSFileStore.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSFileStore.java
new file mode 100644
index 00000000000..64752450d0f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSFileStore.java
@@ -0,0 +1,157 @@
+/**********************************************************************
+ * Copyright (c) 2007 Wind River Systems 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:
+ * Wind River Systems - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.internal.core.ffs;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.filesystem.IFileSystem;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * @author Doug Schaefer
+ *
+ */
+public class FFSFileStore implements org.eclipse.core.filesystem.IFileStore {
+
+ private final IFileStore target;
+ private final IFileStore parent;
+ private final FFSEcprojFile ecprojFile;
+
+ public FFSFileStore(FFSEcprojFile ecprojFile, IFileStore parent, IFileStore target) {
+ this.ecprojFile = ecprojFile;
+ this.parent = parent;
+ this.target = target;
+ }
+
+ public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
+ return target.childInfos(options, monitor);
+ }
+
+ public String[] childNames(int options, IProgressMonitor monitor) throws CoreException {
+ // TODO child handling
+ return target.childNames(options, monitor);
+ }
+
+ public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
+ IFileStore[] targetChildren = target.childStores(options, monitor);
+ IFileStore[] children = new IFileStore[targetChildren.length];
+ for (int i = 0; i < children.length; ++i)
+ children[i] = new FFSFileStore(ecprojFile, this, targetChildren[i]);
+ return children;
+ }
+
+ public void copy(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
+ target.copy(destination, options, monitor);
+ }
+
+ public void delete(int options, IProgressMonitor monitor) throws CoreException {
+ target.delete(options, monitor);
+ }
+
+ public IFileInfo fetchInfo() {
+ return target.fetchInfo();
+ }
+
+ public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
+ return target.fetchInfo(options, monitor);
+ }
+
+ public IFileStore getChild(IPath path) {
+ IFileStore store = getChild(path.segment(0));
+ if (store == null)
+ return null;
+ return store.getChild(path.removeFirstSegments(1));
+ }
+
+ public IFileStore getChild(String name) {
+ // TODO child handling
+ return target.getChild(name);
+ }
+
+ public IFileSystem getFileSystem() {
+ return ecprojFile.getFileSystem();
+ }
+
+ public String getName() {
+ return target.getName();
+ }
+
+ public IFileStore getParent() {
+ return parent;
+ }
+
+ public boolean isParentOf(IFileStore other) {
+ if (other == null || !(other instanceof FFSFileStore))
+ return false;
+
+ if (other.equals(this))
+ return true;
+
+ return isParentOf(other.getParent());
+ }
+
+ public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
+ return target.mkdir(options, monitor);
+ }
+
+ public void move(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
+ // TODO what happens if destination is a different target file system?
+ target.move(destination, options, monitor);
+ }
+
+ public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException {
+ return target.openInputStream(options, monitor);
+ }
+
+ public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
+ return target.openOutputStream(options, monitor);
+ }
+
+ public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException {
+ target.putInfo(info, options, monitor);
+ }
+
+ public File toLocalFile(int options, IProgressMonitor monitor) throws CoreException {
+ return target.toLocalFile(options, monitor);
+ }
+
+ public URI toURI() {
+ // TODO
+ // need base URI from file system
+ // then add in the child path as the query
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == IFileStore.class || adapter == FFSFileStore.class)
+ return this;
+
+ return null;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof FFSFileStore)
+ return target.equals(((FFSFileStore)obj).target);
+ else
+ return target.equals(obj);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSFileSystem.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSFileSystem.java
index b2943312a80..71c5295f886 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSFileSystem.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ffs/FFSFileSystem.java
@@ -14,6 +14,8 @@ package org.eclipse.cdt.internal.core.ffs;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.filesystem.EFS;
@@ -23,24 +25,54 @@ import org.eclipse.core.filesystem.provider.FileSystem;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
/**
* @author Doug Schaefer
*
- * This is the virtual file system. It maps URIs to files in underlying file systems.
- * In doing so, it allows the hierarchical structure of URIs to be different.
- * In particular, you can add files from one location to another and excludes files
- * and directories from the tree.
+ * This is the flexible file system. It allows you to add and exclude
+ * entries from from a given directory.
+ *
+ * The URI's for this system are as follows:
+ *
+ * ecproj:///<ecproj file location>?<logical path>#<ecproj file schema>
+ *
+ * For example:
+ *
+ * ecproj:///c:/Eclipse/workspace/s?.project
+ *
*/
public class FFSFileSystem extends FileSystem {
- public FFSFileSystem() {
+ private Map<URI, FFSEcprojFile> ecprojFiles = new HashMap<URI, FFSEcprojFile>();
+
+ private synchronized FFSEcprojFile getEcprojFile(FFSFileSystem fileSystem, URI uri) throws CoreException {
+ uri.normalize();
+ FFSEcprojFile ecprojFile = ecprojFiles.get(uri);
+ if (ecprojFile == null) {
+ ecprojFile = new FFSEcprojFile(fileSystem, uri);
+ ecprojFiles.put(uri, ecprojFile);
+ }
+ return ecprojFile;
}
public IFileStore getStore(URI uri) {
try {
- URI realURI = new URI(getScheme(), uri.getSchemeSpecificPart(), uri.getFragment());
- return EFS.getStore(realURI);
+ String ecprojScheme = uri.getFragment();
+ if (ecprojScheme == null)
+ ecprojScheme = EFS.SCHEME_FILE;
+
+ URI ecprojURI = new URI(ecprojScheme, uri.getAuthority(), uri.getPath(), null, null);
+ FFSEcprojFile ecprojFile = getEcprojFile(this, ecprojURI);
+
+ IFileStore root = ecprojFile.getRoot();
+ String pathStr = uri.getQuery();
+ if (pathStr == null)
+ return root;
+ IPath path = new Path(pathStr);
+ if (path.segmentCount() == 0)
+ return root;
+ return root.getChild(path);
} catch (URISyntaxException e) {
CCorePlugin.log(e);
} catch (CoreException e) {

Back to the top