// Path: app/src/main/java/javax/bluetooth/BTL2CAPConnectionProvider.java
// public class BTL2CAPConnectionProvider implements ConnectionProvider
// {
// 	public Connection open(String name, int mode) throws IOException
// 	{
// 		if(name.startsWith("localhost:"))
// 		{
// 			String[] params = name.substring(10).split(";");
// 			name = null;
// 			
// 			for(int i = 1; i < params.length; i++)
// 			{
// 				if(params[i].startsWith("name="))
// 				{
// 					name = params[i].substring(5);
// 					break;
// 				}
// 			}
// 			
// 			if(name == null)
// 			{
// 				name = "MicroBTL2CAP";
// 			}
// 			
// 			return new L2CAPConnectionNotifier(BluetoothAdapter.getDefaultAdapter().listenUsingRfcommWithServiceRecord(name, BTUtils.parseUUID(params[0])));
// 		}
// 		else
// 		{
// 			String[] params = name.split(";")[0].split(":");
// 			
// 			BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(BTUtils.validateBluetoothAddress(params[0]));
// 			BluetoothSocket socket = device.createRfcommSocketToServiceRecord(BTUtils.parseUUID(params[1]));
// 			
// 			return new L2CAPConnection(socket);
// 		}
// 	}
// }
// 
// Path: app/src/main/java/javax/microedition/io/file/FileSystemRegistry.java
// public class FileSystemRegistry implements ConnectionProvider
// {
// 	public static final String INTERNAL_DISK = "c:/";
// 	public static final String EXTERNAL_DISK = "e:/";
// 	
// 	private static Vector roots = new Vector();
// 	
// 	public static Enumeration listRoots()
// 	{
// 		synchronized(roots)
// 		{
// 			roots.removeAllElements();
// 			roots.addElement(INTERNAL_DISK);
// 			
// 			String state = Environment.getExternalStorageState();
// 			
// 			if(Environment.MEDIA_MOUNTED.equals(state) ||
// 			   Environment.MEDIA_MOUNTED_READ_ONLY.equals(state))
// 			{
// 				roots.addElement(EXTERNAL_DISK);
// 			}
// 			
// 			return roots.elements();
// 		}
// 	}
// 	
// 	public static String getExternalStoragePath()
// 	{
// 		String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();
// 		
// 		if(sdcard.startsWith("/"))
// 		{
// 			sdcard = sdcard.substring(1);
// 		}
// 		
// 		if(!sdcard.endsWith("/"))
// 		{
// 			sdcard += "/";
// 		}
// 		
// 		return sdcard;
// 	}
// 	
// 	public static String midpFileToAndroid(String name)
// 	{
// 		if(name.startsWith("/"))
// 		{
// 			name = name.substring(1);
// 		}
// 		
// 		if(name.startsWith(INTERNAL_DISK))
// 		{
// 			name = name.substring(INTERNAL_DISK.length());
// 		}
// 		else if(name.startsWith(EXTERNAL_DISK))
// 		{
// 			name = getExternalStoragePath() + name.substring(EXTERNAL_DISK.length());
// 		}
// 		
// 		return "/" + name;
// 	}
// 	
// 	public static String androidFileToMIDP(String name)
// 	{
// 		if(name.startsWith("/"))
// 		{
// 			name = name.substring(1);
// 		}
// 		
// 		String sdcard = getExternalStoragePath();
// 		
// 		if(name.startsWith(sdcard))
// 		{
// 			name = EXTERNAL_DISK + name.substring(sdcard.length());
// 		}
// 		else
// 		{
// 			name = INTERNAL_DISK + name;
// 		}
// 		
// 		return "/" + name;
// 	}
// 	
// 	public Connection open(String name, int mode)
// 	{
// 		return new FileConnection(new File(midpFileToAndroid(name)), (mode & Connector.WRITE) != 0 ? FileConnection.READ_WRITE : FileConnection.READ);
// 	}
// }


import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import javax.bluetooth.BTL2CAPConnectionProvider;
import javax.microedition.io.file.FileSystemRegistry;

