1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.microemu.cldc.file;
28
29 import java.security.AccessControlContext;
30 import java.security.AccessController;
31 import java.security.PrivilegedAction;
32 import java.util.Enumeration;
33
34 import javax.microedition.io.file.FileSystemListener;
35
36 import org.microemu.microedition.Implementation;
37
38 public class FileSystemRegistryImpl implements FileSystemRegistryDelegate, Implementation {
39
40
41 private AccessControlContext acc;
42
43 private String fsRoot;
44
45 private String fsSingle;
46
47 public FileSystemRegistryImpl() {
48 this.acc = AccessController.getContext();
49 }
50
51 public FileSystemRegistryImpl(String fsRoot, String fsSingle) {
52 this();
53 this.fsRoot = fsRoot;
54 this.fsSingle = fsSingle;
55 }
56
57 public Enumeration listRoots() {
58 switch (Connection.getConnectionType()) {
59 case Connection.CONNECTIONTYPE_SYSTEM_FS:
60 return (Enumeration) AccessController.doPrivileged(new PrivilegedAction() {
61 public Object run() {
62 return FileSystemFileConnection.listRoots(fsRoot, fsSingle);
63 }
64 }, acc);
65 default:
66 throw new RuntimeException("Invalid connectionType configuration");
67 }
68 }
69
70 public boolean addFileSystemListener(FileSystemListener listener) {
71
72 return false;
73 }
74
75 public boolean removeFileSystemListener(FileSystemListener listener) {
76
77 return false;
78 }
79
80 }