MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / _glob

Method _glob

utility/glob.cpp:554–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552}
553
554Vector<String> Glob::_glob(const String &inpath, bool recursive,
555 bool dironly, bool include_hidden) {
556 Vector<String> result;
557
558 String path = inpath;
559
560 if (path[0] == '~') {
561 // expand tilde
562 path = expand_tilde(path);
563 }
564
565 const String dirname = get_base_dir(get_real_dir(path));
566 const String basename = get_file_name(get_real_dir(path));
567
568 if (!has_magic(path)) {
569 //assert(!dironly);
570 if (!basename.is_empty()) {
571 if (dir_or_file_exists(path, include_hidden)) {
572 result.push_back(path);
573 }
574 } else {
575 // Patterns ending with a slash should match only directories
576 if (dir_exists(dirname, include_hidden)) {
577 result.push_back(path);
578 }
579 }
580 return result;
581 }
582
583 if (dirname.is_empty()) {
584 if (recursive && is_recursive(basename)) {
585 return glob2(dirname, basename, dironly, include_hidden);
586 } else {
587 return glob1(dirname, basename, dironly, include_hidden);
588 }
589 }
590
591 Vector<String> dirs;
592 if (dirname != path && has_magic(dirname)) {
593 dirs = _glob(dirname, recursive, true, include_hidden);
594 } else {
595 dirs = { dirname };
596 }
597
598 std::function<Vector<String>(const String &, const String &, bool, bool)>
599 glob_in_dir;
600 if (has_magic(basename)) {
601 if (recursive && is_recursive(basename)) {
602 glob_in_dir = glob2;
603 } else {
604 glob_in_dir = glob1;
605 }
606 } else {
607 glob_in_dir = glob0;
608 }
609
610 for (auto &d : dirs) {
611 for (auto &name : glob_in_dir(d, basename, dironly, include_hidden)) {

Callers

nothing calls this directly

Calls 10

expand_tildeFunction · 0.85
get_base_dirFunction · 0.85
get_real_dirFunction · 0.85
get_file_nameFunction · 0.85
dir_or_file_existsFunction · 0.85
dir_existsFunction · 0.85
is_recursiveFunction · 0.85
glob2Function · 0.85
glob1Function · 0.85
push_backMethod · 0.80

Tested by

no test coverage detected