Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 121666 Details for
Bug 215261
[EFS] request to add method to IFileStore to get physical path
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Draft patch implementing Approach 2. Derived from e4 repository.
efs_adapter.patch.txt (text/plain), 13.00 KB, created by
Chris Recoskie
on 2009-01-06 13:14:42 EST
(
hide
)
Description:
Draft patch implementing Approach 2. Derived from e4 repository.
Filename:
MIME Type:
Creator:
Chris Recoskie
Created:
2009-01-06 13:14:42 EST
Size:
13.00 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.filesystem >Index: src/org/eclipse/core/internal/filesystem/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.resources/bundles/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 6 Jan 2009 18:09:10 -0000 >@@ -30,4 +30,5 @@ > noImplWrite = This file system is read only: {0}. > noScheme=Must specify a URI scheme: > notAFile = Resource is not a file: {0}. >+NullFileStore_0=Attempted physical comparison to non-physical store > readOnlyParent = Parent of resource: {0} is marked as read-only. >Index: src/org/eclipse/core/internal/filesystem/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/Messages.java,v >retrieving revision 1.7 >diff -u -r1.7 Messages.java >--- src/org/eclipse/core/internal/filesystem/Messages.java 3 Jun 2008 12:40:03 -0000 1.7 >+++ src/org/eclipse/core/internal/filesystem/Messages.java 6 Jan 2009 18:09:10 -0000 >@@ -38,6 +38,8 @@ > public static String noImplWrite; > public static String noScheme; > public static String notAFile; >+ >+ public static String NullFileStore_0; > public static String readOnlyParent; > > static { >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 6 Jan 2009 18:09:10 -0000 >@@ -105,4 +105,54 @@ > return null; > } > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) >+ */ >+ public Object getAdapter(Class adapter) { >+ if (adapter.equals(IPhysicalStore.class)) { >+ return new IPhysicalStore() { >+ >+ public IFileStore getFileStorePhysical(IPath physicalPath) { >+ return getFileStore(physicalPath); >+ } >+ >+ public IFileStore getPhysicalChild(String name) { >+ return getChild(name); >+ } >+ >+ public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) { >+ return childInfos(options, monitor); >+ } >+ >+ public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) { >+ return childNames(options, monitor); >+ } >+ >+ public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException { >+ return childStores(options, monitor); >+ } >+ >+ public String getPhysicalLocation() { >+ return path.toOSString(); >+ } >+ >+ public String getPhysicalName() { >+ return getName(); >+ } >+ >+ public IFileStore getPhysicalParent() { >+ return getParent(); >+ } >+ >+ public boolean isPhysicalParentOf(IFileStore other) throws CoreException { >+ if (other.getAdapter(IPhysicalStore.class) == null) >+ throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.core.filesystem", Messages.NullFileStore_0)); //$NON-NLS-1$ >+ return isParentOf(other); >+ } >+ >+ }; >+ } >+ return super.getAdapter(adapter); >+ } > } >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 6 Jan 2009 18:09:10 -0000 >@@ -425,4 +425,54 @@ > public URI toURI() { > return URIUtil.toURI(filePath); > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) >+ */ >+ public Object getAdapter(Class adapter) { >+ if (adapter.equals(IPhysicalStore.class)) { >+ return new IPhysicalStore() { >+ >+ public IFileStore getFileStorePhysical(IPath physicalPath) { >+ return getFileStore(physicalPath); >+ } >+ >+ public IFileStore getPhysicalChild(String name) { >+ return getChild(name); >+ } >+ >+ public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) throws CoreException { >+ return childInfos(options, monitor); >+ } >+ >+ public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) throws CoreException { >+ return childNames(options, monitor); >+ } >+ >+ public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException { >+ return childStores(options, monitor); >+ } >+ >+ public String getPhysicalLocation() { >+ return filePath; >+ } >+ >+ public String getPhysicalName() { >+ return getName(); >+ } >+ >+ public IFileStore getPhysicalParent() { >+ return getParent(); >+ } >+ >+ public boolean isPhysicalParentOf(IFileStore other) throws CoreException { >+ if (other.getAdapter(IPhysicalStore.class) == null) >+ throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.core.filesystem", Messages.NullFileStore_0)); //$NON-NLS-1$ >+ return isParentOf(other); >+ } >+ >+ }; >+ } >+ return super.getAdapter(adapter); >+ } > } >Index: src/org/eclipse/core/filesystem/IPhysicalStore.java >=================================================================== >RCS file: src/org/eclipse/core/filesystem/IPhysicalStore.java >diff -N src/org/eclipse/core/filesystem/IPhysicalStore.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/filesystem/IPhysicalStore.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,176 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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.*; >+ >+/** >+ * An interface representing an instance of an IFileStoree that is backed one-to-one >+ * by a physical file by the operating system on which the file physically resides on >+ * disk. The file may or may not also be a directory. Stores that logically reside inside other >+ * files such as archive files, databases, etc., are not considered to be physical, as they >+ * do not have a one-to-one relationship with a unique file. >+ * >+ * @see IFileStore >+ * @since 3.5 >+ * @author crecoskie >+ */ >+public interface IPhysicalStore { >+ /** >+ * 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(); >+ >+ /** >+ * <p>Returns an IFileStore representing the file's physical parent >+ * as modeled by the operating system where the store physically resides on disk.</p> >+ * >+ * <p>This is a handle only method; the parent >+ * is returned regardless of whether this store or the parent store exists.</p> >+ * >+ * <p>This method returns <code>null</code> when this store represents the root >+ * directory of a file system.</p> >+ * >+ * @return The parent store, or <code>null</code> if this store is the root >+ * of a file system. >+ * >+ */ >+ public IFileStore getPhysicalParent(); >+ >+ /** >+ * 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. >+ * >+ * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE} >+ * is applicable). >+ * @param monitor a progress monitor, or <code>null</code> 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: >+ * <ul> >+ * <li> This store does not exist.</li> >+ * </ul> >+ */ >+ public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException; >+ >+ /** >+ * Returns a child store with the provided physical name whose physical parent is >+ * this store. This is a handle-only method; a child is provided regardless >+ * of whether this store or the child store exists, or whether this store >+ * represents a directory or not. >+ * </p> >+ * >+ * @param name The name of the child store to return >+ * @return A child file store. >+ */ >+ public IFileStore getPhysicalChild(String name); >+ >+ /** >+ * Returns a handle to the member store identified by the given path. The >+ * path is treated as relative to this store's physical location. >+ * >+ * <p> >+ * 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. >+ * </p> >+ * >+ * @param physicalPath the path of the member store >+ * @return the member store >+ * @since 3.5 >+ */ >+ public IFileStore getFileStorePhysical(IPath physicalPath); >+ >+ /** >+ * Returns whether this store is a physical parent of the provided store. This >+ * is equivalent to, but typically more efficient than, the following: >+ * <code><p> >+ * while (true) { >+ * <dir>IPhysicalFile otherPhysical = other.getAdapter(IPhysicalFile.class);<BR> >+ * >+ * if(otherPhysical != null) {<BR> >+ * <dir>other = otherPhysical.getPhyisicalParent();<BR> >+ * if (other == null)<BR> >+ * <dir>return false;</dir><BR> >+ * if (this.equals(other))<BR> >+ * <dir>return true;</dir><BR> >+ * </dir> >+ * }<BR> >+ * >+ * else<BR> >+ * <dir>return false;</dir><BR> >+ * </dir> >+ * } >+ * </code></p> >+ * <p> >+ * This is a handle only method; this test works regardless of whether >+ * this store or the parameter store exists. >+ * </p> >+ * >+ * @param other The store to test for parentage. >+ * @return <code>true</code> if this store is a parent of the provided >+ * store, and <code>false</code> otherwise. >+ * @exception CoreException if <code>other</code> >+ * does not have a physical representation (cannot be adapted to IPhysicalFile). >+ */ >+ 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 <code>null</code> 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: >+ * <ul> >+ * <li> This store does not exist.</li> >+ * </ul> >+ */ >+ public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) throws CoreException; >+ >+ /** >+ * Returns an {@link IFileInfo} instance for each file and directory contained >+ * within this store. The parent-child relationship reflects the physical files >+ * as modeled by the operating system where the store physically resides on disk. >+ * >+ * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE} >+ * is applicable). >+ * @param monitor a progress monitor, or <code>null</code> 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: >+ * <ul> >+ * <li> This store does not exist.</li> >+ * </ul> >+ * @see IFileTree#getChildInfos(IFileStore) >+ */ >+ public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) throws CoreException; >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 215261
:
121665
| 121666