View Javadoc

1   /**
2    *  MicroEmulator
3    *  Copyright (C) 2006-2007 Bartek Teodorczyk <barteo@barteo.net>
4    *  Copyright (C) 2006-2007 Vlad Skarzhevskyy
5    *
6    *  It is licensed under the following two licenses as alternatives:
7    *    1. GNU Lesser General Public License (the "LGPL") version 2.1 or any newer version
8    *    2. Apache License (the "AL") Version 2.0
9    *
10   *  You may not use this file except in compliance with at least one of
11   *  the above two licenses.
12   *
13   *  You may obtain a copy of the LGPL at
14   *      http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
15   *
16   *  You may obtain a copy of the AL at
17   *      http://www.apache.org/licenses/LICENSE-2.0
18   *
19   *  Unless required by applicable law or agreed to in writing, software
20   *  distributed under the License is distributed on an "AS IS" BASIS,
21   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22   *  See the LGPL or the AL for the specific language governing permissions and
23   *  limitations.
24   *
25   *  @version $Id: FileSystemRegistryImpl.java 1874 2008-12-17 11:46:29Z barteo $
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  	/* The context to be used when accessing filesystem */
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  		// TODO Auto-generated method stub
72  		return false;
73  	}
74  
75  	public boolean removeFileSystemListener(FileSystemListener listener) {
76  		// TODO Auto-generated method stub
77  		return false;
78  	}
79  
80  }