| java.lang.Object org.gjt.sp.jedit.io.VFS
All known Subclasses: org.gjt.sp.jedit.io.UrlVFS, org.gjt.sp.jedit.io.FileRootsVFS, org.gjt.sp.jedit.io.FileVFS, org.gjt.sp.jedit.io.FavoritesVFS,
VFS | abstract public class VFS (Code) | | A virtual filesystem implementation.
Plugins can provide virtual file systems by defining entries in their
services.xml files like so:
<SERVICE CLASS="org.gjt.sp.jedit.io.VFS" NAME="name">
new MyVFS();
</SERVICE>
URLs of the form name:path will then be handled
by the VFS named name .
See
org.gjt.sp.jedit.ServiceManager for details.
Session objects:
A session is used to persist things like login information, any network
sockets, etc. File system implementations that do not need this kind of
persistence return a dummy object as a session.
Methods whose names are prefixed with "_" expect to be given a
previously-obtained session object. A session must be obtained from the AWT
thread in one of two ways:
When done, the session must be disposed of using
VFS._endVFSSession(Object,Component) .
Thread safety:
The following methods cannot be called from an I/O thread:
All remaining methods are required to be thread-safe in subclasses.
Implementing a VFS
You can override as many or as few methods as you want. Make sure
VFS.getCapabilities() returns a value reflecting the functionality
implemented by your VFS.
See Also: VFSManager.getVFSForPath(String) See Also: VFSManager.getVFSForProtocol(String) author: Slava Pestov author: $Id: VFS.java 10773 2007-09-30 19:21:03Z kpouer $ |
Inner Class :public static class DirectoryEntry extends VFSFile | |
Inner Class :public static class DirectoryEntryCompare implements Comparator | |
Inner Class :static class ColorEntry | |
Field Summary | |
final public static int | BROWSE_CAP Browse capability
since: jEdit 4.3pre11 since: This was the official API for adding items to a file since: system browser's Plugins menu in jEdit 4.1 and earlier. | final public static int | CASE_INSENSITIVE_CAP Case insensitive file system capability. | final public static int | DELETE_CAP Delete file capability. | final public static String | EA_MODIFIED File last modified date. | final public static String | EA_SIZE File size. | final public static String | EA_STATUS File status (read only, read write, etc). | final public static String | EA_TYPE File type. | public static int | IOBUFSIZE | final public static int | LOW_LATENCY_CAP Low latency capability. | final public static int | MKDIR_CAP Make directory capability. | final public static int | READ_CAP Read capability. | final public static int | RENAME_CAP Rename file capability. | final public static int | WRITE_CAP Write capability. |
Constructor Summary | |
public | VFS(String name) | public | VFS(String name, int caps) Creates a new virtual filesystem. | public | VFS(String name, int caps, String[] extAttrs) Creates a new virtual filesystem. |
Method Summary | |
public void | _backup(Object session, String path, Component comp) Backs up the specified file. | public String | _canonPath(Object session, String path, Component comp) Returns the canonical form of the specified path name. | public InputStream | _createInputStream(Object session, String path, boolean ignoreErrors, Component comp) Creates an input stream. | public OutputStream | _createOutputStream(Object session, String path, Component comp) Creates an output stream. | public boolean | _delete(Object session, String path, Component comp) Deletes the specified URL. | public void | _endVFSSession(Object session, Component comp) Finishes the specified VFS session. | public void | _finishTwoStageSave(Object session, Buffer buffer, String path, Component comp) Called after a file has been saved and we use twoStageSave (first saving to
another file). | public DirectoryEntry | _getDirectoryEntry(Object session, String path, Component comp) Returns the specified directory entry. | public VFSFile | _getFile(Object session, String path, Component comp) Returns the specified directory entry. | public String[] | _listDirectory(Object session, String directory, String glob, boolean recursive, Component comp) A convinience method that matches file names against globs, and can
optionally list the directory recursively.
Parameters: session - The session Parameters: directory - The directory. | public String[] | _listDirectory(Object session, String directory, String glob, boolean recursive, Component comp, boolean skipBinary, boolean skipHidden) A convinience method that matches file names against globs, and can
optionally list the directory recursively.
Parameters: session - The session Parameters: directory - The directory. | public String[] | _listDirectory(Object session, String directory, VFSFileFilter filter, boolean recursive, Component comp, boolean skipBinary, boolean skipHidden) A convinience method that filters the directory listing
according to a filter, and can optionally list the directory
recursively.
Parameters: session - The session Parameters: directory - The directory. | public DirectoryEntry[] | _listDirectory(Object session, String directory, Component comp) | public VFSFile[] | _listFiles(Object session, String directory, Component comp) Lists the specified directory.
Parameters: session - The session Parameters: directory - The directory. | public boolean | _mkdir(Object session, String directory, Component comp) Creates a new directory with the specified URL. | public boolean | _rename(Object session, String from, String to, Component comp) Renames the specified URL. | public void | _saveComplete(Object session, Buffer buffer, String path, Component comp) Called after a file has been saved. | public String | constructPath(String parent, String path) Constructs a path from the specified directory and
file name component. | public static boolean | copy(ProgressObserver progress, VFS sourceVFS, Object sourceSession, String sourcePath, VFS targetVFS, Object targetSession, String targetPath, Component comp, boolean canStop) Copy a file to another using VFS.
Parameters: progress - the progress observer. | public static boolean | copy(ProgressObserver progress, String sourcePath, String targetPath, Component comp, boolean canStop) Copy a file to another using VFS.
Parameters: progress - the progress observer. | public Object | createVFSSession(String path, Component comp) Creates a VFS session. | public int | getCapabilities() Returns the capabilities of this VFS. | public static Color | getDefaultColorFor(String name) Returns color of the specified file name, by matching it against
user-specified regular expressions. | public String[] | getExtendedAttributes() Returns the extended attributes supported by this VFS. | public String | getFileName(String path) Returns the file name component of the specified path. | public char | getFileSeparator() Returns the file separator used by this VFS. | public String | getName() Returns this VFS's name. | public String | getParentOfPath(String path) Returns the parent of the specified path. | public String | getTwoStageSaveName(String path) Returns a temporary file name based on the given path.
By default jEdit first saves a file to #name#save#
and then renames it to the original file. | public boolean | insert(View view, Buffer buffer, String path) Inserts a file into the specified buffer. | public boolean | isMarkersFileSupported() Returns if an additional markers file can be saved by this VFS. | public boolean | load(View view, Buffer buffer, String path) Loads the specified buffer. | public void | reloadDirectory(String path) Called before a directory is reloaded by the file system browser. | public boolean | save(View view, Buffer buffer, String path) Saves the specifies buffer. | public String | showBrowseDialog(Object[] session, Component comp) Displays a dialog box that should set up a session and return
the initial URL to browse. |
BROWSE_CAP | final public static int BROWSE_CAP(Code) | | Browse capability
since: jEdit 4.3pre11 since: This was the official API for adding items to a file since: system browser's Plugins menu in jEdit 4.1 and earlier. In since: jEdit 4.2, there is a different way of doing this, you must provide since: a browser.actions.xml file in your plugin JAR, and since: define plugin.class.browser-menu-item since: or plugin.class.browser-menu properties. since: See org.gjt.sp.jedit.EditPlugin since: for details. |
CASE_INSENSITIVE_CAP | final public static int CASE_INSENSITIVE_CAP(Code) | | Case insensitive file system capability.
since: jEdit 4.1pre1 |
DELETE_CAP | final public static int DELETE_CAP(Code) | | Delete file capability.
since: jEdit 2.6pre2 |
EA_MODIFIED | final public static String EA_MODIFIED(Code) | | File last modified date.
since: jEdit 4.2pre1 |
EA_SIZE | final public static String EA_SIZE(Code) | | File size.
since: jEdit 4.2pre1 |
EA_STATUS | final public static String EA_STATUS(Code) | | File status (read only, read write, etc).
since: jEdit 4.2pre1 |
EA_TYPE | final public static String EA_TYPE(Code) | | File type.
since: jEdit 4.2pre1 |
IOBUFSIZE | public static int IOBUFSIZE(Code) | | |
LOW_LATENCY_CAP | final public static int LOW_LATENCY_CAP(Code) | | Low latency capability. If this is not set, then a confirm dialog
will be shown before doing a directory search in this VFS.
since: jEdit 4.1pre1 |
MKDIR_CAP | final public static int MKDIR_CAP(Code) | | Make directory capability.
since: jEdit 2.6pre2 |
READ_CAP | final public static int READ_CAP(Code) | | Read capability.
since: jEdit 2.6pre2 |
RENAME_CAP | final public static int RENAME_CAP(Code) | | Rename file capability.
since: jEdit 2.6pre2 |
WRITE_CAP | final public static int WRITE_CAP(Code) | | Write capability.
since: jEdit 2.6pre2 |
VFS | public VFS(String name, int caps)(Code) | | Creates a new virtual filesystem.
Parameters: name - The name Parameters: caps - The capabilities |
VFS | public VFS(String name, int caps, String[] extAttrs)(Code) | | Creates a new virtual filesystem.
Parameters: name - The name Parameters: caps - The capabilities Parameters: extAttrs - The extended attributes since: jEdit 4.2pre1 |
_backup | public void _backup(Object session, String path, Component comp) throws IOException(Code) | | Backs up the specified file. This should only be overriden by
the local filesystem VFS.
Parameters: session - The VFS session Parameters: path - The path Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurs since: jEdit 3.2pre2 |
_canonPath | public String _canonPath(Object session, String path, Component comp) throws IOException(Code) | | Returns the canonical form of the specified path name. For example,
~ might be expanded to the user's home directory.
Parameters: session - The session Parameters: path - The path Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurred since: jEdit 4.0pre2 |
_createInputStream | public InputStream _createInputStream(Object session, String path, boolean ignoreErrors, Component comp) throws IOException(Code) | | Creates an input stream. This method is called from the I/O
thread.
Parameters: session - the VFS session Parameters: path - The path Parameters: ignoreErrors - If true, file not found errors should beignored Parameters: comp - The component that will parent error dialog boxes an inputstream or null if there was a problem exception: IOException - If an I/O error occurs since: jEdit 2.7pre1 |
_createOutputStream | public OutputStream _createOutputStream(Object session, String path, Component comp) throws IOException(Code) | | Creates an output stream. This method is called from the I/O
thread.
Parameters: session - the VFS session Parameters: path - The path Parameters: comp - The component that will parent error dialog boxes exception: IOException - If an I/O error occurs since: jEdit 2.7pre1 |
_delete | public boolean _delete(Object session, String path, Component comp) throws IOException(Code) | | Deletes the specified URL.
Parameters: session - The VFS session Parameters: path - The path Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurs since: jEdit 2.7pre1 |
_endVFSSession | public void _endVFSSession(Object session, Component comp) throws IOException(Code) | | Finishes the specified VFS session. This must be called
after all I/O with this VFS is complete, to avoid leaving
stale network connections and such.
Parameters: session - The VFS session Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurred since: jEdit 2.7pre1 |
_finishTwoStageSave | public void _finishTwoStageSave(Object session, Buffer buffer, String path, Component comp) throws IOException(Code) | | Called after a file has been saved and we use twoStageSave (first saving to
another file). This should re-apply permissions for example.
Parameters: session - The VFS session Parameters: buffer - The buffer Parameters: path - The path the buffer was saved to (can be different fromorg.gjt.sp.jedit.Buffer.getPath if the user invoked theSave a Copy As command, for example). Parameters: comp - The component that will parent error dialog boxes exception: IOException - If an I/O error occurs since: jEdit 4.3pre4 |
_getDirectoryEntry | public DirectoryEntry _getDirectoryEntry(Object session, String path, Component comp) throws IOException(Code) | | Returns the specified directory entry.
Parameters: session - The session get it with VFS.createVFSSession(StringComponent) Parameters: path - The path Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurred The specified directory entry, or null if it doesn't exist. since: jEdit 2.7pre1 |
_listDirectory | public String[] _listDirectory(Object session, String directory, String glob, boolean recursive, Component comp) throws IOException(Code) | | A convinience method that matches file names against globs, and can
optionally list the directory recursively.
Parameters: session - The session Parameters: directory - The directory. Note that this must be a fullURL, including the host name, path name, and so on. Theusername and password (if needed by the VFS) is obtained from thesession instance. Parameters: glob - Only file names matching this glob will be returned Parameters: recursive - If true, subdirectories will also be listed. Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurred since: jEdit 4.1pre1 |
_listDirectory | public String[] _listDirectory(Object session, String directory, String glob, boolean recursive, Component comp, boolean skipBinary, boolean skipHidden) throws IOException(Code) | | A convinience method that matches file names against globs, and can
optionally list the directory recursively.
Parameters: session - The session Parameters: directory - The directory. Note that this must be a fullURL, including the host name, path name, and so on. Theusername and password (if needed by the VFS) is obtained from thesession instance. Parameters: glob - Only file names matching this glob will be returned Parameters: recursive - If true, subdirectories will also be listed. Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurred Parameters: skipBinary - ignore binary files (do not return them).This will slow down the process since it will open the files Parameters: skipHidden - skips hidden files, directories, andbackup files. Ignores any file beginning with . or #, or ending with ~or .bak since: jEdit 4.3pre5 |
_listDirectory | public String[] _listDirectory(Object session, String directory, VFSFileFilter filter, boolean recursive, Component comp, boolean skipBinary, boolean skipHidden) throws IOException(Code) | | A convinience method that filters the directory listing
according to a filter, and can optionally list the directory
recursively.
Parameters: session - The session Parameters: directory - The directory. Note that this must be a fullURL, including the host name, path name, and so on. Theusername and password (if needed by the VFS) is obtained from thesession instance. Parameters: filter - The VFSFileFilter to use for filtering. Parameters: recursive - If true, subdirectories will also be listed. Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurred Parameters: skipBinary - ignore binary files (do not return them).This will slow down the process since it will open the files Parameters: skipHidden - skips hidden files, directories, andbackup files. Ignores any file beginning with . or #, or ending with ~or .bak since: jEdit 4.3pre7 |
_listFiles | public VFSFile[] _listFiles(Object session, String directory, Component comp) throws IOException(Code) | | Lists the specified directory.
Parameters: session - The session Parameters: directory - The directory. Note that this must be a fullURL, including the host name, path name, and so on. Theusername and password (if needed by the VFS) is obtained from thesession instance. Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurred since: jEdit 4.3pre2 |
_mkdir | public boolean _mkdir(Object session, String directory, Component comp) throws IOException(Code) | | Creates a new directory with the specified URL.
Parameters: session - The VFS session Parameters: directory - The directory Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurs since: jEdit 2.7pre1 |
_rename | public boolean _rename(Object session, String from, String to, Component comp) throws IOException(Code) | | Renames the specified URL. Some filesystems might support moving
URLs between directories, however others may not. Do not rely on
this behavior.
Parameters: session - The VFS session Parameters: from - The old path Parameters: to - The new path Parameters: comp - The component that will parent error dialog boxes exception: IOException - if an I/O error occurs since: jEdit 2.7pre1 |
_saveComplete | public void _saveComplete(Object session, Buffer buffer, String path, Component comp) throws IOException(Code) | | Called after a file has been saved.
Parameters: session - The VFS session Parameters: buffer - The buffer Parameters: path - The path the buffer was saved to (can be different fromorg.gjt.sp.jedit.Buffer.getPath if the user invoked theSave a Copy As command, for example). Parameters: comp - The component that will parent error dialog boxes exception: IOException - If an I/O error occurs since: jEdit 4.1pre9 |
constructPath | public String constructPath(String parent, String path)(Code) | | Constructs a path from the specified directory and
file name component. This must be overridden to return a
non-null value, otherwise browsing this filesystem will
not work.
Unless you are writing a VFS, this method should not be called
directly. To ensure correct behavior, you must call
org.gjt.sp.jedit.MiscUtilities.constructPath(StringString) instead.
Parameters: parent - The parent directory Parameters: path - The path since: jEdit 2.6pre2 |
copy | public static boolean copy(ProgressObserver progress, VFS sourceVFS, Object sourceSession, String sourcePath, VFS targetVFS, Object targetSession, String targetPath, Component comp, boolean canStop) throws IOException(Code) | | Copy a file to another using VFS.
Parameters: progress - the progress observer. It could be null if you don't want to monitor progress. If not nullyou should probably launch this command in a WorkThread Parameters: sourceVFS - the source VFS Parameters: sourceSession - the VFS session Parameters: sourcePath - the source path Parameters: targetVFS - the target VFS Parameters: targetSession - the target session Parameters: targetPath - the target path Parameters: comp - comp The component that will parent error dialog boxes true if the copy was successful throws: IOException - IOException If an I/O error occurs since: jEdit 4.3pre3 |
copy | public static boolean copy(ProgressObserver progress, String sourcePath, String targetPath, Component comp, boolean canStop) throws IOException(Code) | | Copy a file to another using VFS.
Parameters: progress - the progress observer. It could be null if you don't want to monitor progress. If not nullyou should probably launch this command in a WorkThread Parameters: sourcePath - the source path Parameters: targetPath - the target path Parameters: comp - comp The component that will parent error dialog boxes Parameters: canStop - if true the copy can be stopped true if the copy was successful throws: IOException - IOException If an I/O error occurs since: jEdit 4.3pre3 |
createVFSSession | public Object createVFSSession(String path, Component comp)(Code) | | Creates a VFS session. This method is called from the AWT thread,
so it should not do any I/O. It could, however, prompt for
a login name and password, for example.
Parameters: path - The path in question Parameters: comp - The component that will parent any dialog boxes shown The session. The session can be null if there were errors since: jEdit 2.6pre3 |
getCapabilities | public int getCapabilities()(Code) | | Returns the capabilities of this VFS.
since: jEdit 2.6pre2 |
getDefaultColorFor | public static Color getDefaultColorFor(String name)(Code) | | Returns color of the specified file name, by matching it against
user-specified regular expressions.
since: jEdit 4.0pre1 |
getExtendedAttributes | public String[] getExtendedAttributes()(Code) | | Returns the extended attributes supported by this VFS.
since: jEdit 4.2pre1 |
getFileName | public String getFileName(String path)(Code) | | Returns the file name component of the specified path.
Parameters: path - The path since: jEdit 3.1pre4 |
getFileSeparator | public char getFileSeparator()(Code) | | Returns the file separator used by this VFS.
since: jEdit 2.6pre9 |
getName | public String getName()(Code) | | Returns this VFS's name. The name is used to obtain the
label stored in the vfs.name.label
property.
|
getParentOfPath | public String getParentOfPath(String path)(Code) | | Returns the parent of the specified path. This must be
overridden to return a non-null value for browsing of this
filesystem to work.
Parameters: path - The path since: jEdit 2.6pre5 |
getTwoStageSaveName | public String getTwoStageSaveName(String path)(Code) | | Returns a temporary file name based on the given path.
By default jEdit first saves a file to #name#save#
and then renames it to the original file. However some virtual file
systems might not support the # character in filenames,
so this method permits the VFS to override this behavior.
If this method returns null , two stage save will not
be used for that particular file (introduced in jEdit 4.3pre1).
Parameters: path - The path name since: jEdit 4.1pre7 |
insert | public boolean insert(View view, Buffer buffer, String path)(Code) | | Inserts a file into the specified buffer. The default implementation
posts an I/O request to the I/O thread.
Parameters: view - The view Parameters: buffer - The buffer Parameters: path - The path |
isMarkersFileSupported | public boolean isMarkersFileSupported()(Code) | | Returns if an additional markers file can be saved by this VFS.
Default is
true .
since: jEdit 4.3pre10 |
load | public boolean load(View view, Buffer buffer, String path)(Code) | | Loads the specified buffer. The default implementation posts
an I/O request to the I/O thread.
Parameters: view - The view Parameters: buffer - The buffer Parameters: path - The path |
reloadDirectory | public void reloadDirectory(String path)(Code) | | Called before a directory is reloaded by the file system browser.
Can be used to flush a cache, etc.
since: jEdit 4.0pre3 |
save | public boolean save(View view, Buffer buffer, String path)(Code) | | Saves the specifies buffer. The default implementation posts
an I/O request to the I/O thread.
Parameters: view - The view Parameters: buffer - The buffer Parameters: path - The path |
showBrowseDialog | public String showBrowseDialog(Object[] session, Component comp)(Code) | | Displays a dialog box that should set up a session and return
the initial URL to browse.
Parameters: session - Where the VFS session will be stored Parameters: comp - The component that will parent error dialog boxes The URL since: jEdit 2.7pre1 |
|
|