source: trunk/gli/src/org/greenstone/gatherer/file/FileSystem.java@ 10007

Last change on this file since 10007 was 9755, checked in by mdewsnip, 19 years ago

Replaced all the nonsense where string arrays were created for running perl scripts with array lists. This removes a lot of duplicated code where the same things were added in different cases, and the silly (and error-prone) "new String[11]"s.

  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1package org.greenstone.gatherer.file;
2
3import java.io.File;
4import org.greenstone.gatherer.DebugStream;
5import org.greenstone.gatherer.Dictionary;
6import org.greenstone.gatherer.util.Utility;
7
8
9public class FileSystem
10{
11 static public WorkspaceTreeNode getLocalFilespaceNode(FileSystemModel model)
12 {
13 // Get all the available roots mounted on the filesystem
14 File[] roots = File.listRoots();
15 if (roots == null) {
16 return null;
17 }
18
19 // If there is just one root use it as the tree root (Unix)
20 if (roots.length == 1) {
21 return new WorkspaceTreeNode(roots[0], Dictionary.get("Tree.Root"));
22 }
23
24 // Otherwise build a dummy node which has the roots as children (Windows)
25 else {
26 return new WorkspaceTreeNode(null, Dictionary.get("Tree.Root"));
27 }
28 }
29
30
31 static public WorkspaceTreeNode getHomeFolderNode()
32 {
33 // Get the name of the OS we're running on
34 String os_name = System.getProperty("os.name");
35 if (os_name == null) {
36 return null;
37 }
38
39 // Make sure we're running on a multiuser OS where the idea of a "user home" is valid
40 DebugStream.println("Property os.name: " + os_name);
41 String os_name_lc = os_name.toLowerCase();
42 if (os_name_lc.equals("windows 95") || os_name_lc.equals("windows 98") || os_name_lc.equals("windows me")) {
43 return null;
44 }
45
46 // Get the user's home folder
47 String home_folder_str = System.getProperty("user.home");
48 if (home_folder_str == null || home_folder_str.length() == 0) {
49 return null;
50 }
51
52 // Generate a special mapping to the user home folder
53 File home_folder = new File(home_folder_str);
54 return new WorkspaceTreeNode(home_folder, Dictionary.get("Tree.Home", home_folder.getName()));
55 }
56
57
58 static public WorkspaceTreeNode getDownloadedFilesNode()
59 {
60 // Return a mapping to the downloaded files folder
61 return new WorkspaceTreeNode(Utility.getCacheDir(), Dictionary.get("Tree.DownloadedFiles"));
62 }
63}
Note: See TracBrowser for help on using the repository browser.