[openrtm-commit:03278] r3256 - in branches/RELENG_1_2/OpenRTM-aist/src/lib: coil/win32/coil rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 3月 26日 (月) 18:16:39 JST
Author: miyamoto
Date: 2018-03-26 18:16:39 +0900 (Mon, 26 Mar 2018)
New Revision: 3256
Modified:
branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/win32/coil/File.h
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ModuleManager.cpp
Log:
[compat,->trunk] refs #4497
Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/win32/coil/File.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/win32/coil/File.h 2018-03-23 07:19:41 UTC (rev 3255)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/win32/coil/File.h 2018-03-26 09:16:39 UTC (rev 3256)
@@ -20,6 +20,7 @@
#define COIL_FILE_H
#include <windows.h>
+#include <fstream>
#include <coil/config_coil.h>
#include <coil/stringutil.h>
@@ -446,7 +447,134 @@
return flist;
}
+ /*!
+ * @if jp
+ *
+ * @brief wèt@C¼ðwèfBNg©çT¸·é
+ *
+ * @param dir fBNgpX
+ * @param filename fBNgpX
+ * @param filelist t@Cê
+ *
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param dir
+ * @param filename
+ * @param filelist
+ *
+ * @endif
+ */
+ inline void findFile(std::string dir, std::string filename, coil::vstring &filelist)
+ {
+ {
+ HANDLE hFind;
+ WIN32_FIND_DATA win32fd;
+ std::string dir_fff = dir + "\\*";
+ hFind = FindFirstFile(dir_fff.c_str(), &win32fd);
+ if (hFind == INVALID_HANDLE_VALUE) {
+ return;
+ }
+ do {
+ if (win32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ std::string filename = win32fd.cFileName;
+ if (filename != "." && filename != "..")
+ {
+ std::string next_dir = dir + "\\" + win32fd.cFileName;
+ findFile(next_dir, filename, filelist);
+ }
+ }
+ else {
+ }
+ } while (FindNextFile(hFind, &win32fd));
+ }
+
+ {
+ std::string file_fff = dir + "\\" + filename;
+ std::ifstream ifs(file_fff);
+
+ if (ifs.is_open())
+ {
+ filelist.push_back(file_fff);
+ }
+
+ }
+ }
+
+
+
+ /*!
+ * @if jp
+ *
+ * @brief t@CêðwèfBNg©çT¸·é
+ *
+ * @param dir fBNgpX
+ * @param ext g£q
+ * @param filelist t@Cê
+ *
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param dir
+ * @param ext
+ * @param filelist
+ *
+ * @endif
+ */
+ inline void getFileList(std::string dir, std::string ext, coil::vstring &filelist)
+ {
+ {
+ HANDLE hFind;
+ WIN32_FIND_DATA win32fd;
+ std::string dir_fff = dir + "\\*";
+ hFind = FindFirstFile(dir_fff.c_str(), &win32fd);
+
+ if (hFind == INVALID_HANDLE_VALUE) {
+ return;
+ }
+ do {
+ if (win32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ std::string filename = win32fd.cFileName;
+ //std::cout << win32fd.cFileName << std::endl;
+ if (filename != "." && filename != "..")
+ {
+ std::string next_dir = dir + "\\" + win32fd.cFileName;
+ getFileList(next_dir, ext, filelist);
+ }
+ }
+ else {
+ }
+ } while (FindNextFile(hFind, &win32fd));
+ }
+
+ {
+ HANDLE hFind;
+ WIN32_FIND_DATA win32fd;
+ std::string file_fff = dir + "\\*." + ext;
+ hFind = FindFirstFile(file_fff.c_str(), &win32fd);
+ if (hFind == INVALID_HANDLE_VALUE) {
+ return;
+ }
+ do {
+ if (win32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+
+ }
+ else {
+ std::string ret = dir + "\\" + win32fd.cFileName;
+ filelist.push_back(ret);
+ }
+ } while (FindNextFile(hFind, &win32fd));
+ }
+
+
+ }
+
+
};
#endif // COIL_FILE_H
Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ModuleManager.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ModuleManager.cpp 2018-03-23 07:19:41 UTC (rev 3255)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ModuleManager.cpp 2018-03-26 09:16:39 UTC (rev 3256)
@@ -374,9 +374,16 @@
{
return f;
}
+ coil::vstring ret;
+ coil::findFile((*it), file_name, ret);
+ if (!ret.empty())
+ {
+ return ret.front();
+ }
+
++it;
}
-
+
return std::string("");
}
@@ -479,8 +486,10 @@
coil::vstring flist;
for (size_t s(0); s < suffixes.size(); ++s)
{
- std::string glob("*."); glob += suffixes[s];
- coil::vstring tmp = coil::filelist(path.c_str(), glob.c_str());
+ //std::string glob("*."); glob += suffixes[s];
+ //coil::vstring tmp = coil::filelist(path.c_str(), glob.c_str());
+ coil::vstring tmp;
+ coil::getFileList(path, suffixes[s], tmp);
RTC_DEBUG(("File list (path:%s, ext:%s): %s", path.c_str(),
suffixes[s].c_str(), coil::flatten(tmp).c_str()));
flist.insert(flist.end(), tmp.begin(), tmp.end());
@@ -489,9 +498,11 @@
// reformat file path and remove cached files
for (size_t j(0); j < flist.size(); ++j)
{
- if (*(path.end() - 1) != '/') { path += "/"; }
- std::string fpath(path + flist[j]);
- addNewFile(fpath, modules);
+ //if (*(path.end() - 1) != '/') { path += "/"; }
+ //std::string fpath(path + flist[j]);
+ //addNewFile(fpath, modules);
+ coil::replaceString(flist[j], "\\", "/");
+ addNewFile(flist[j], modules);
}
}
}
openrtm-commit メーリングリストの案内