Eclipse Platform
Release 3.3

org.eclipse.core.filesystem.provider
Class FileStore

java.lang.Object
  extended byorg.eclipse.core.runtime.PlatformObject
      extended byorg.eclipse.core.filesystem.provider.FileStore
All Implemented Interfaces:
IAdaptable, IFileStore

public abstract class FileStore
extends PlatformObject
implements IFileStore

The abstract superclass of all 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.

Since:
org.eclipse.core.filesystem 1.0

Field Summary
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 Summary
FileStore()
           
 
Method Summary
 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)
          The default implementation of IFileStore.getChild(IPath).
abstract  IFileStore getChild(String name)
          Returns a child store with the provided name whose parent is this store.
 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.
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

EMPTY_FILE_INFO_ARRAY

protected static final 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.


EMPTY_STRING_ARRAY

protected static final 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 Detail

FileStore

public FileStore()
Method Detail

childInfos

public IFileInfo[] childInfos(int options,
                              IProgressMonitor monitor)
                       throws CoreException
The default implementation of 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.

Specified by:
childInfos in interface IFileStore
Parameters:
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 desired
Returns:
An array of information about the children of this store, or an empty array if this store has no children.
Throws:
CoreException - if this method fails. Reasons include:
  • This store does not exist.
See Also:
IFileTree.getChildInfos(IFileStore)

childNames

public abstract String[] childNames(int options,
                                    IProgressMonitor monitor)
                             throws CoreException
Description copied from interface: IFileStore
Returns the names of the files and directories contained within this store.

Specified by:
childNames in interface IFileStore
Parameters:
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 desired
Returns:
The names of the children of this store, or an empty array if this store has no children.
Throws:
CoreException - if this method fails. Reasons include:
  • This store does not exist.

childStores

public IFileStore[] childStores(int options,
                                IProgressMonitor monitor)
                         throws CoreException
The default implementation of IFileStore.childStores(int, IProgressMonitor). Subclasses may override.

Specified by:
childStores in interface IFileStore
Parameters:
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 desired
Returns:
The children of this store, or an empty array if this store has no children.
Throws:
CoreException - if this method fails. Reasons include:
  • This store does not exist.
See Also:
IFileTree.getChildStores(IFileStore)

copy

public void copy(IFileStore destination,
                 int options,
                 IProgressMonitor monitor)
          throws CoreException
The default implementation of IFileStore.copy(IFileStore, int, IProgressMonitor). This implementation performs a copy by using other primitive methods. Subclasses may override this method.

Specified by:
copy in interface IFileStore
Parameters:
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 desired
Throws:
CoreException - if this method fails. Reasons include:
  • This store does not exist.
  • The parent of the destination file store does not exist.
  • The OVERWRITE flag is not specified and a file of the same name already exists at the copy destination.

copyDirectory

protected void copyDirectory(IFileInfo sourceInfo,
                             IFileStore destination,
                             int options,
                             IProgressMonitor monitor)
                      throws CoreException
Recursively copies a directory as specified by IFileStore.copy(IFileStore, int, IProgressMonitor).

Parameters:
sourceInfo - The current file information for the source of the move
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 desired
Throws:
CoreException - if this method fails. Reasons include:
  • This store does not exist.
  • The OVERWRITE flag is not specified and a file of the same name already exists at the copy destination.

copyFile

protected void copyFile(IFileInfo sourceInfo,
                        IFileStore destination,
                        int options,
                        IProgressMonitor monitor)
                 throws CoreException
Copies a file as specified by IFileStore.copy(IFileStore, int, IProgressMonitor).

Parameters:
sourceInfo - The current file information for the source of the move
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 desired
Throws:
CoreException - if this method fails. Reasons include:
  • This store does not exist.
  • The OVERWRITE flag is not specified and a file of the same name already exists at the copy destination.

delete

public void delete(int options,
                   IProgressMonitor monitor)
            throws CoreException
The default implementation of 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.

Specified by:
delete in interface IFileStore
Parameters:
options - bit-wise or of option flag constants
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if this method fails. Reasons include:
  • Files or directories could not be deleted.
See Also:
EFS.ATTRIBUTE_SYMLINK

equals

public boolean equals(Object obj)
This implementation of 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().

Parameters:
obj - The object to compare with the receiver for equality
Returns:
true if this object is equal to the provided object, and false otherwise.
Since:
org.eclipse.core.filesystem 1.1

fetchInfo

public IFileInfo fetchInfo()
The default implementation of IFileStore.fetchInfo(). This implementation forwards to IFileStore.fetchInfo(int, IProgressMonitor). Subclasses may override this method.

Specified by:
fetchInfo in interface IFileStore
Returns:
A structure containing information about this file.
See Also:
IFileStore.fetchInfo(int, IProgressMonitor)

fetchInfo

public abstract IFileInfo fetchInfo(int options,
                                    IProgressMonitor monitor)
                             throws CoreException
Description copied from interface: IFileStore
Fetches and returns information about this file from the underlying file system.

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.

Specified by:
fetchInfo in interface IFileStore
Parameters:
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 desired
Returns:
A structure containing information about this file.
Throws:
CoreException - if this method fails. Reasons include:
  • Problems occurred while contacting the file system.