/*
 * Copyright 2012 Kulikov Dmitriy
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package javax.microedition.io;



public class Connector
{
	public static final int READ = 1;
	public static final int READ_WRITE = 3;
	public static final int WRITE = 2;
	
	private static HashMap<String, ConnectionProvider> providers;
	
	static
	{

// Path: app/src/main/java/javax/bluetooth/BTL2CAPConnectionProvider.java
// public class BTL2CAPConnectionProvider implements ConnectionProvider
// {
// 	public Connection open(String name, int mode) throws IOException
// 	{
// 		if(name.startsWith("localhost:"))
// 		{
// 			String[] params = name.substring(10).split(";");
// 			name = null;
// 			
// 			for(int i = 1; i < params.length; i++)
// 			{
// 				if(params[i].startsWith("name="))
// 				{
// 					name = params[i].substring(5);
// 					break;
// 				}
// 			}
// 			
// 			if(name == null)
// 			{
// 				name = "MicroBTL2CAP";
// 			}
// 			
// 			return new L2CAPConnectionNotifier(BluetoothAdapter.getDefaultAdapter().listenUsingRfcommWithServiceRecord(name, BTUtils.parseUUID(params[0])));
// 		}
// 		else
// 		{
// 			String[] params = name.split(";")[0].split(":");
// 			
// 			BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(BTUtils.validateBluetoothAddress(params[0]));
// 			BluetoothSocket socket = device.createRfcommSocketToServiceRecord(BTUtils.parseUUID(params[1]));
// 			
// 			return new L2CAPConnection(socket);
// 		}
// 	}
// }
// 
// Path: app/src/main/java/javax/microedition/io/file/FileSystemRegistry.java
// public class FileSystemRegistry implements ConnectionProvider
// {
// 	public static final String INTERNAL_DISK = "c:/";
// 	public static final String EXTERNAL_DISK = "e:/";
// 	
// 	private static Vector roots = new Vector();
// 	
// 	public static Enumeration listRoots()
// 	{
// 		synchronized(roots)
// 		{
// 			roots.removeAllElements();
// 			roots.addElement(INTERNAL_DISK);
// 			
// 			String state = Environment.getExternalStorageState();
// 			
// 			if(Environment.MEDIA_MOUNTED.equals(state) ||
// 			   Environment.MEDIA_MOUNTED_READ_ONLY.equals(state))
// 			{
// 				roots.addElement(EXTERNAL_DISK);
// 			}
// 			
// 			return roots.elements();
// 		}
// 	}
// 	
// 	public static String getExternalStoragePath()
// 	{
// 		String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();
// 		
// 		if(sdcard.startsWith("/"))
// 		{
// 			sdcard = sdcard.substring(1);
// 		}
// 		
// 		if(!sdcard.endsWith("/"))
// 		{
// 			sdcard += "/";
// 		}
// 		
// 		return sdcard;
// 	}
// 	
// 	public static String midpFileToAndroid(String name)
// 	{
// 		if(name.startsWith("/"))
// 		{
// 			name = name.substring(1);
// 		}
// 		
// 		if(name.startsWith(INTERNAL_DISK))
// 		{
// 			name = name.substring(INTERNAL_DISK.length());
// 		}
// 		else if(name.startsWith(EXTERNAL_DISK))
// 		{
// 			name = getExternalStoragePath() + name.substring(EXTERNAL_DISK.length());
// 		}
// 		
// 		return "/" + name;
// 	}
// 	
// 	public static String androidFileToMIDP(String name)
// 	{
// 		if(name.startsWith("/"))
// 		{
// 			name = name.substring(1);
// 		}
// 		
// 		String sdcard = getExternalStoragePath();
// 		
// 		if(name.startsWith(sdcard))
// 		{
// 			name = EXTERNAL_DISK + name.substring(sdcard.length());
// 		}
// 		else
// 		{
// 			name = INTERNAL_DISK + name;
// 		}
// 		
// 		return "/" + name;
// 	}
// 	
// 	public Connection open(String name, int mode)
// 	{
// 		return new FileConnection(new File(midpFileToAndroid(name)), (mode & Connector.WRITE) != 0 ? FileConnection.READ_WRITE : FileConnection.READ);
// 	}
// }


// Path: app/src/main/java/javax/microedition/io/Connector.java
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import javax.bluetooth.BTL2CAPConnectionProvider;
import javax.microedition.io.file.FileSystemRegistry;

/*
 * Copyright 2012 Kulikov Dmitriy
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package javax.microedition.io;



public class Connector
{
	public static final int READ = 1;
	public static final int READ_WRITE = 3;
	public static final int WRITE = 2;
	
	private static HashMap<String, ConnectionProvider> providers;
	
	static
	{

		registerConnectionProvider("file", new FileSystemRegistry());
