mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 208944 - start of Flexible File System.
This commit is contained in:
parent
859d4ebd3f
commit
2a3047e389
4 changed files with 153 additions and 0 deletions
|
@ -704,5 +704,14 @@
|
||||||
<simple name="appName"/>
|
<simple name="appName"/>
|
||||||
</processType>
|
</processType>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.core.filesystem.filesystems">
|
||||||
|
<filesystem
|
||||||
|
scheme="ffs">
|
||||||
|
<run
|
||||||
|
class="org.eclipse.cdt.internal.core.ffs.FFSFileSystem">
|
||||||
|
</run>
|
||||||
|
</filesystem>
|
||||||
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2007 QNX Software 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:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.ffs;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.core.filesystem.EFS;
|
||||||
|
import org.eclipse.core.filesystem.IFileStore;
|
||||||
|
import org.eclipse.core.filesystem.IFileTree;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
|
public class FFSFileSystem extends FileSystem {
|
||||||
|
|
||||||
|
public FFSFileSystem() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFileStore getStore(URI uri) {
|
||||||
|
try {
|
||||||
|
URI realURI = new URI(getScheme(), uri.getSchemeSpecificPart(), uri.getFragment());
|
||||||
|
return EFS.getStore(realURI);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFS.getNullFileSystem().getStore(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int attributes() {
|
||||||
|
// TODO what attributes should we support?
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canDelete() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canWrite() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFileTree fetchFileTree(IFileStore root, IProgressMonitor monitor) {
|
||||||
|
try {
|
||||||
|
// TODO obviously
|
||||||
|
return EFS.getNullFileSystem().fetchFileTree(root, monitor);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFileStore fromLocalFile(File file) {
|
||||||
|
return EFS.getLocalFileSystem().fromLocalFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFileStore getStore(IPath path) {
|
||||||
|
return EFS.getLocalFileSystem().getStore(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCaseSensitive() {
|
||||||
|
return EFS.getLocalFileSystem().isCaseSensitive();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2274,5 +2274,13 @@
|
||||||
id="org.eclipse.cdt.ui.provider1">
|
id="org.eclipse.cdt.ui.provider1">
|
||||||
</provider>
|
</provider>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.ide.filesystemSupport">
|
||||||
|
<filesystemContributor
|
||||||
|
class="org.eclipse.cdt.internal.ui.ffs.FFSFileSystemContributor"
|
||||||
|
label="Flexible File System"
|
||||||
|
scheme="ffs">
|
||||||
|
</filesystemContributor>
|
||||||
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2007 QNX Software 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:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.ffs;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.eclipse.core.filesystem.EFS;
|
||||||
|
import org.eclipse.core.filesystem.IFileInfo;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.ide.fileSystem.FileSystemContributor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Doug Schaefer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FFSFileSystemContributor extends FileSystemContributor {
|
||||||
|
|
||||||
|
public URI browseFileSystem(String initialPath, Shell shell) {
|
||||||
|
DirectoryDialog dialog = new DirectoryDialog(shell);
|
||||||
|
dialog.setMessage("Select Project Location");
|
||||||
|
|
||||||
|
if (!initialPath.equals("")) { //$NON-NLS-1$
|
||||||
|
IFileInfo info = EFS.getLocalFileSystem().getStore(new Path(initialPath)).fetchInfo();
|
||||||
|
if (info != null && info.exists()) {
|
||||||
|
dialog.setFilterPath(initialPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String selectedDirectory = dialog.open();
|
||||||
|
if (selectedDirectory == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new File(selectedDirectory).toURI();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue