[openrtm-commit:03279] r3257 - branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/posix/coil
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 3月 26日 (月) 18:58:53 JST
Author: miyamoto
Date: 2018-03-26 18:58:53 +0900 (Mon, 26 Mar 2018)
New Revision: 3257
Modified:
branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/posix/coil/File.h
Log:
[compat, ->trunk] refs #4497
Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/posix/coil/File.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/posix/coil/File.h 2018-03-26 09:16:39 UTC (rev 3256)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/posix/coil/File.h 2018-03-26 09:58:53 UTC (rev 3257)
@@ -24,6 +24,10 @@
#include <dirent.h>
#include <libgen.h>
+#include <string.h>
+#include <sys/stat.h>
+
+
#include <coil/config_coil.h>
#include <coil/stringutil.h>
@@ -189,6 +193,110 @@
return flist;
}
+
+
+ /*!
+ * @if jp
+ *
+ * @brief »ØÄê¥Õ¥¡¥¤¥ë̾¤ò»ØÄê¥Ç¥£¥ì¥¯¥È¥ê¤«¤éõºº¤¹¤ë
+ *
+ * @param dir ¥Ç¥£¥ì¥¯¥È¥ê¥Ñ¥¹
+ * @param filename ¥Ç¥£¥ì¥¯¥È¥ê¥Ñ¥¹
+ * @param filelist ¥Õ¥¡¥¤¥ë°ìÍ÷
+ *
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param dir
+ * @param filename
+ * @param filelist
+ *
+ * @endif
+ */
+ inline void findFile(std::string dir, std::string filename, coil::vstring &filelist)
+ {
+ struct dirent **namelist=NULL;
+ int files = scandir(dir.c_str(), &namelist, NULL, NULL);
+
+ for (int i=0; i<files; i++) {
+ std::string dname = namelist[i]->d_name;
+ if( dname != "." && dname != ".." ){
+
+ std::string fullpath = dir + "/" + dname;
+
+ struct stat stat_buf;
+ if(stat(fullpath.c_str(), &stat_buf) == 0){
+ if ((stat_buf.st_mode & S_IFMT) == S_IFDIR){
+ findFile(fullpath, filename, filelist);
+ }
+ else
+ {
+ if(dname == filename)
+ {
+ filelist.push_back(fullpath);
+ }
+ }
+ }
+
+
+ }
+ }
+ }
+
+
+ /*!
+ * @if jp
+ *
+ * @brief ¥Õ¥¡¥¤¥ë°ìÍ÷¤ò»ØÄê¥Ç¥£¥ì¥¯¥È¥ê¤«¤éõºº¤¹¤ë
+ *
+ * @param dir ¥Ç¥£¥ì¥¯¥È¥ê¥Ñ¥¹
+ * @param ext ³ÈÄ¥»Ò
+ * @param filelist ¥Õ¥¡¥¤¥ë°ìÍ÷
+ *
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param dir
+ * @param ext
+ * @param filelist
+ *
+ * @endif
+ */
+ inline void getFileList(std::string dir, std::string ext, coil::vstring &filelist)
+ {
+ struct dirent **namelist=NULL;
+ int files = scandir(dir.c_str(), &namelist, NULL, NULL);
+
+ for (int i=0; i<files; i++) {
+ std::string dname = namelist[i]->d_name;
+ if( dname != "." && dname != ".." ){
+
+ std::string fullpath = dir + "/" + dname;
+
+ struct stat stat_buf;
+ if(stat(fullpath.c_str(), &stat_buf) == 0){
+ if ((stat_buf.st_mode & S_IFMT) == S_IFDIR){
+ getFileList(fullpath, ext, filelist);
+ }
+ else
+ {
+ coil::vstring filesp = coil::split(dname, ".");
+ if(filesp.back() == ext)
+ {
+ filelist.push_back(fullpath);
+ }
+ }
+ }
+
+
+ }
+ }
+
+ }
};
#endif // COIL_FILE_H
openrtm-commit メーリングリストの案内