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

Collapse All | Expand All

(-)src/org/eclipse/core/internal/filesystem/local/LocalFile.java (-3 / +101 lines)
Lines 15-21 Link Here
15
import org.eclipse.core.filesystem.*;
15
import org.eclipse.core.filesystem.*;
16
import org.eclipse.core.filesystem.URIUtil;
16
import org.eclipse.core.filesystem.URIUtil;
17
import org.eclipse.core.filesystem.provider.FileInfo;
17
import org.eclipse.core.filesystem.provider.FileInfo;
18
import org.eclipse.core.filesystem.provider.FileStore;
18
import org.eclipse.core.filesystem.provider.FileStore2;
19
import org.eclipse.core.internal.filesystem.Messages;
19
import org.eclipse.core.internal.filesystem.Messages;
20
import org.eclipse.core.internal.filesystem.Policy;
20
import org.eclipse.core.internal.filesystem.Policy;
21
import org.eclipse.core.runtime.*;
21
import org.eclipse.core.runtime.*;
Lines 23-31 Link Here
23
23
24
/**
24
/**
25
 * File system implementation based on storage of files in the local
25
 * File system implementation based on storage of files in the local
26
 * operating system's file system.
26
 * operating system's file system.  The logical model and the physical model of the files are identical.
27
 */
27
 */
28
public class LocalFile extends FileStore {
28
public class LocalFile extends FileStore2 {
29
	/**
29
	/**
30
	 * The java.io.File that this store represents.
30
	 * The java.io.File that this store represents.
31
	 */
31
	 */
Lines 84-89 Link Here
84
		}
84
		}
85
	}
85
	}
86
86
87
	/**
88
	 * @deprecated
89
	 */
87
	public String[] childNames(int options, IProgressMonitor monitor) {
90
	public String[] childNames(int options, IProgressMonitor monitor) {
88
		String[] names = file.list();
91
		String[] names = file.list();
89
		return (names == null ? EMPTY_STRING_ARRAY : names);
92
		return (names == null ? EMPTY_STRING_ARRAY : names);
Lines 163-176 Link Here
163
		return info;
166
		return info;
164
	}
167
	}
165
168
169
	/**
170
	 * @deprecated
171
	 */
166
	public IFileStore getChild(IPath path) {
172
	public IFileStore getChild(IPath path) {
167
		return new LocalFile(new File(file, path.toOSString()));
173
		return new LocalFile(new File(file, path.toOSString()));
168
	}
174
	}
169
175
176
	/**
177
	 * @deprecated
178
	 */
170
	public IFileStore getFileStore(IPath path) {
179
	public IFileStore getFileStore(IPath path) {
171
		return new LocalFile(new Path(file.getPath()).append(path).toFile());
180
		return new LocalFile(new Path(file.getPath()).append(path).toFile());
172
	}
181
	}
173
182
183
	/**
184
	 * @deprecated
185
	 */
174
	public IFileStore getChild(String name) {
186
	public IFileStore getChild(String name) {
175
		return new LocalFile(new File(file, name));
187
		return new LocalFile(new File(file, name));
176
	}
188
	}
Lines 183-192 Link Here
183
		return LocalFileSystem.getInstance();
195
		return LocalFileSystem.getInstance();
184
	}
196
	}
185
197
198
	/**
199
	 * @deprecated
200
	 */
186
	public String getName() {
201
	public String getName() {
187
		return file.getName();
202
		return file.getName();
188
	}
203
	}
189
204
205
	/**
206
	 * @deprecated
207
	 */
190
	public IFileStore getParent() {
208
	public IFileStore getParent() {
191
		File parent = file.getParentFile();
209
		File parent = file.getParentFile();
192
		return parent == null ? null : new LocalFile(parent);
210
		return parent == null ? null : new LocalFile(parent);
Lines 252-257 Link Here
252
		return false;
270
		return false;
253
	}
271
	}
254
272
273
	/**
274
	 * @deprecated
275
	 */
255
	public boolean isParentOf(IFileStore other) {
276
	public boolean isParentOf(IFileStore other) {
256
		if (!(other instanceof LocalFile))
277
		if (!(other instanceof LocalFile))
257
			return false;
278
			return false;
Lines 425-428 Link Here
425
	public URI toURI() {
446
	public URI toURI() {
426
		return URIUtil.toURI(filePath);
447
		return URIUtil.toURI(filePath);
427
	}
448
	}
449
450
	/* (non-Javadoc)
451
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChild(java.lang.String)
452
	 */
453
	public IFileStore getPhysicalChild(String name) {
454
		return getLogicalChild(name); // physical and logical are the same in this case
455
	}
456
457
	/* (non-Javadoc)
458
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildInfos(int, org.eclipse.core.runtime.IProgressMonitor)
459
	 */
460
	public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) throws CoreException {
461
		return getLogicalChildInfos(options, monitor); // physical and logical are the same in this case
462
	}
463
464
	/* (non-Javadoc)
465
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildNames(int, org.eclipse.core.runtime.IProgressMonitor)
466
	 */
467
	public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) throws CoreException {
468
		return getLogicalChildNames(options, monitor); // physical and logical are the same in this case
469
	}
