📄 vfs.java
字号:
*/ public String _canonPath(Object session, String path, Component comp) throws IOException { return path; } //}}} //{{{ _listDirectory() method /** * A convinience method that matches file names against globs, and can * optionally list the directory recursively. * @param session The session * @param directory The directory. Note that this must be a full * URL, including the host name, path name, and so on. The * username and password (if needed by the VFS) is obtained from the * session instance. * @param glob Only file names matching this glob will be returned * @param recursive If true, subdirectories will also be listed. * @param comp The component that will parent error dialog boxes * @exception IOException if an I/O error occurred * @since jEdit 4.1pre1 */ public String[] _listDirectory(Object session, String directory, String glob, boolean recursive, Component comp) throws IOException { Log.log(Log.DEBUG,this,"Listing " + directory); ArrayList files = new ArrayList(100); RE filter; try { filter = new RE(MiscUtilities.globToRE(glob), RE.REG_ICASE); } catch(REException e) { Log.log(Log.ERROR,this,e); return null; } _listDirectory(session,new ArrayList(),files,directory,filter, recursive,comp); String[] retVal = (String[])files.toArray(new String[files.size()]); Arrays.sort(retVal,new MiscUtilities.StringICaseCompare()); return retVal; } //}}} //{{{ _listDirectory() method /** * Lists the specified directory. * @param session The session * @param directory The directory. Note that this must be a full * URL, including the host name, path name, and so on. The * username and password (if needed by the VFS) is obtained from the * session instance. * @param comp The component that will parent error dialog boxes * @exception IOException if an I/O error occurred * @since jEdit 2.7pre1 */ public DirectoryEntry[] _listDirectory(Object session, String directory, Component comp) throws IOException { VFSManager.error(comp,directory,"vfs.not-supported.list",new String[] { name }); return null; } //}}} //{{{ _getDirectoryEntry() method /** * Returns the specified directory entry. * @param session The session * @param path The path * @param comp The component that will parent error dialog boxes * @exception IOException if an I/O error occurred * @return The specified directory entry, or null if it doesn't exist. * @since jEdit 2.7pre1 */ public DirectoryEntry _getDirectoryEntry(Object session, String path, Component comp) throws IOException { return null; } //}}} //{{{ DirectoryEntry class /** * A directory entry. * @since jEdit 2.6pre2 */ public static class DirectoryEntry implements Serializable { //{{{ File types public static final int FILE = 0; public static final int DIRECTORY = 1; public static final int FILESYSTEM = 2; //}}} //{{{ Instance variables public String name; public String path; public String deletePath; public int type; public long length; public boolean hidden; //}}} //{{{ DirectoryEntry constructor public DirectoryEntry(String name, String path, String deletePath, int type, long length, boolean hidden) { this.name = name; this.path = path; this.deletePath = deletePath; this.type = type; this.length = length; this.hidden = hidden; } //}}} protected boolean colorCalculated; protected Color color; //{{{ getColor() method public Color getColor() { if(!colorCalculated) { colorCalculated = true; color = getDefaultColorFor(name); } return color; } //}}} //{{{ toString() method public String toString() { return name; } //}}} } //}}} //{{{ _delete() method /** * Deletes the specified URL. * @param session The VFS session * @param path The path * @param comp The component that will parent error dialog boxes * @exception IOException if an I/O error occurs * @since jEdit 2.7pre1 */ public boolean _delete(Object session, String path, Component comp) throws IOException { return false; } //}}} //{{{ _rename() method /** * Renames the specified URL. Some filesystems might support moving * URLs between directories, however others may not. Do not rely on * this behavior. * @param session The VFS session * @param from The old path * @param to The new path * @param comp The component that will parent error dialog boxes * @exception IOException if an I/O error occurs * @since jEdit 2.7pre1 */ public boolean _rename(Object session, String from, String to, Component comp) throws IOException { return false; } //}}} //{{{ _mkdir() method /** * Creates a new directory with the specified URL. * @param session The VFS session * @param directory The directory * @param comp The component that will parent error dialog boxes * @exception IOException if an I/O error occurs * @since jEdit 2.7pre1 */ public boolean _mkdir(Object session, String directory, Component comp) throws IOException { return false; } //}}} //{{{ _backup() method /** * Backs up the specified file. This should only be overriden by * the local filesystem VFS. * @param session The VFS session * @param path The path * @param comp The component that will parent error dialog boxes * @exception IOException if an I/O error occurs * @since jEdit 3.2pre2 */ public void _backup(Object session, String path, Component comp) throws IOException { } //}}} //{{{ _createInputStream() method /** * Creates an input stream. This method is called from the I/O * thread. * @param session the VFS session * @param path The path * @param ignoreErrors If true, file not found errors should be * ignored * @param comp The component that will parent error dialog boxes * @exception IOException If an I/O error occurs * @since jEdit 2.7pre1 */ public InputStream _createInputStream(Object session, String path, boolean ignoreErrors, Component comp) throws IOException { VFSManager.error(comp,path,"vfs.not-supported.load",new String[] { name }); return null; } //}}} //{{{ _createOutputStream() method /** * Creates an output stream. This method is called from the I/O * thread. * @param session the VFS session * @param path The path * @param comp The component that will parent error dialog boxes * @exception IOException If an I/O error occurs * @since jEdit 2.7pre1 */ public OutputStream _createOutputStream(Object session, String path, Component comp) throws IOException { VFSManager.error(comp,path,"vfs.not-supported.save",new String[] { name }); return null; } //}}} //{{{ _saveComplete() method /** * Called after a file has been saved. * @param session The VFS session * @param buffer The buffer * @param path The path the buffer was saved to (can be different from * {@link org.gjt.sp.jedit.Buffer#getPath()} if the user invoked the * <b>Save a Copy As</b> command, for example). * @param comp The component that will parent error dialog boxes * @exception IOException If an I/O error occurs * @since jEdit 4.1pre9 */ public void _saveComplete(Object session, Buffer buffer, String path, Component comp) throws IOException {} //}}} //{{{ _endVFSSession() method /** * 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. * @param session The VFS session * @param comp The component that will parent error dialog boxes * @exception IOException if an I/O error occurred * @since jEdit 2.7pre1 */ public void _endVFSSession(Object session, Component comp) throws IOException { } //}}} //{{{ getDefaultColorFor() method /** * Returns color of the specified file name, by matching it against * user-specified regular expressions. * @since jEdit 4.0pre1 */ public static Color getDefaultColorFor(String name) { synchronized(lock) { if(colors == null) loadColors(); for(int i = 0; i < colors.size(); i++) { ColorEntry entry = (ColorEntry)colors.elementAt(i); if(entry.re.isMatch(name)) return entry.color; } return null; } } //}}} //{{{ Private members private String name; private int caps; private static Vector colors; private static Object lock = new Object(); //{{{ Class initializer static { EditBus.addToBus(new EBComponent() { public void handleMessage(EBMessage msg) { if(msg instanceof PropertiesChanged) { synchronized(lock) { colors = null; } } } }); } //}}} //{{{ _listDirectory() method private void _listDirectory(Object session, ArrayList stack, ArrayList files, String directory, RE glob, boolean recursive, Component comp) throws IOException { if(stack.contains(directory)) { Log.log(Log.ERROR,this, "Recursion in _listDirectory(): " + directory); return; } else stack.add(directory); VFS.DirectoryEntry[] _files = _listDirectory(session,directory, comp); if(_files == null || _files.length == 0) return; for(int i = 0; i < _files.length; i++) { VFS.DirectoryEntry file = _files[i]; if(file.type == VFS.DirectoryEntry.DIRECTORY || file.type == VFS.DirectoryEntry.FILESYSTEM) { if(recursive) { // resolve symlinks to avoid loops String canonPath = _canonPath(session,file.path,comp); _listDirectory(session,stack,files, canonPath,glob,recursive, comp); } } else { if(!glob.isMatch(file.name)) continue; Log.log(Log.DEBUG,this,file.path); files.add(file.path); } } } //}}} //{{{ loadColors() method private static void loadColors() { synchronized(lock) { colors = new Vector(); if(!jEdit.getBooleanProperty("vfs.browser.colorize")) return; String glob; int i = 0; while((glob = jEdit.getProperty("vfs.browser.colors." + i + ".glob")) != null) { try { colors.addElement(new ColorEntry( new RE(MiscUtilities.globToRE(glob)), jEdit.getColorProperty( "vfs.browser.colors." + i + ".color", Color.black))); i++; } catch(REException e) { Log.log(Log.ERROR,VFS.class,"Invalid regular expression: " + glob); Log.log(Log.ERROR,VFS.class,e); } } } } //}}} //{{{ ColorEntry class static class ColorEntry { RE re; Color color; ColorEntry(RE re, Color color) { this.re = re; this.color = color; } } //}}} //}}}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -