public abstract class FileStore extends PlatformObject implements IFileStore
IFileStore
implementations. All
file stores must subclass this base class, implementing all abstract
methods according to their specification in the IFileStore
API.
Clients may subclass this class.
Modifier and Type | Field and Description |
---|---|
protected static IFileInfo[] |
EMPTY_FILE_INFO_ARRAY
A file info array of size zero that can be used as a return value for methods
that return IFileInfo[] to avoid creating garbage objects.
|
protected static String[] |
EMPTY_STRING_ARRAY
A string array of size zero that can be used as a return value for methods
that return String[] to avoid creating garbage objects.
|
Constructor and Description |
---|
FileStore() |
Modifier and Type | Method and Description |
---|---|
IFileInfo[] |
childInfos(int options,
IProgressMonitor monitor)
The default implementation of
IFileStore.childInfos(int, IProgressMonitor) . |
abstract String[] |
childNames(int options,
IProgressMonitor monitor)
Returns the names of the files and directories contained within this store.
|
IFileStore[] |
childStores(int options,
IProgressMonitor monitor)
The default implementation of
IFileStore.childStores(int, IProgressMonitor) . |
void |
copy(IFileStore destination,
int options,
IProgressMonitor monitor)
The default implementation of
IFileStore.copy(IFileStore, int, IProgressMonitor) . |
protected void |
copyDirectory(IFileInfo sourceInfo,
IFileStore destination,
int options,
IProgressMonitor monitor)
Recursively copies a directory as specified by
IFileStore.copy(IFileStore, int, IProgressMonitor) . |
protected void |
copyFile(IFileInfo sourceInfo,
IFileStore destination,
int options,
IProgressMonitor monitor)
Copies a file as specified by
IFileStore.copy(IFileStore, int, IProgressMonitor) . |
void |
delete(int options,
IProgressMonitor monitor)
The default implementation of
IFileStore.delete(int, IProgressMonitor) . |
boolean |
equals(Object obj)
This implementation of
Object.equals(Object) defines
equality based on the file store's URI. |
IFileInfo |
fetchInfo()
The default implementation of
IFileStore.fetchInfo() . |
abstract IFileInfo |
fetchInfo(int options,
IProgressMonitor monitor)
Fetches and returns information about this file from the underlying file
system.
|
IFileStore |
getChild(IPath path)
Deprecated.
use
getFileStore(IPath) instead |
abstract IFileStore |
getChild(String name)
Returns a child store with the provided name whose parent is
this store.
|
IFileStore |
getFileStore(IPath path)
The default implementation of
IFileStore.getFileStore(IPath)
Subclasses may override. |
IFileSystem |
getFileSystem()
The default implementation of
IFileStore.getFileSystem() . |
abstract String |
getName()
Returns the name of this store.
|
abstract IFileStore |
getParent()
Returns the parent of this store.
|
int |
hashCode()
This implementation of
Object.hashCode() uses a definition
of equality based on equality of the file store's URI. |
boolean |
isParentOf(IFileStore other)
The default implementation of
IFileStore.isParentOf(IFileStore) . |
IFileStore |
mkdir(int options,
IProgressMonitor monitor)
The default implementation of
IFileStore.mkdir(int, IProgressMonitor) . |
void |
move(IFileStore destination,
int options,
IProgressMonitor monitor)
The default implementation of
IFileStore.move(IFileStore, int, IProgressMonitor) . |
abstract InputStream |
openInputStream(int options,
IProgressMonitor monitor)
Returns an open input stream on the contents of this file.
|
OutputStream |
openOutputStream(int options,
IProgressMonitor monitor)
The default implementation of
IFileStore.openOutputStream(int, IProgressMonitor) . |
void |
putInfo(IFileInfo info,
int options,
IProgressMonitor monitor)
The default implementation of
IFileStore.putInfo(IFileInfo, int, IProgressMonitor) . |
File |
toLocalFile(int options,
IProgressMonitor monitor)
The default implementation of
IFileStore.toLocalFile(int, IProgressMonitor) . |
String |
toString()
Default implementation of
IFileStore.toString() . |
abstract URI |
toURI()
Returns a URI instance corresponding to this store.
|
getAdapter
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getAdapter
protected static final IFileInfo[] EMPTY_FILE_INFO_ARRAY
protected static final String[] EMPTY_STRING_ARRAY
public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException
IFileStore.childInfos(int, IProgressMonitor)
.
Subclasses should override this method where a more efficient implementation
is possible. This default implementation calls fetchInfo()
on each
child, which will result in a file system call for each child.childInfos
in interface IFileStore
options
- bit-wise or of option flag constants (currently only EFS.NONE
is applicable).monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
IFileTree.getChildInfos(IFileStore)
public abstract String[] childNames(int options, IProgressMonitor monitor) throws CoreException
IFileStore
childNames
in interface IFileStore
options
- bit-wise or of option flag constants (currently only EFS.NONE
is applicable).monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException
IFileStore.childStores(int, IProgressMonitor)
.
Subclasses may override.childStores
in interface IFileStore
options
- bit-wise or of option flag constants (currently only EFS.NONE
is applicable).monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
IFileTree.getChildStores(IFileStore)
public void copy(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException
IFileStore.copy(IFileStore, int, IProgressMonitor)
.
This implementation performs a copy by using other primitive methods.
Subclasses may override this method.copy
in interface IFileStore
destination
- The destination of the copy.options
- bit-wise or of option flag constants (
EFS.OVERWRITE
or EFS.SHALLOW
).monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
OVERWRITE
flag is not specified and a
file of the same name already exists at the copy destination.protected void copyDirectory(IFileInfo sourceInfo, IFileStore destination, int options, IProgressMonitor monitor) throws CoreException
IFileStore.copy(IFileStore, int, IProgressMonitor)
.sourceInfo
- The current file information for the source of the movedestination
- The destination of the copy.options
- bit-wise or of option flag constants (
EFS.OVERWRITE
or EFS.SHALLOW
).monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
protected void copyFile(IFileInfo sourceInfo, IFileStore destination, int options, IProgressMonitor monitor) throws CoreException
IFileStore.copy(IFileStore, int, IProgressMonitor)
.sourceInfo
- The current file information for the source of the movedestination
- The destination of the copy.options
- bit-wise or of option flag constants (
EFS.OVERWRITE
or EFS.SHALLOW
).monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
OVERWRITE
flag is not specified and a file of the
same name already exists at the copy destination.public void delete(int options, IProgressMonitor monitor) throws CoreException
IFileStore.delete(int, IProgressMonitor)
.
This implementation always throws an exception indicating that deletion
is not supported by this file system. This method should be overridden
for all file systems on which deletion is supported.delete
in interface IFileStore
options
- bit-wise or of option flag constantsmonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
EFS.ATTRIBUTE_SYMLINK
public boolean equals(Object obj)
Object.equals(Object)
defines
equality based on the file store's URI. Subclasses should override
this method to return true
if and only if the two file stores
represent the same resource in the backing file system. Issues to watch
out for include whether the file system is case-sensitive, and whether trailing
slashes are considered significant. Subclasses that override this method
should also override hashCode()
.public IFileInfo fetchInfo()
IFileStore.fetchInfo()
.
This implementation forwards to IFileStore.fetchInfo(int, IProgressMonitor)
.
Subclasses may override this method.fetchInfo
in interface IFileStore
IFileStore.fetchInfo(int, IProgressMonitor)
public abstract IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException
IFileStore
This method succeeds regardless of whether a corresponding
file currently exists in the underlying file system. In the case of a non-existent
file, the returned info will include the file's name and will return false
when IFileInfo#exists() is called, but all other information will assume default
values.
fetchInfo
in interface IFileStore
options
- bit-wise or of option flag constants (currently only EFS.NONE
is applicable).monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
IFileTree.getFileInfo(IFileStore)
@Deprecated public IFileStore getChild(IPath path)
getFileStore(IPath)
insteadIFileStore
IFileStore result = this; for (int i = 0; i < path.segmentCount(); i++) { result = result.getChild(path.segment(i)); return result;
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.
The provided path must not contain segments that are self references (".") or parent references ("..").
getChild
in interface IFileStore
path
- The path of the child store to returnpublic IFileStore getFileStore(IPath path)
IFileStore.getFileStore(IPath)
Subclasses may override.getFileStore
in interface IFileStore
path
- the path of the member storepublic abstract IFileStore getChild(String name)
IFileStore
getChild
in interface IFileStore
name
- The name of the child store to returnpublic IFileSystem getFileSystem()
IFileStore.getFileSystem()
.
Subclasses may override.getFileSystem
in interface IFileStore
public abstract String getName()
IFileStore
Note that when dealing with case-insensitive file systems, this name
may differ in case from the name of the corresponding file in the file
system. To obtain the exact name used in the file system, use
fetchInfo().getName()
.
getName
in interface IFileStore
public abstract IFileStore getParent()
IFileStore
null
when this store represents the root
directory of a file system.getParent
in interface IFileStore
null
if this store is the root
of a file system.public int hashCode()
Object.hashCode()
uses a definition
of equality based on equality of the file store's URI. Subclasses that
override equals(Object)
should also override this method
to ensure the contract of Object.hashCode()
is honored.public boolean isParentOf(IFileStore other)
IFileStore.isParentOf(IFileStore)
.
This implementation performs parent calculation using other primitive methods.
Subclasses may override this method.isParentOf
in interface IFileStore
other
- The store to test for parentage.true
if this store is a parent of the provided
store, and false
otherwise.public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException
IFileStore.mkdir(int, IProgressMonitor)
.
This implementation always throws an exception indicating that this file system
is read only. This method should be overridden for all writable file systems.mkdir
in interface IFileStore
options
- bit-wise or of option flag constantsmonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
EFS.SHALLOW
option flag was
specified and the parent of this directory does not exist.public void move(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException
IFileStore.move(IFileStore, int, IProgressMonitor)
.
This implementation performs a move by using other primitive methods.
Subclasses may override this method.move
in interface IFileStore
destination
- The destination of the move.options
- bit-wise or of option flag constants
(EFS.OVERWRITE
).monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
EFS.OVERWRITE
flag is not specified and a file of the
same name already exists at the destination.public abstract InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException
IFileStore
The returned stream is not guaranteed to be buffered efficiently. When reading
large blocks of data from the stream, a BufferedInputStream
wrapper should be used, or some other form of content buffering.
It depends on the implementation how the limit of concurrently opened streams
is handled. CoreException
may be thrown, when the limit is exceeded.
openInputStream
in interface IFileStore
options
- bit-wise or of option flag constants (currently only EFS.NONE
is applicable).monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException
IFileStore.openOutputStream(int, IProgressMonitor)
.
This implementation always throws an exception indicating that this file system
is read only. This method should be overridden for all writable file systems.
Implementations of this method are responsible for ensuring that the exact sequence
of bytes written to the output stream are returned on a subsequent call to
openInputStream(int, IProgressMonitor)
, unless there have been
intervening modifications to the file in the file system. For example, the implementation
of this method must not perform conversion of line terminator characters on text
data in the stream.
openOutputStream
in interface IFileStore
options
- bit-wise or of option flag constantsmonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredCoreException
- if this method fails. Reasons include:
public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException
IFileStore.putInfo(IFileInfo, int, IProgressMonitor)
.
This implementation always throws an exception indicating that this file system
is read only. This method should be overridden for all writable file systems.putInfo
in interface IFileStore
options
- bit-wise or of option flag constantsmonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredinfo
- The file information instance containing the values to set.CoreException
- if this method fails. Reasons include:
EFS.createFileInfo()
public File toLocalFile(int options, IProgressMonitor monitor) throws CoreException
IFileStore.toLocalFile(int, IProgressMonitor)
.
When the EFS.CACHE
option is specified, this method returns
a cached copy of this store in the local file system, or null
if
this store does not exist.toLocalFile
in interface IFileStore
options
- bit-wise or of option flag constants (
only EFS.CACHE
applies).monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desirednull
if EFS.CACHE
is not specified and this is not a local file.CoreException
- if this method fails. Reasons include:
IFileSystem.fromLocalFile(java.io.File)
public String toString()
IFileStore.toString()
. This default implementation
returns a string equal to the one returned by #toURI().toString(). Subclasses
may override to provide a more specific string representation of this store.toString
in interface IFileStore
toString
in class Object
public abstract URI toURI()
IFileStore
EFS.getStore(URI)
, will return a store equal
to this instance.toURI
in interface IFileStore
EFS.getStore(URI)
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.