See Also:
IFileTree.getFileInfo(IFileStore)

getChild

public IFileStore getChild(IPath path)
The default implementation of IFileStore.getChild(IPath). Subclasses may override.

Specified by:
getChild in interface IFileStore
Parameters:
path - The path of the child store to return
Returns:
A child file store.

getChild

public abstract IFileStore getChild(String name)
Description copied from interface: IFileStore
Returns a child store with the provided name whose 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.

Specified by:
getChild in interface IFileStore
Parameters:
name - The name of the child store to return
Returns:
A child file store.

getFileSystem

public IFileSystem getFileSystem()
The default implementation of IFileStore.getFileSystem(). Subclasses may override.

Specified by:
getFileSystem in interface IFileStore
Returns:
The file system this store belongs to.

getName

public abstract String getName()
Description copied from interface: IFileStore
Returns the name of this store. This is a handle-only method; the name is returned regardless of whether this store exists.

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().

Specified by:
getName in interface IFileStore
Returns:
The name of this store

getParent

public abstract IFileStore getParent()
Description copied from interface: IFileStore
Returns the parent of this store. This is a handle only method; the parent is returned regardless of whether this store or the parent store exists. This method returns null when this store represents the root directory of a file system.

Specified by:
getParent in interface IFileStore
Returns:
The parent store, or null if this store is the root of a file system.

hashCode

public int hashCode()
This implementation of 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.

Returns:
A hash code value for this file store
Since:
org.eclipse.core.filesystem 1.1

isParentOf

public boolean isParentOf(IFileStore other)
The default implementation of IFileStore.isParentOf(IFileStore). This implementation performs parent calculation using other primitive methods. Subclasses may override this method.

Specified by:
isParentOf in interface IFileStore
Parameters:
other - The store to test for parentage.
Returns:
true if this store is a parent of the provided store, and false otherwise.

mkdir

public IFileStore mkdir(int options,
                        IProgressMonitor monitor)
                 throws CoreException
The default implementation of 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.

Specified by:
mkdir in interface IFileStore
Parameters:
options - bit-wise or of option flag constants
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Returns:
This directory
Throws:
CoreException - if this method fails. Reasons include:
  • The directory could not be created
  • A file already exists with this name that is not a directory
  • The EFS.SHALLOW option flag was specified and the parent of this directory does not exist.

move

public void move(IFileStore destination,
                 int options,
                 IProgressMonitor monitor)
          throws CoreException
The default implementation of IFileStore.move(IFileStore, int, IProgressMonitor). This implementation performs a move by using other primitive methods. Subclasses may override this method.

Specified by:
move in interface IFileStore
Parameters:
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 desired
Throws:
CoreException - if this method fails. Reasons include:
  • This store does not exist.
  • The parent of the destination file store does not exist.
  • The EFS.OVERWRITE flag is not specified and a file of the same name already exists at the destination.

openInputStream

public abstract InputStream openInputStream(int options,
                                            IProgressMonitor monitor)
                                     throws CoreException
Description copied from interface: IFileStore
Returns an open input stream on the contents of this file. The caller is responsible for closing the provided stream when it is no longer needed.

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.

Specified by:
openInputStream in interface IFileStore
Parameters:
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 desired
Returns:
An input stream on the contents of this file.
Throws:
CoreException - if this method fails. Reasons include:
  • This store does not exist.
  • This store represents a directory.

openOutputStream

public OutputStream openOutputStream(int options,
                                     IProgressMonitor monitor)
                              throws CoreException
The default implementation of 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.

Specified by:
openOutputStream in interface IFileStore
Parameters:
options - bit-wise or of option flag constants
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Returns:
An output stream on the contents of this file.
Throws:
CoreException - if this method fails. Reasons include:
  • This store represents a directory.
  • The parent of this store does not exist.

putInfo

public void putInfo(IFileInfo info,
                    int options,
                    IProgressMonitor monitor)
             throws CoreException
The default implementation of 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.

Specified by:
putInfo in interface IFileStore
Parameters:
options - bit-wise or of option flag constants
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
info - The file information instance containing the values to set.
Throws:
CoreException - if this method fails. Reasons include:
  • This store does not exist.
See Also:
EFS.createFileInfo()

toLocalFile

public File toLocalFile(int options,
                        IProgressMonitor monitor)
                 throws CoreException
The default implementation of 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.

Specified by:
toLocalFile in interface IFileStore
Parameters:
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 desired
Returns:
A local file with the same state as this file or null if EFS.CACHE is not specified and this is not a local file.
Throws:
CoreException - if this method fails. Reasons include:
  • A corresponding file could not be created in the local file system.
See Also:
IFileSystem.fromLocalFile(java.io.File)

toString

public String toString()
Default implementation of 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.

Specified by:
toString in interface IFileStore
Returns:
A string representation of this store.

toURI

public abstract URI toURI()
Description copied from interface: IFileStore
Returns a URI instance corresponding to this store. The resulting URI, when passed to EFS.getStore(URI), will return a store equal to this instance.

Specified by:
toURI in interface IFileStore
Returns:
A URI corresponding to this store.
See Also:
EFS.getStore(URI)

Eclipse Platform
Release 3.3

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.