470
471
	/* (non-Javadoc)
472
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildren(int, org.eclipse.core.runtime.IProgressMonitor)
473
	 */
474
	public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException {
475
		return getLogicalChildren(options, monitor); // physical and logical are the same in this case
476
	}
477
478
	/* (non-Javadoc)
479
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalFilename()
480
	 */
481
	public String getPhysicalName() {
482
		return getLogicalName(); // physical and logical are the same in this case
483
	}
484
485
	/* (non-Javadoc)
486
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalParent()
487
	 */
488
	public IFileStore getPhysicalParent() throws CoreException {
489
		return getLogicalParent(); // physical and logical are the same in this case
490
	}
491
492
	/* (non-Javadoc)
493
	 * @see org.eclipse.core.filesystem.IFileStore2#isPhysicalFile()
494
	 */
495
	public boolean isPhysical() {
496
		return true;
497
	}
498
499
	/* (non-Javadoc)
500
	 * @see org.eclipse.core.filesystem.IFileStore2#isPhysicalParentOf(org.eclipse.core.filesystem.IFileStore)
501
	 */
502
	public boolean isPhysicalParentOf(IFileStore other) {
503
		return isLogicalParentOf(other); // physical and logical are the same in this case
504
	}
505
506
	/* (non-Javadoc)
507
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalLocation()
508
	 */
509
	public String getPhysicalLocation() {
510
		return filePath;
511
	}
512
513
	/* (non-Javadoc)
514
	 * @see org.eclipse.core.filesystem.IFileStore2#getFileStoreLogical(org.eclipse.core.runtime.IPath)
515
	 */
516
	public IFileStore getFileStoreLogical(IPath logicalPath) {
517
		return getFileStore(logicalPath);
518
	}
519
520
	/* (non-Javadoc)
521
	 * @see org.eclipse.core.filesystem.IFileStore2#getFileStorePhysical(org.eclipse.core.runtime.IPath)
522
	 */
523
	public IFileStore getFileStorePhysical(IPath physicalPath) {
524
		return getFileStoreLogical(physicalPath); // physical and logical are the same in this case
525
	}
428
}
526
}
(-)src/org/eclipse/core/filesystem/provider/FileStore.java (-4 / +13 lines)
Lines 98-103 Link Here
98
	 * Subclasses should override this method where a more efficient implementation
98
	 * Subclasses should override this method where a more efficient implementation
99
	 * is possible.  This default implementation calls {@link #fetchInfo()} on each
99
	 * is possible.  This default implementation calls {@link #fetchInfo()} on each
100
	 * child, which will result in a file system call for each child.
100
	 * child, which will result in a file system call for each child.
101
	 * 
102
	 * @deprecated
101
	 */
103
	 */
102
	public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
104
	public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
103
		IFileStore[] childStores = childStores(options, monitor);
105
		IFileStore[] childStores = childStores(options, monitor);
Lines 108-121 Link Here
108
		return childInfos;
110
		return childInfos;
109
	}
111
	}
110
112
111
	/* (non-Javadoc)
113
	/**
112
	 * @see org.eclipse.core.filesystem.IFileStore#childNames(int, org.eclipse.core.runtime.IProgressMonitor)
114
	 * @see org.eclipse.core.filesystem.IFileStore#childNames(int, org.eclipse.core.runtime.IProgressMonitor)
115
	 * @deprecated
113
	 */
116
	 */
114
	public abstract String[] childNames(int options, IProgressMonitor monitor) throws CoreException;
117
	public abstract String[] childNames(int options, IProgressMonitor monitor) throws CoreException;
115
118
116
	/**
119
	/**
117
	 * The default implementation of {@link IFileStore#childStores(int, IProgressMonitor)}.
120
	 * The default implementation of {@link IFileStore#childStores(int, IProgressMonitor)}.
118
	 * Subclasses may override.
121
	 * Subclasses may override.
122
	 * @deprecated
119
	 */
123
	 */
120
	public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
124
	public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
121
		String[] children = childNames(options, monitor);
125
		String[] children = childNames(options, monitor);
Lines 305-310 Link Here
305
	 * Subclasses may override.
309
	 * Subclasses may override.
306
	 * 
310
	 * 
