Class FileStore
- All Implemented Interfaces:
IFileStore,IAdaptable
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
FieldsModifier and TypeFieldDescriptionprotected static final IFileInfo[]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 final String[]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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchildInfos(int options, IProgressMonitor monitor) The default implementation ofIFileStore.childInfos(int, IProgressMonitor).abstract String[]childNames(int options, IProgressMonitor monitor) Returns the names of the files and directories contained within this store.childStores(int options, IProgressMonitor monitor) The default implementation ofIFileStore.childStores(int, IProgressMonitor).voidcopy(IFileStore destination, int options, IProgressMonitor monitor) The default implementation ofIFileStore.copy(IFileStore, int, IProgressMonitor).protected voidcopyDirectory(IFileInfo sourceInfo, IFileStore destination, int options, IProgressMonitor monitor) Recursively copies a directory as specified byIFileStore.copy(IFileStore, int, IProgressMonitor).protected voidcopyFile(IFileInfo sourceInfo, IFileStore destination, int options, IProgressMonitor monitor) Copies a file as specified byIFileStore.copy(IFileStore, int, IProgressMonitor).voiddelete(int options, IProgressMonitor monitor) The default implementation ofIFileStore.delete(int, IProgressMonitor).booleanThis implementation ofObject.equals(Object)defines equality based on the file store's URI.The default implementation ofIFileStore.fetchInfo().abstract IFileInfofetchInfo(int options, IProgressMonitor monitor) Fetches and returns information about this file from the underlying file system.abstract IFileStoreReturns a child store with the provided name whose parent is this store.Deprecated.getFileStore(IPath path) The default implementation ofIFileStore.getFileStore(IPath)Subclasses may override.The default implementation ofIFileStore.getFileSystem().abstract StringgetName()Returns the name of this store.abstract IFileStoreReturns the parent of this store.inthashCode()This implementation ofObject.hashCode()uses a definition of equality based on equality of the file store's URI.booleanisParentOf(IFileStore other) The default implementation ofIFileStore.isParentOf(IFileStore).mkdir(int options, IProgressMonitor monitor) The default implementation ofIFileStore.mkdir(int, IProgressMonitor).voidmove(IFileStore destination, int options, IProgressMonitor monitor) The default implementation ofIFileStore.move(IFileStore, int, IProgressMonitor).abstract InputStreamopenInputStream(int options, IProgressMonitor monitor) Returns an open input stream on the contents of this file.openOutputStream(int options, IProgressMonitor monitor) The default implementation ofIFileStore.openOutputStream(int, IProgressMonitor).voidputInfo(IFileInfo info, int options, IProgressMonitor monitor) The default implementation ofIFileStore.putInfo(IFileInfo, int, IProgressMonitor).toLocalFile(int options, IProgressMonitor monitor) The default implementation ofIFileStore.toLocalFile(int, IProgressMonitor).toString()Default implementation ofIFileStore.toString().abstract URItoURI()Returns a URI instance corresponding to this store.Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapterMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapterMethods inherited from interface org.eclipse.core.filesystem.IFileStore
compareTo, readAllBytes, write
-
Field Details
-
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
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 Details
-
FileStore
public FileStore()
-
-
Method Details
-
childInfos
The default implementation ofIFileStore.childInfos(int, IProgressMonitor). Subclasses should override this method where a more efficient implementation is possible. This default implementation callsfetchInfo()on each child, which will result in a file system call for each child.- Specified by:
childInfosin interfaceIFileStore- Parameters:
options- bit-wise or of option flag constants (currently onlyEFS.NONEis applicable).monitor- a progress monitor, ornullif 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:
-
childNames
Description copied from interface:IFileStoreReturns the names of the files and directories contained within this store.- Specified by:
childNamesin interfaceIFileStore- Parameters:
options- bit-wise or of option flag constants (currently onlyEFS.NONEis applicable).monitor- a progress monitor, ornullif 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
The default implementation ofIFileStore.childStores(int, IProgressMonitor). Subclasses may override.- Specified by:
childStoresin interfaceIFileStore- Parameters:
options- bit-wise or of option flag constants (currently onlyEFS.NONEis applicable).monitor- a progress monitor, ornullif 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:
-
copy
public void copy(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException The default implementation ofIFileStore.copy(IFileStore, int, IProgressMonitor). This implementation performs a copy by using other primitive methods. Subclasses may override this method.- Specified by:
copyin interfaceIFileStore- Parameters:
destination- The destination of the copy.options- bit-wise or of option flag constants (EFS.OVERWRITEorEFS.SHALLOW).monitor- a progress monitor, ornullif 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
OVERWRITEflag is not specified and a file of the same name already exists at the copy destination. - A file is being copied, but a directory of the same name already exists at the copy destination.
- A directory is being copied, but 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 byIFileStore.copy(IFileStore, int, IProgressMonitor).- Parameters:
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.OVERWRITEorEFS.SHALLOW).monitor- a progress monitor, ornullif progress reporting and cancellation are not desired- Throws:
CoreException- if this method fails. Reasons include:- This store does not exist.
- 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 byIFileStore.copy(IFileStore, int, IProgressMonitor).- Parameters:
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.OVERWRITEorEFS.SHALLOW).monitor- a progress monitor, ornullif progress reporting and cancellation are not desired- Throws:
CoreException- if this method fails. Reasons include:- This store does not exist.
- The
OVERWRITEflag is not specified and a file of the same name already exists at the copy destination. - A directory of the same name already exists at the copy destination.
-
delete
The default implementation ofIFileStore.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:
deletein interfaceIFileStore- Parameters:
options- bit-wise or of option flag constantsmonitor- a progress monitor, ornullif progress reporting and cancellation are not desired- Throws:
CoreException- if this method fails. Reasons include:- Files or directories could not be deleted.
- See Also:
-
equals
This implementation ofObject.equals(Object)defines equality based on the file store's URI. Subclasses should override this method to returntrueif 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 overridehashCode(). -
fetchInfo
The default implementation ofIFileStore.fetchInfo(). This implementation forwards toIFileStore.fetchInfo(int, IProgressMonitor). Subclasses may override this method.- Specified by:
fetchInfoin interfaceIFileStore- Returns:
- A structure containing information about this file.
- See Also:
-
fetchInfo
Description copied from interface:IFileStoreFetches 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
falsewhen IFileInfo#exists() is called, but all other information will assume default values.- Specified by:
fetchInfoin interfaceIFileStore- Parameters:
options- bit-wise or of option flag constants (currently onlyEFS.NONEis applicable).monitor- a progress monitor, ornullif 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:
-
getChild
Deprecated.usegetFileStore(IPath)insteadDescription copied from interface:IFileStoreReturns a child of this store as specified by the provided path. The path is treated as relative to this store. This is equivalent toIFileStore 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 ("..").
- Specified by:
getChildin interfaceIFileStore- Parameters:
path- The path of the child store to return- Returns:
- A child file store.
-
getFileStore
The default implementation ofIFileStore.getFileStore(IPath)Subclasses may override.- Specified by:
getFileStorein interfaceIFileStore- Parameters:
path- the path of the member store- Returns:
- the member store
- Since:
- org.eclipse.core.filesystem 1.2
-
getChild
Description copied from interface:IFileStoreReturns 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:
getChildin interfaceIFileStore- Parameters:
name- The name of the child store to return- Returns:
- A child file store.
-
getFileSystem
The default implementation ofIFileStore.getFileSystem(). Subclasses may override.- Specified by:
getFileSystemin interfaceIFileStore- Returns:
- The file system this store belongs to.
-
getName
Description copied from interface:IFileStoreReturns 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:
getNamein interfaceIFileStore- Returns:
- The name of this store
-
getParent
Description copied from interface:IFileStoreReturns 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 returnsnullwhen this store represents the root directory of a file system.- Specified by:
getParentin interfaceIFileStore- Returns:
- The parent store, or
nullif this store is the root of a file system.
-
hashCode
public int hashCode()This implementation ofObject.hashCode()uses a definition of equality based on equality of the file store's URI. Subclasses that overrideequals(Object)should also override this method to ensure the contract ofObject.hashCode()is honored. -
isParentOf
The default implementation ofIFileStore.isParentOf(IFileStore). This implementation performs parent calculation using other primitive methods. Subclasses may override this method.- Specified by:
isParentOfin interfaceIFileStore- Parameters:
other- The store to test for parentage.- Returns:
trueif this store is a parent of the provided store, andfalseotherwise.
-
mkdir
The default implementation ofIFileStore.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:
mkdirin interfaceIFileStore- Parameters:
options- bit-wise or of option flag constantsmonitor- a progress monitor, ornullif 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.SHALLOWoption 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 ofIFileStore.move(IFileStore, int, IProgressMonitor). This implementation performs a move by using other primitive methods. Subclasses may override this method.- Specified by:
movein interfaceIFileStore- Parameters:
destination- The destination of the move.options- bit-wise or of option flag constants (EFS.OVERWRITE).monitor- a progress monitor, ornullif 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.OVERWRITEflag 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:IFileStoreReturns an open input stream on the contents of this file. The number of concurrently open streams depends on the implementation and can be limited. 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
BufferedInputStreamwrapper should be used, or some other form of content buffering.It depends on the implementation how the limit of concurrently opened streams is handled.
CoreExceptionmay be thrown, when the limit is exceeded.- Specified by:
openInputStreamin interfaceIFileStore- Parameters:
options- bit-wise or of option flag constants (currently onlyEFS.NONEis applicable).monitor- a progress monitor, ornullif progress reporting and cancellation are not desired- Returns:
- An input stream on the contents of this file.
- Throws:
CoreException- if this method fails. The status code associated with exception reflects the cause of the failure. Reasons include:EFS.ERROR_NOT_EXISTS- This store does not exist.EFS.ERROR_WRONG_TYPE- This store represents a directory.EFS.ERROR_READ- The limit of concurrently opened streams has been exceeded.
-
openOutputStream
The default implementation ofIFileStore.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.- Specified by:
openOutputStreamin interfaceIFileStore- Parameters:
options- bit-wise or of option flag constantsmonitor- a progress monitor, ornullif progress reporting and cancellation are not desired- Returns:
- An output stream on the contents of this file.
- Throws:
CoreException- if this method fails. The status code associated with exception reflects the cause of the failure. Reasons include:EFS.ERROR_NOT_EXISTS- This store does not exist.EFS.ERROR_WRONG_TYPE- This store represents a directory.EFS.ERROR_READ- The limit of concurrently opened streams has been exceeded.
-
putInfo
The default implementation ofIFileStore.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:
putInfoin interfaceIFileStore- Parameters:
info- The file information instance containing the values to set.options- bit-wise or of option flag constantsmonitor- a progress monitor, ornullif progress reporting and cancellation are not desired- Throws:
CoreException- if this method fails. Reasons include:- This store does not exist.
- See Also:
-
toLocalFile
The default implementation ofIFileStore.toLocalFile(int, IProgressMonitor). When theEFS.CACHEoption is specified, this method returns a cached copy of this store in the local file system, ornullif this store does not exist.- Specified by:
toLocalFilein interfaceIFileStore- Parameters:
options- bit-wise or of option flag constants ( onlyEFS.CACHEapplies).monitor- a progress monitor, ornullif progress reporting and cancellation are not desired- Returns:
- A local file with the same state as this file or
nullifEFS.CACHEis 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:
-
toString
Default implementation ofIFileStore.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:
toStringin interfaceIFileStore- Overrides:
toStringin classObject- Returns:
- A string representation of this store.
-
toURI
Description copied from interface:IFileStoreReturns a URI instance corresponding to this store. The resulting URI, when passed toEFS.getStore(URI), will return a store equal to this instance.- Specified by:
toURIin interfaceIFileStore- Returns:
- A URI corresponding to this store.
- See Also:
-
getFileStore(IPath)instead