PageRenderTime 44ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Java | 86 lines | 40 code | 11 blank | 35 comment | 3 complexity | 880084704d2b2a4032d700197385f731 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. package org.gjt.sp.jedit.io;
  23. //{{{ Imports
  24. import java.awt.Component;
  25. import java.io.File;
  26. import org.gjt.sp.util.Log;
  27. //}}}
  28. /**
  29. * A VFS that lists local root filesystems.
  30. * @author Slava Pestov
  31. * @version $Id: FileRootsVFS.java 3935 2001-12-11 06:32:54Z spestov $
  32. */
  33. public class FileRootsVFS extends VFS
  34. {
  35. public static final String PROTOCOL = "roots";
  36. //{{{ FileRootsVFS constructor
  37. public FileRootsVFS()
  38. {
  39. super("roots");
  40. } //}}}
  41. //{{{ getCapabilities() method
  42. public int getCapabilities()
  43. {
  44. // BROWSE_CAP not set because we don't want the VFS browser
  45. // to create the default 'favorites' item in the 'More' menu
  46. return 0 /* BROWSE_CAP | */;
  47. } //}}}
  48. //{{{ getParentOfPath() method
  49. public String getParentOfPath(String path)
  50. {
  51. return PROTOCOL + ":";
  52. } //}}}
  53. //{{{ _listDirectory() method
  54. public VFS.DirectoryEntry[] _listDirectory(Object session, String url,
  55. Component comp)
  56. {
  57. File[] roots = File.listRoots();
  58. if(roots == null)
  59. return null;
  60. VFS.DirectoryEntry[] rootDE = new VFS.DirectoryEntry[roots.length];
  61. for(int i = 0; i < roots.length; i++)
  62. {
  63. String name = roots[i].getPath();
  64. rootDE[i] = _getDirectoryEntry(session,name,comp);
  65. }
  66. return rootDE;
  67. } //}}}
  68. //{{{ _getDirectoryEntry() method
  69. public DirectoryEntry _getDirectoryEntry(Object session, String path,
  70. Component comp)
  71. {
  72. return new VFS.DirectoryEntry(path,path,path,VFS.DirectoryEntry
  73. .FILESYSTEM,0L,false);
  74. } //}}}
  75. }