PageRenderTime 109ms CodeModel.GetById 103ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre5/org/gjt/sp/jedit/io/FileRootsVFS.java

#
Java | 86 lines | 40 code | 11 blank | 35 comment | 3 complexity | 880084704d2b2a4032d700197385f731 MD5 | raw file
 1/*
 2 * FileRootsVFS.java - Local root filesystems VFS
 3 * :tabSize=8:indentSize=8:noTabs=false:
 4 * :folding=explicit:collapseFolds=1:
 5 *
 6 * Copyright (C) 2000, 2001 Slava Pestov
 7 *
 8 * This program is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 */
22
23package org.gjt.sp.jedit.io;
24
25//{{{ Imports
26import java.awt.Component;
27import java.io.File;
28import org.gjt.sp.util.Log;
29//}}}
30
31/**
32 * A VFS that lists local root filesystems.
33 * @author Slava Pestov
34 * @version $Id: FileRootsVFS.java 3935 2001-12-11 06:32:54Z spestov $
35 */
36public class FileRootsVFS extends VFS
37{
38	public static final String PROTOCOL = "roots";
39
40	//{{{ FileRootsVFS constructor
41	public FileRootsVFS()
42	{
43		super("roots");
44	} //}}}
45
46	//{{{ getCapabilities() method
47	public int getCapabilities()
48	{
49		// BROWSE_CAP not set because we don't want the VFS browser
50		// to create the default 'favorites' item in the 'More' menu
51		return 0 /* BROWSE_CAP | */;
52	} //}}}
53
54	//{{{ getParentOfPath() method
55	public String getParentOfPath(String path)
56	{
57		return PROTOCOL + ":";
58	} //}}}
59
60	//{{{ _listDirectory() method
61	public VFS.DirectoryEntry[] _listDirectory(Object session, String url,
62		Component comp)
63	{
64		File[] roots = File.listRoots();
65
66		if(roots == null)
67			return null;
68
69		VFS.DirectoryEntry[] rootDE = new VFS.DirectoryEntry[roots.length];
70		for(int i = 0; i < roots.length; i++)
71		{
72			String name = roots[i].getPath();
73			rootDE[i] = _getDirectoryEntry(session,name,comp);
74		}
75
76		return rootDE;
77	} //}}}
78
79	//{{{ _getDirectoryEntry() method
80	public DirectoryEntry _getDirectoryEntry(Object session, String path,
81		Component comp)
82	{
83		return new VFS.DirectoryEntry(path,path,path,VFS.DirectoryEntry
84			.FILESYSTEM,0L,false);
85	} //}}}
86}