307
	 * @since org.eclipse.core.filesystem 1.2
311
	 * @since org.eclipse.core.filesystem 1.2
312
	 * @deprecated
308
	 */
313
	 */
309
	public IFileStore getFileStore(IPath path) {
314
	public IFileStore getFileStore(IPath path) {
310
		IFileStore result = this;
315
		IFileStore result = this;
Lines 321-328 Link Here
321
		return result;
326
		return result;
322
	}
327
	}
323
328
324
	/* (non-Javadoc)
329
	/**
325
	 * @see org.eclipse.core.filesystem.IFileStore#getChild(java.lang.String)
330
	 * @see org.eclipse.core.filesystem.IFileStore#getChild(java.lang.String)
331
	 * @deprecated
326
	 */
332
	 */
327
	public abstract IFileStore getChild(String name);
333
	public abstract IFileStore getChild(String name);
328
334
Lines 339-351 Link Here
339
		}
345
		}
340
	}
346
	}
341
347
342
	/* (non-Javadoc)
348
	/**
343
	 * @see org.eclipse.core.filesystem.IFileStore#getName()
349
	 * @see org.eclipse.core.filesystem.IFileStore#getName()
350
	 * @deprecated
344
	 */
351
	 */
345
	public abstract String getName();
352
	public abstract String getName();
346
353
347
	/* (non-Javadoc)
354
	/**
348
	 * @see org.eclipse.core.filesystem.IFileStore#getParent()
355
	 * @see org.eclipse.core.filesystem.IFileStore#getParent()
356
	 * @deprecated
349
	 */
357
	 */
350
	public abstract IFileStore getParent();
358
	public abstract IFileStore getParent();
351
359
Lines 370-375 Link Here
370
	 * @param other The store to test for parentage.
378
	 * @param other The store to test for parentage.
371
	 * @return <code>true</code> if this store is a parent of the provided
379
	 * @return <code>true</code> if this store is a parent of the provided
372
	 * store, and <code>false</code> otherwise.
380
	 * store, and <code>false</code> otherwise.
381
	 * @deprecated
373
	 */
382
	 */
374
	public boolean isParentOf(IFileStore other) {
383
	public boolean isParentOf(IFileStore other) {
375
		while (true) {
384
		while (true) {
(-)src/org/eclipse/core/filesystem/IFileStore.java (+24 lines)
Lines 59-64 Link Here
59
	 * <li> This store does not exist.</li>
59
	 * <li> This store does not exist.</li>
60
	 * </ul>
60
	 * </ul>
61
	 * @see IFileTree#getChildInfos(IFileStore)
61
	 * @see IFileTree#getChildInfos(IFileStore)
62
	 * @see IFileStore2#getLogicalChildInfos(int, IProgressMonitor)
63
	 * @see IFileStore2#getPhysicalChildInfos(int, IProgressMonitor)
64
	 * @deprecated
62
	 */
65
	 */
63
	public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException;
66
	public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException;
64
67
Lines 75-80 Link Here
75
	 * <ul>
78
	 * <ul>
76
	 * <li> This store does not exist.</li>
79
	 * <li> This store does not exist.</li>
77
	 * </ul>
80
	 * </ul>
81
	 * @deprecated
82
	 * @see IFileStore2#getLogicalChildNames(int, IProgressMonitor)
83
	 * @see IFileStore2#getPhysicalChildNames(int, IProgressMonitor)
78
	 */
84
	 */
79
	public String[] childNames(int options, IProgressMonitor monitor) throws CoreException;
85
	public String[] childNames(int options, IProgressMonitor monitor) throws CoreException;
80
86
Lines 93-98 Link Here
93
	 * <li> This store does not exist.</li>
99
	 * <li> This store does not exist.</li>
94
	 * </ul>
100
	 * </ul>
95
	 * @see IFileTree#getChildStores(IFileStore)
101
	 * @see IFileTree#getChildStores(IFileStore)
102
	 * @see IFileStore2#getLogicalChildren(int, IProgressMonitor)
103
	 * @see IFileStore2#getPhysicalChildren(int, IProgressMonitor)
104
	 * @deprecated
96
	 */
105
	 */
97
	public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException;
106
	public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException;
98
107
Lines 239-244 Link Here
239
	 * @return the member store
248
	 * @return the member store
240
	 * 
249
	 * 
241
	 * @since org.eclipse.core.filesystem 1.2
250
	 * @since org.eclipse.core.filesystem 1.2
251
	 * @deprecated
252
	 * @see IFileStore2#getFileStoreLogical(IPath)
253
	 * @see IFileStore2#getFileStorePhysical(IPath)
242
	 */
254
	 */
243
	public IFileStore getFileStore(IPath path);
255
	public IFileStore getFileStore(IPath path);
244
256
Lines 251-256 Link Here
251
	 * 
263
	 * 
252
	 * @param name The name of the child store to return
264
	 * @param name The name of the child store to return
253
	 * @return A child file store.
265
	 * @return A child file store.
266
	 * @deprecated
267
	 * @see IFileStore2#getLogicalChild(String)
268
	 * @see IFileStore2#getPhysicalChild(String)
254
	 */
269
	 */
255
	public IFileStore getChild(String name);
270
	public IFileStore getChild(String name);
256
271
Lines 271-276 Link Here
271
	 * <code>fetchInfo().getName()</code>.
286
	 * <code>fetchInfo().getName()</code>.
272
	 * </p>
287
	 * </p>
273
	 * @return The name of this store
288
	 * @return The name of this store
289
	 * @deprecated
290
	 * @see IFileStore2#getLogicalName()
291
	 * @see IFileStore2#getPhysicalName()
274
	 */
292
	 */
275
	public String getName();
293
	public String getName();
276
294
Lines 282-287 Link Here
282
	 * 
300
	 * 
283
	 * @return The parent store, or <code>null</code> if this store is the root
301
	 * @return The parent store, or <code>null</code> if this store is the root
284
	 * of a file system.
302
	 * of a file system.
303
	 * @deprecated
304
	 * @see IFileStore2#getLogicalParent()
305
	 * @see IFileStore2#getPhysicalParent()
285
	 */
306
	 */
286
	public IFileStore getParent();
307
	public IFileStore getParent();
287
308
Lines 305-310 Link Here
305
	 * @param other The store to test for parentage.
326
	 * @param other The store to test for parentage.
306
	 * @return <code>true</code> if this store is a parent of the provided
327
	 * @return <code>true</code> if this store is a parent of the provided
307
	 * store, and <code>false</code> otherwise.
328
	 * store, and <code>false</code> otherwise.
329
	 * @deprecated
330
	 * @see IFileStore2#isLogicalParentOf(IFileStore)
331
	 * @see IFileStore2#isPhysicalParentOf(IFileStore)
308
	 */
332
	 */
309
	public boolean isParentOf(IFileStore other);
333
	public boolean isParentOf(IFileStore other);
310
334
(-)src/org/eclipse/core/internal/filesystem/NullFileStore.java (-2 / +96 lines)
Lines 15-21 Link Here
15
import java.net.URISyntaxException;
15
import java.net.URISyntaxException;
16
import org.eclipse.core.filesystem.*;
16
import org.eclipse.core.filesystem.*;
17
import org.eclipse.core.filesystem.provider.FileInfo;
17
import org.eclipse.core.filesystem.provider.FileInfo;
18
import org.eclipse.core.filesystem.provider.FileStore;
18
import org.eclipse.core.filesystem.provider.FileStore2;
19
import org.eclipse.core.runtime.*;
19
import org.eclipse.core.runtime.*;
20
20
21
/**
21
/**
Lines 23-30 Link Here
23
 * such as a location based on an undefined variable.  This store
23
 * such as a location based on an undefined variable.  This store
24
 * acts much like /dev/null on *nix: writes are ignored, reads return
24
 * acts much like /dev/null on *nix: writes are ignored, reads return
25
 * empty streams, and modifications such as delete, mkdir, will fail.
25
 * empty streams, and modifications such as delete, mkdir, will fail.
26
 * The logical model and physical model of this file are identical,
27
 * even though reads and writes all result in null operations.
26
 */
28
 */
27
public class NullFileStore extends FileStore {
29
public class NullFileStore extends FileStore2 {
28
	private IPath path;
30
	private IPath path;
29
31
30
	/**
32
	/**
Lines 35-48 Link Here
35
		this.path = path;
37
		this.path = path;
36
	}
38
	}
37
39
40
	/**
41
	 * @deprecated
42
	 */
38
	public IFileInfo[] childInfos(int options, IProgressMonitor monitor) {
43
	public IFileInfo[] childInfos(int options, IProgressMonitor monitor) {
39
		return EMPTY_FILE_INFO_ARRAY;
44
		return EMPTY_FILE_INFO_ARRAY;
40
	}
45
	}
41
46
47
	/**
48
	 * @deprecated
49
	 */
42
	public String[] childNames(int options, IProgressMonitor monitor) {
50
	public String[] childNames(int options, IProgressMonitor monitor) {
43
		return EMPTY_STRING_ARRAY;
51
		return EMPTY_STRING_ARRAY;
44
	}
52
	}
45
53
54
	/**
55
	 * @deprecated
56
	 */
46
	public void delete(int options, IProgressMonitor monitor) throws CoreException {
57
	public void delete(int options, IProgressMonitor monitor) throws CoreException {
47
		//super implementation will always fail
58
		//super implementation will always fail
48
		super.delete(options, monitor);
59
		super.delete(options, monitor);
Lines 54-59 Link Here
54
		return result;
65
		return result;
55
	}
66
	}
56
67
68
	/**
69
	 * @deprecated
70
	 */
57
	public IFileStore getChild(String name) {
71
	public IFileStore getChild(String name) {
58
		return new NullFileStore(path.append(name));
72
		return new NullFileStore(path.append(name));
59
	}
73
	}
Lines 62-71 Link Here
62
		return NullFileSystem.getInstance();
76
		return NullFileSystem.getInstance();
63
	}
77
	}
64
78
79
	/**
80
	 * @deprecated
81
	 */
65
	public String getName() {
82
	public String getName() {
66
		return String.valueOf(path.lastSegment());
83
		return String.valueOf(path.lastSegment());
67
	}
84
	}
68
85
86
	/**
87
	 * @deprecated
88
	 */
69
	public IFileStore getParent() {
89
	public IFileStore getParent() {
70
		return path.segmentCount() == 0 ? null : new NullFileStore(path.removeLastSegments(1));
90
		return path.segmentCount() == 0 ? null : new NullFileStore(path.removeLastSegments(1));
71
	}
91
	}
Lines 105-108 Link Here
105
			return null;
125
			return null;
106
		}
126
		}
107
	}
127
	}
