[openrtm-commit:03314] r1120 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 3月 28日 (水) 15:07:07 JST
Author: t-katami
Date: 2018-03-28 15:07:07 +0900 (Wed, 28 Mar 2018)
New Revision: 1120
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ModuleManager.java
Log:
[compat,newfunc->RELENG_1_2] Made it possible to search the existing module in below of specified path. refs #4499
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ModuleManager.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ModuleManager.java 2018-03-20 08:45:35 UTC (rev 1119)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ModuleManager.java 2018-03-28 06:07:07 UTC (rev 1120)
@@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Stack;
import java.util.Vector;
import jp.go.aist.rtm.RTC.util.Properties;
@@ -86,6 +87,7 @@
}
m_loadPath.add(loadPath[i]);
}
+ m_loadPath = recursiveDirectory(m_loadPath);
m_absoluteAllowed = StringUtil.toBool(
properties.getProperty(ALLOW_ABSPATH), "yes", "no", false);
@@ -361,7 +363,8 @@
URI uri = path.toURI();
urls[0] = uri.toURL();
} catch(java.net.MalformedURLException ex){
- rtcout.println(Logbuf.WARN, "java.net.MalformedURLException: toURL() threw Exception."+ex);
+ rtcout.println(Logbuf.WARN,
+ "java.net.MalformedURLException: toURL() threw Exception."+ex);
return null;
}
URLClassLoader url = new URLClassLoader(urls);
@@ -548,6 +551,7 @@
*/
public void setLoadpath(final Vector<String> loadPath) {
m_loadPath = new Vector<String>(loadPath);
+ m_loadPath = recursiveDirectory(m_loadPath);
}
/**
@@ -580,7 +584,8 @@
* {@.en List of additional module search path}
*/
public void addLoadPath(final Vector<String> loadPath) {
- m_loadPath.addAll(loadPath);
+ Vector<String>loadpath = recursiveDirectory(loadPath);
+ m_loadPath.addAll(loadpath);
}
/**
@@ -1133,6 +1138,7 @@
public Class dll;
}
+
/**
* {@.ja モジュール・ロード・パス・リスト}
* {@.en Module load path list}
@@ -1184,4 +1190,26 @@
}
private Logbuf rtcout;
private ArrayList<Properties> m_modprofs = new ArrayList<Properties>();
+ /**
+ * {@.ja 指定したパス以下に存在するディレクトリを探索する}
+ * {@.en Searches the directory which exists in below of designated paths.}
+ */
+ private Vector<String> recursiveDirectory(Vector<String> paths){
+ Vector<String> result = new Vector<String>();
+ for(String path:paths){
+ Stack<File> stack = new Stack<>();
+ stack.add(new File(path));
+ while(!stack.isEmpty()){
+ File item = stack.pop();
+ if (item.isDirectory()) {
+ result.add(item.getPath());
+ for (File child : item.listFiles()){
+ stack.push(child);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
}
openrtm-commit メーリングリストの案内