1 package jp.go.aist.hrp.joystick;
4 import java.io.FileOutputStream;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.io.OutputStream;
10 import org.eclipse.core.runtime.FileLocator;
11 import org.eclipse.jface.resource.ImageDescriptor;
12 import org.eclipse.ui.plugin.AbstractUIPlugin;
13 import org.osgi.framework.BundleContext;
21 public static final String
PLUGIN_ID =
"JoystickPlugin";
26 private static final String
LINUX_HOME_DIR = System.getenv(
"HOME") + File.separator ;
27 private static final String
WIN_HOME_DIR = System.getenv(
"APPDATA") + File.separator;
43 public void start(BundleContext context)
throws Exception {
51 public void stop(BundleContext context)
throws Exception {
62 URL entry =
getDefault().getBundle().getEntry(
"/");
63 String pluginDirectory =
"";
65 pluginDirectory = FileLocator.resolve(entry).
getPath();
66 }
catch (IOException e) {
69 return pluginDirectory;
100 public static void resourceToFile(Class<jp.go.aist.hrp.joystick.Activator> pluginManager, String srcName, File destFile)
102 InputStream in = pluginManager.getResourceAsStream(srcName.toString());
103 OutputStream out =
new FileOutputStream(destFile.toString());
105 byte[]
buf =
new byte[1024];
107 while ((len = in.read(
buf)) > 0) {
108 out.write(
buf, 0, len);
110 }
catch (IOException e) {
124 if (!rtcFile.exists()){
127 }
catch (IOException ex){
128 ex.printStackTrace();
141 if( defualtRtcFile.isFile() ){
142 confPath = defualtRtcFile.getPath();
146 System.out.println(
"[Joystick] default Config File path="+confPath);
158 return imageDescriptorFromPlugin(
PLUGIN_ID, path);
165 if ( System.getProperty(
"os.name").equals(
"Linux") ||
166 System.getProperty(
"os.name").equals(
"Mac OS X")) {