23 #include <sys/types.h>
58 char path_name[strlen(path)+1];
59 strcpy(path_name, path);
89 char path_name[strlen(path)+1];
90 strcpy(path_name, path);
124 bool has_glob(
false);
127 if (path == 0) {
return flist; }
128 if (glob_str[0] !=
'\0') { has_glob =
true; }
130 DIR* dir_ptr(::opendir(path));
131 if (dir_ptr == 0) {
return flist; }
133 while ((ent = ::readdir(dir_ptr)) != 0)
138 const char* globc(glob_str);
139 std::string fname(ent->d_name);
140 for (
size_t i(0); i < fname.size() && globc !=
'\0'; ++i, ++globc)
145 if (globc[1] ==
'\0') {
break; }
147 if (globc[1] ==
'*' || globc[1] ==
'+') { --i;
continue; }
151 size_t pos(fname.find(*globc, i));
152 if (pos == std::string::npos) { match =
false;
break; }
156 else if (*globc ==
'+')
159 if (globc[1] ==
'\0' && !(i + 1 < fname.size())) {
break; }
161 if (globc[1] ==
'*' || globc[1] ==
'+') { --i;
continue; }
165 size_t pos(fname.find(*globc, i + 1));
166 if (pos == std::string::npos) { match =
false;
break; }
172 if (fname[i] != *globc) { match =
false; }
177 if (i + 1 == fname.size() &&
178 globc[1] !=
'\0' && globc[1] !=
'*') { match =
false; }
181 if (match) { flist.push_back(ent->d_name); }
189 #endif // COIL_FILE_H
std::vector< std::string > vstring
Definition: stringutil.h:37
std::string dirname(char *path)
ファイルパスよりディレクトリ部分を取得する
Definition: File.h:56
coil::vstring filelist(const char *path, const char *glob_str="")
ファイルリストを取得する
Definition: File.h:120
std::string basename(const char *path)
ファイルパスよりファイル名部分を取得する
Definition: File.h:87
Common Object Interface Layer.
Definition: Allocator.h:27