| 258 | } |
| 259 | |
| 260 | void cv::glob(String pattern, std::vector<String>& result, bool recursive) |
| 261 | { |
| 262 | result.clear(); |
| 263 | String path, wildchart; |
| 264 | |
| 265 | if (isDir(pattern, 0)) |
| 266 | { |
| 267 | if(strchr(dir_separators, pattern[pattern.size() - 1]) != 0) |
| 268 | { |
| 269 | path = pattern.substr(0, pattern.size() - 1); |
| 270 | } |
| 271 | else |
| 272 | { |
| 273 | path = pattern; |
| 274 | } |
| 275 | } |
| 276 | else |
| 277 | { |
| 278 | size_t pos = pattern.find_last_of(dir_separators); |
| 279 | if (pos == String::npos) |
| 280 | { |
| 281 | wildchart = pattern; |
| 282 | path = "."; |
| 283 | } |
| 284 | else |
| 285 | { |
| 286 | path = pattern.substr(0, pos); |
| 287 | wildchart = pattern.substr(pos + 1); |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | glob_rec(path, wildchart, result, recursive); |
| 292 | std::sort(result.begin(), result.end()); |
| 293 | } |