128
129
	/* (non-Javadoc)
130
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChild(java.lang.String)
131
	 */
132
	public IFileStore getPhysicalChild(String name) {
133
		return getLogicalChild(name);
134
	}
135
136
	/* (non-Javadoc)
137
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildInfos(int, org.eclipse.core.runtime.IProgressMonitor)
138
	 */
139
	public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) throws CoreException {
140
		return getLogicalChildInfos(options, monitor);
141
	}
142
143
	/* (non-Javadoc)
144
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildNames(int, org.eclipse.core.runtime.IProgressMonitor)
145
	 */
146
	public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) throws CoreException {
147
		return getLogicalChildNames(options, monitor);
148
	}
149
150
	/* (non-Javadoc)
151
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalChildren(int, org.eclipse.core.runtime.IProgressMonitor)
152
	 */
153
	public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException {
154
		return getLogicalChildren(options, monitor);
155
	}
156
157
	/* (non-Javadoc)
158
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalFilename()
159
	 */
160
	public String getPhysicalName() {
161
		return getLogicalName();
162
	}
163
164
	/* (non-Javadoc)
165
	 * @see org.eclipse.core.filesystem.IFileStore2#getPhysicalParent()
166
	 */
167
	public IFileStore getPhysicalParent() throws CoreException {
168
		return getLogicalParent();
169
	}
170
171
	/* (non-Javadoc)
172
	 * @see org.eclipse.core.filesystem.IFileStore2#isPhysicalFile()
173
	 */
174
	public boolean isPhysical() {
175
		return true;
176
	}
177
178
	/* (non-Javadoc)
179
	 * @see org.eclipse.core.filesystem.IFileStore2#isPhysicalParentOf(org.eclipse.core.filesystem.IFileStore)
180
	 */
181
	public boolean isPhysicalParentOf(IFileStore other) {
182
		return isLogicalParentOf(other);
183
	}
184
185
	public String getPhysicalLocation() {
186
		return path.toOSString();
187
	}
188
189
	/* (non-Javadoc)
190
	 * @see org.eclipse.core.filesystem.IFileStore2#getFileStoreLogical(org.eclipse.core.runtime.IPath)
191
	 */
192
	public IFileStore getFileStoreLogical(IPath logicalPath) {
193
		return getFileStore(logicalPath);
194
	}
195
196
	/* (non-Javadoc)
197
	 * @see org.eclipse.core.filesystem.IFileStore2#getFileStorePhysical(org.eclipse.core.runtime.IPath)
198
	 */
199
	public IFileStore getFileStorePhysical(IPath physicalPath) {
200
		return getFileStoreLogical(physicalPath); // physical and logical are the same in this case
201
	}
