View | Details | Raw Unified | Return to bug 215261 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/filesystem/messages.properties (+1 lines)
Lines 30-33 Link Here
30
noImplWrite = This file system is read only: {0}.
30
noImplWrite = This file system is read only: {0}.
31
noScheme=Must specify a URI scheme:
31
noScheme=Must specify a URI scheme:
32
notAFile = Resource is not a file: {0}.
32
notAFile = Resource is not a file: {0}.
33
NullFileStore_0=Attempted physical comparison to non-physical store
33
readOnlyParent = Parent of resource: {0} is marked as read-only.
34
readOnlyParent = Parent of resource: {0} is marked as read-only.
(-)src/org/eclipse/core/internal/filesystem/Messages.java (+2 lines)
Lines 38-43 Link Here
38
	public static String noImplWrite;
38
	public static String noImplWrite;
39
	public static String noScheme;
39
	public static String noScheme;
40
	public static String notAFile;
40
	public static String notAFile;
41
42
	public static String NullFileStore_0;
41
	public static String readOnlyParent;
43
	public static String readOnlyParent;
42
44
43
	static {
45
	static {
(-)src/org/eclipse/core/internal/filesystem/NullFileStore.java (+50 lines)
Lines 105-108 Link Here
105
			return null;
105
			return null;
106
		}
106
		}
107
	}
107
	}
108
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
111
	 */
112
	public Object getAdapter(Class adapter) {
113
		if (adapter.equals(IPhysicalStore.class)) {
114
			return new IPhysicalStore() {
115
116
				public IFileStore getFileStorePhysical(IPath physicalPath) {
117
					return getFileStore(physicalPath);
118
				}
119
120
				public IFileStore getPhysicalChild(String name) {
121
					return getChild(name);
122
				}
123
124
				public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) {
125
					return childInfos(options, monitor);
126
				}
127
128
				public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) {
129
					return childNames(options, monitor);
130
				}
131
132
				public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException {
133
					return childStores(options, monitor);
134
				}
135
136
				public String getPhysicalLocation() {
137
					return path.toOSString();
138
				}
139
140
				public String getPhysicalName() {
141
					return getName();
142
				}
143
144
				public IFileStore getPhysicalParent() {
145
					return getParent();
146
				}
147
148
				public boolean isPhysicalParentOf(IFileStore other) throws CoreException {
149
					if (other.getAdapter(IPhysicalStore.class) == null)
150
						throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.core.filesystem", Messages.NullFileStore_0)); //$NON-NLS-1$
151
					return isParentOf(other);
152
				}
153
154
			};
155
		}
156
		return super.getAdapter(adapter);
157
	}
108
}
158
}
(-)src/org/eclipse/core/internal/filesystem/local/LocalFile.java (+50 lines)
Lines 425-428 Link Here
425
	public URI toURI() {
425
	public URI toURI() {
426
		return URIUtil.toURI(filePath);
426
		return URIUtil.toURI(filePath);
427
	}
427
	}
428
429
	/* (non-Javadoc)
430
	 * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
431
	 */
432
	public Object getAdapter(Class adapter) {
433
		if (adapter.equals(IPhysicalStore.class)) {
434
			return new IPhysicalStore() {
435
436
				public IFileStore getFileStorePhysical(IPath physicalPath) {
437
					return getFileStore(physicalPath);
438
				}
439
440
				public IFileStore getPhysicalChild(String name) {
441
					return getChild(name);
442
				}
443
444
				public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) throws CoreException {
445
					return childInfos(options, monitor);
446
				}
447
448
				public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) throws CoreException {
449
					return childNames(options, monitor);
450
				}
451
452
				public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException {
453
					return childStores(options, monitor);
454
				}
455
456
				public String getPhysicalLocation() {
457
					return filePath;
458
				}
459
460
				public String getPhysicalName() {
461
					return getName();
462
				}
463
464
				public IFileStore getPhysicalParent() {
465
					return getParent();
466
				}
467
468
				public boolean isPhysicalParentOf(IFileStore other) throws CoreException {
469
					if (other.getAdapter(IPhysicalStore.class) == null)
470
						throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.core.filesystem", Messages.NullFileStore_0)); //$NON-NLS-1$
471
					return isParentOf(other);
472
				}
473
474
			};
475
		}
476
		return super.getAdapter(adapter);
477
	}
