source: other-projects/FileTransfer-WebSocketPair/testGXTWithGreenstone/src/org/greenstone/gatherer/file/FileSystem.java@ 33053

Last change on this file since 33053 was 33053, checked in by ak19, 5 years ago

I still had some stuff of Nathan Kelly's (FileTransfer-WebSocketPair) sitting on my USB. Had already commited the Themes folder at the time, 2 years back. Not sure if he wanted this additional folder commited. But I didn't want to delete it and decided it will be better off on SVN. When we use his project, if we find we didn't need this test folder, we can remove it from svn then.

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.Gatherer;
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(new File(Gatherer.getGLIUserCacheDirectoryPath()), Dictionary.get("Tree.DownloadedFiles"));
62 }
63}
Note: See TracBrowser for help on using the repository browser.