108
}
202
}
(-)src/org/eclipse/core/filesystem/IFileStore2.java (+317 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 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
package org.eclipse.core.filesystem;
12
13
import org.eclipse.core.runtime.*;
14
15
/**
16
 * Extension of IFileStore which provides a distinct notion between the
17
 * logical model of a file and its physical model.  The logical model can be any
18
 * arbitrary model of the file as Eclipse sees it, but the physical model
19
 * always reflects the file as it is modeled by the operating system on which
20
 * the store physically resides on disk.
21
 * @author crecoskie
22
 * @since 3.5
23
 *
24
 */
25
public interface IFileStore2 extends IFileStore {
26
	/**
27
	 * Returns <code>true</code> if this file has a physical, one-to-one representation
28
	 * with a file as modeled by the operating system where the store physically resides on disk.
29
	 * Stores which reside inside archive files, databases, etc. must respond <code>false</code>.
30
	 * @return boolean
31
	 */
32
	public boolean isPhysical();
33
34
	/**
35
	 * Returns a String corresponding to the name of the physical file
36
	 * as modeled by the operating system where the store physically resides on disk.
37
	 * 
38
	 * @return String
39
	 */
40
	public String getPhysicalName();
41
42
	/**
43
	 * Returns a String corresponding to the absolute path with which
44
	 * this store is associated, as modeled by the operating system where
45
	 * the store physically resides on disk.
46
	 * 
47
	 * @return String
48
	 */
49
	public String getPhysicalLocation();
50
51
	/**
52
	 * <p>Returns an IFileStore representing the file's physical parent
53
	 * as modeled by the operating system where the store physically resides on disk.</p>
54
	 * 
55
	 * <p>This is a handle only method; the parent
56
	 * is returned regardless of whether this store or the parent store exists.</p>
57
	 * 
58
	 * <p>This method returns <code>null</code> when this store represents the root
59
	 * directory of a file system.</p>
60
	 * 
61
	 * @return The parent store, or <code>null</code> if this store is the root
62
	 * of a file system.
63
	 * 
64
	 * @exception CoreException if this store does not have a physical representation (isPhysical() returns false);
65
	 */
66
	public IFileStore getPhysicalParent() throws CoreException;
67
68
	/**
69
	 * Returns an array of type IFileStore[] representing the store's physical children
70
	 * as modeled by the operating system where the store physically resides on disk.
71
	 * Returns an empty array if there are no children.
72
	 * Returns null if this file does not have a physical representation (isPhysical() returns false).
73
	 * 
74
	 * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
75
	 * is applicable).
76
	 * @param monitor a progress monitor, or <code>null</code> if progress
77
	 *    reporting and cancellation are not desired
78
	 * @return The children of this store, or an empty array if this
79
	 * store has no children.
80
	 * @exception CoreException if this method fails. Reasons include:
81
	 * <ul>
82
	 * <li> This store does not exist.</li>
83
	 * <li> This store does not have a physical representation (isPhysical() returns <code>false</code>).
84
	 * </ul>
85
	 * @see IFileStore2#getLogicalChildren(int, IProgressMonitor)
86
	 */
87
	public IFileStore[] getPhysicalChildren(int options, IProgressMonitor monitor) throws CoreException;
88
89
	/**
90
	 * Returns a child store with the provided physical name whose physical parent is
91
	 * this store.  This is a handle-only method; a child is provided regardless
92
	 * of whether this store or the child store exists, or whether this store
93
	 * represents a directory or not.
94
	 * </p>
95
	 * 
96
	 * @param name The name of the child store to return
97
	 * @return A child file store.
98
	 * @exception CoreException if this store does not have a physical representation (isPhysical() returns <code>false</code>).
99
	 */
100
	public IFileStore getPhysicalChild(String name) throws CoreException;
101
102
	/**
103
	 * Returns a handle to the member store identified by the given path. The
104
	 * path is treated as relative to this store's physical location.
105
	 * 
106
	 * <p>
107
	 * This is a handle-only method; a store is provided regardless
108
	 * of whether this store or the member store exists, or whether this store
109
	 * represents a directory or not.
110
	 * </p>
111
	 * 
112
	 * @param physicalPath the path of the member store
113
	 * @return the member store
114
	 * @exception CoreException if this store does not have a physical
115
	 * representation  (isPhysical() returns <code>false</code>).
116
	 * 
117
	 * @since 3.5
118
	 */
119
	public IFileStore getFileStorePhysical(IPath physicalPath) throws CoreException;
120
121
	/**
122
	 * Returns whether this store is a physical parent of the provided store.  This
123
	 * is equivalent to, but typically more efficient than, the following:
124
	 * <code>
125
	 * while (true) {
126
	 * 	other = other.getPhyisicalParent();
127
	 * 	if (other == null)
128
	 * 		return false;
129
	 * 	if (this.equals(other))
130
	 * 		return true;
131
	 * }
132
	 * </code>
133
	 * <p>
134
	 * This is a handle only method; this test works regardless of whether
135
	 * this store or the parameter store exists.
136
	 * </p>
137
	 * 
138
	 * @param other The store to test for parentage.
139
	 * @return <code>true</code> if this store is a parent of the provided
140
	 * store, and <code>false</code> otherwise.
141
	 * @exception CoreException if either or both of this store and/or <code>other</code>
142
	 * does not have a physical representation  (isPhysical() returns <code>false</code>).
143
	 */
144
	public boolean isPhysicalParentOf(IFileStore other) throws CoreException;
145
146
	/**
147
	 * Returns the names of the files and directories physically contained within this store.
148
	 * 
149
	 * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
150
	 * is applicable).
151
	 * @param monitor a progress monitor, or <code>null</code> if progress
152
	 *    reporting and cancellation are not desired
153
	 * @return The names of the children of this store, or an empty array if this
154
	 * store has no children.
155
	 * @exception CoreException if this method fails. Reasons include:
156
	 * <ul>
157
	 * <li> This store does not exist.</li>
158
	 * <li> This store does not have a physical representation (isPhysical() returns <code>false</code>)
159
	 * </ul>
160
	 */
161
	public String[] getPhysicalChildNames(int options, IProgressMonitor monitor) throws CoreException;
162
163
	/**
164
	 * Returns an {@link IFileInfo} instance for each file and directory contained 
165
	 * within this store.  The parent-child relationship reflects the physical files
166
	 * as modeled by the operating system where the store physically resides on disk.
167
	 * 
168
	 * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
169
	 * is applicable).
170
	 * @param monitor a progress monitor, or <code>null</code> if progress
171
	 *    reporting and cancellation are not desired
172
	 * @return An array of information about the children of this store, or an empty 
173
	 * array if this store has no children.
174
	 * @exception CoreException if this method fails. Reasons include:
175
	 * <ul>
176
	 * <li> This store does not exist.</li>
177
	 * <li> This store does not have a physical representation (isPhysical() returns <code>false</code>)
178
	 * </ul>
179
	 * @see IFileTree#getChildInfos(IFileStore)
180
	 */
181
	public IFileInfo[] getPhysicalChildInfos(int options, IProgressMonitor monitor) throws CoreException;
182
183
	/**
184
	 * Returns the logical name for this store.  This name need not be the same as its name
185
	 * as modeled by the operating system where the store physically resides on disk.
186
	 * 
187
	 * @return String
188
	 */
189
	public String getLogicalName();
190
191
	/**
192
	 * <p>Returns an IFileStore representing the store's logical parent.
193
	 * The parent need not be the same as the physical parent as modeled
194
	 * by the operating system where the store physically resides on disk.</p>
195
	 * 
196
	 * <p>This is a handle only method; the parent
197
	 * is returned regardless of whether this store or the parent store exists. This
198
	 * method returns <code>null</code> when this store represents the root
199
	 * directory of a file system.</p>
200
	 * 
201
	 * @return The parent store, or <code>null</code> if this store is the root
202
	 * of a file system.
203
	 * 
204
	 */
205
	public IFileStore getLogicalParent() throws CoreException;
206
207
	/**
208
	 * Returns an array of type IFileStore[] representing the store's logical children.
209
	 * These children need not be the same as the phyiscal children as modeled by the
210
	 * operating system where the store physically resides on disk.
211
	 * Returns an empty array if there are no children.
212
	 * Returns null if this file does not have a physical representation (isPhysical() returns false).
213
	 * 
214
	 * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
215
	 * is applicable).
216
	 * @param monitor a progress monitor, or <code>null</code> if progress
217
	 *    reporting and cancellation are not desired
218
	 * @return The children of this store, or an empty array if this
219
	 * store has no children.
220
	 * @exception CoreException if this method fails. Reasons include:
221
	 * <ul>
222
	 * <li> This store does not exist.</li>
223
	 * </ul>
224
	 * @see IFileStore2#getLogicalChildren(int, IProgressMonitor)
225
	 */
226
	public IFileStore[] getLogicalChildren(int options, IProgressMonitor monitor) throws CoreException;
227
228
	/**
229
	 * Returns a child store with the provided logical name whose logical parent is
230
	 * this store.  This is a handle-only method; a child is provided regardless
231
	 * of whether this store or the child store exists, or whether this store
232
	 * represents a directory or not.
233
	 * </p>
234
	 * 
235
	 * @param name The name of the child store to return
236
	 * @return A child file store.
237
	 */
238
	public IFileStore getLogicalChild(String name);
239
240
	/**
241
	 * Returns a handle to the member store identified by the given path. The
242
	 * path is treated as relative to this store's logical path.  I.e., segments of the path
243
	 * resolved against logical children of this store.
244
	 * 
245
	 * <p>
246
	 * This is a handle-only method; a store is provided regardless
247
	 * of whether this store or the member store exists, or whether this store
248
	 * represents a directory or not.
249
	 * </p>
250
	 * 
251
	 * @param logicalPath the path of the member store
252
	 * @return the member store
253
	 * 
254
	 * @since 3.5
255
	 */
256
	public IFileStore getFileStoreLogical(IPath logicalPath);
257
258
	/**
259
	 * Returns whether this store is a logical parent of the provided store.  This
260
	 * is equivalent to, but typically more efficient than, the following:
261
	 * <code>
262
	 * while (true) {
263
	 * 	other = other.getLogicalParent();
264
	 * 	if (other == null)
265
	 * 		return false;
266
	 * 	if (this.equals(other))
267
	 * 		return true;
268
	 * }
269
	 * </code>
270
	 * <p>
271
	 * This is a handle only method; this test works regardless of whether
272
	 * this store or the parameter store exists.
273
	 * </p>
274
	 * 
275
	 * @param other The store to test for parentage.
276
	 * @return <code>true</code> if this store is a parent of the provided
277
	 * store, and <code>false</code> otherwise.
278
	 */
279
	public boolean isLogicalParentOf(IFileStore other);
280
281
	/**
282
	 * Returns the names of the files and directories logically contained within this store.
283
	 * 
284
	 * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
285
	 * is applicable).
286
	 * @param monitor a progress monitor, or <code>null</code> if progress
287
	 *    reporting and cancellation are not desired
288
	 * @return The names of the children of this store, or an empty array if this
289
	 * store has no children.
290
	 * @exception CoreException if this method fails. Reasons include:
291
	 * <ul>
292
	 * <li> This store does not exist.</li>
293
	 * </ul>
294
	 */
295
	public String[] getLogicalChildNames(int options, IProgressMonitor monitor) throws CoreException;
296
297
	/**
298
	 * Returns an {@link IFileInfo} instance for each file and directory contained 
299
	 * within this store.  The parent-child relationship reflects the logical model as seen by
300
	 * EFS, and does not necessarily reflect the physical layout
301
	 * as modeled by the operating system where the store physically resides on disk.
302
	 * 
303
	 * @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
304
	 * is applicable).
305
	 * @param monitor a progress monitor, or <code>null</code> if progress
306
	 *    reporting and cancellation are not desired
307
	 * @return An array of information about the children of this store, or an empty 
308
	 * array if this store has no children.
309
	 * @exception CoreException if this method fails. Reasons include:
310
	 * <ul>
311
	 * <li> This store does not exist.</li>
312
	 * </ul>
313
	 * @see IFileTree#getChildInfos(IFileStore)
314
	 */
315
	public IFileInfo[] getLogicalChildInfos(int options, IProgressMonitor monitor) throws CoreException;
316
317
}
(-)src/org/eclipse/core/filesystem/provider/FileStore2.java (+72 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 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.provider;
13
14
import org.eclipse.core.filesystem.*;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
18
/**
19
 * @author crecoskie
20
 */
21
public abstract class FileStore2 extends FileStore implements IFileStore2 {
22
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.core.filesystem.IFileStore2#getLogicalChild(java.lang.String)
25
	 */
26
	public IFileStore getLogicalChild(String name) {
27
		return getChild(name);
28
	}
29
30
	/* (non-Javadoc)
31
	 * @see org.eclipse.core.filesystem.IFileStore2#getLogicalChildInfos(int, org.eclipse.core.runtime.IProgressMonitor)
32
	 */
33
	public IFileInfo[] getLogicalChildInfos(int options, IProgressMonitor monitor) throws CoreException {
34
		return childInfos(options, monitor);
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.core.filesystem.IFileStore2#getLogicalChildNames(int, org.eclipse.core.runtime.IProgressMonitor)
39
	 */
40
	public String[] getLogicalChildNames(int options, IProgressMonitor monitor) throws CoreException {
41
		return childNames(options, monitor);
42
	}
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.core.filesystem.IFileStore2#getLogicalChildren(int, org.eclipse.core.runtime.IProgressMonitor)
46
	 */
47
	public IFileStore[] getLogicalChildren(int options, IProgressMonitor monitor) throws CoreException {
48
		return childStores(options, monitor);
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.core.filesystem.IFileStore2#getLogicalFilename()
53
	 */
54
	public String getLogicalName() {
55
		return getName();
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.core.filesystem.IFileStore2#getLogicalParent()
60
	 */
61
	public IFileStore getLogicalParent() throws CoreException {
62
		return getParent();
63
	}
64
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.core.filesystem.IFileStore2#isLogicalParentOf(org.eclipse.core.filesystem.IFileStore)
67
	 */
68
	public boolean isLogicalParentOf(IFileStore other) {
69
		return isParentOf(other);
70
	}
71
72
}

Return to bug 215261