428
}
478
}
(-)src/org/eclipse/core/filesystem/IPhysicalStore.java (+176 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.core.filesystem;
13
14
import org.eclipse.core.runtime.*;
15
16
/**
17
 * An interface representing an instance of an IFileStoree that is backed one-to-one
18
 * by a physical file by the operating system on which the file physically resides on
19
 * disk.  The file may or may not also be a directory.  Stores that logically reside inside other
20
 * files such as archive files, databases, etc., are not considered to be physical, as they
21
 * do not have a one-to-one relationship with a unique file.
22
 * 
23
 * @see IFileStore
24
 * @since 3.5
25
 * @author crecoskie
26
 */
27
public interface IPhysicalStore {
28
	/**
29
	 * Returns a String corresponding to the name of the physical file
30
	 * as modeled by the operating system where the store physically resides on disk.
31
	 * 
32
	 * @return String
33
	 */
34
	public String getPhysicalName();
35
36
	/**
37
	 * Returns a String corresponding to the absolute path with which
38
	 * this store is associated, as modeled by the operating system where
39
	 * the store physically resides on disk.
40
	 * 
41
	 * @return String
42
	 */
43
	public String getPhysicalLocation();
44
45
	/**
46
	 * <p>Returns an IFileStore representing the file's physical parent
47
	 * as modeled by the operating system where the store physically resides on disk.</p>
48
	 * 
49
	 * <p>This is a handle only method; the parent
50
	 * is returned regardless of whether this store or the parent store exists.</p>
51
	 * 
52
	 * <p>This method returns <code>null</code> when this store represents the root
53
	 * directory of a file system.</p>
54
	 * 
55
	 * @return The parent store, or <code>null</code> if this store is the root
56
	 * of a file system.
57
	 * 
58
	 */
59
	public IFileStore getPhysicalParent();
60
61
	/**
62
	 * Returns an array of type IFileStore[] representing the store's physical children
63
	 * as modeled by the operating system where the store physically resides on disk.
64
	 * Returns an empty array if there are no children.
65
	 * 
66
	 * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
67
	 * is applicable).
68
	 * @param monitor a progress monitor, or <code>null</code> if progress
69
	 *    reporting and cancellation are not desired
70
	 * @return The children of this store, or an empty array if this
71
	 * store has no children.
72
	 * @exception CoreException if this method fails. Reasons include:
73
	 * <ul>
74
	 * <li> This store does not exist.</li>
75
	 * </ul>
76
	 */
77
	public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException;
78
79
	/**
80
	 * Returns a child store with the provided physical name whose physical parent is
81
	 * this store.  This is a handle-only method; a child is provided regardless
82
	 * of whether this store or the child store exists, or whether this store
83
	 * represents a directory or not.
84
	 * </p>
85
	 * 
86
	 * @param name The name of the child store to return
87
	 * @return A child file store.
88
	 */
89
	public IFileStore getPhysicalChild(String name);
90
91
	/**
92
	 * Returns a handle to the member store identified by the given path. The
93
	 * path is treated as relative to this store's physical location.
94
	 * 
95
	 * <p>
96
	 * This is a handle-only method; a store is provided regardless
97
	 * of whether this store or the member store exists, or whether this store
98
	 * represents a directory or not.
99
	 * </p>
100
	 * 
101
	 * @param physicalPath the path of the member store
102
	 * @return the member store
103
	 * @since 3.5
104
	 */
105
	public IFileStore getFileStorePhysical(IPath physicalPath);
106
107
	/**
108
	 * Returns whether this store is a physical parent of the provided store.  This
109
	 * is equivalent to, but typically more efficient than, the following:
110
	 * <code><p>
111
	 * while (true) {
112
	 *  <dir>IPhysicalFile otherPhysical = other.getAdapter(IPhysicalFile.class);<BR>
113
	 * 
114
	 *  if(otherPhysical != null) {<BR>
115
	 * 		<dir>other = otherPhysical.getPhyisicalParent();<BR>
116
	 * 		if (other == null)<BR>
117
	 * 			<dir>return false;</dir><BR>
118
	 * 		if (this.equals(other))<BR>
119
	 * 			<dir>return true;</dir><BR>
120
	 * 		</dir>
121
	 * 	}<BR>
122
	 * 
123
	 *  else<BR>
124
	 *  	<dir>return false;</dir><BR>
125
	 *  </dir>
126
	 * }
127
	 * </code></p>
128
	 * <p>
129
	 * This is a handle only method; this test works regardless of whether
130
	 * this store or the parameter store exists.
131
	 * </p>
132
	 * 
133
	 * @param other The store to test for parentage.
134
	 * @return <code>true</code> if this store is a parent of the provided
135
	 * store, and <code>false</code> otherwise.
136
	 * @exception CoreException if <code>other</code>
137
	 * does not have a physical representation  (cannot be adapted to IPhysicalFile).
138
	 */
139
	public boolean isPhysicalParentOf(IFileStore other) throws CoreException;
140
141
	/**
142
	 * Returns the names of the files and directories physically contained within this store.
143
	 * 
144
	 * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
145
	 * is applicable).
146
	 * @param monitor a progress monitor, or <code>null</code> if progress
147
	 *    reporting and cancellation are not desired
148
	 * @return The names of the children of this store, or an empty array if this
149
	 * store has no children.
150
	 * @exception CoreException if this method fails. Reasons include:
151
	 * <ul>
152
	 * <li> This store does not exist.</li>
153
	 * </ul>
154
	 */
155
	public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) throws CoreException;
156
157
	/**
158
	 * Returns an {@link IFileInfo} instance for each file and directory contained 
159
	 * within this store.  The parent-child relationship reflects the physical files
160
	 * as modeled by the operating system where the store physically resides on disk.
161
	 * 
162
	 * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
163
	 * is applicable).
164
	 * @param monitor a progress monitor, or <code>null</code> if progress
165
	 *    reporting and cancellation are not desired
166
	 * @return An array of information about the children of this store, or an empty 
167
	 * array if this store has no children.
168
	 * @exception CoreException if this method fails. Reasons include:
169
	 * <ul>
170
	 * <li> This store does not exist.</li>
171
	 * </ul>
172
	 * @see IFileTree#getChildInfos(IFileStore)
173
	 */
174
	public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) throws CoreException;
175
176
}

Return to bug 215261