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

Method normalize_path

utility/glob.cpp:524–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

522}
523
524String Glob::normalize_path(const String &path) {
525 String sanitized = path;
526 int backslash_pos = sanitized.find_char('\\');
527 if (backslash_pos != -1) {
528 return simplify_path(sanitized);
529 }
530 int slash_pos = sanitized.find_char('/');
531 bool non_windows_path = slash_pos != -1 || (!is_windows) || !path.is_absolute_path();
532
533 while (backslash_pos != -1) {
534 // check if the character after the backslash is a glob character
535 if (non_windows_path) {
536 if (glob_characters.find_char(sanitized[backslash_pos + 1]) != String::npos) {
537 sanitized[backslash_pos] = '/';
538 backslash_pos = sanitized.find_char('\\', backslash_pos + 1);
539 }
540 } else {
541 if (sanitized[backslash_pos + 1] == '*' || sanitized[backslash_pos + 1] == '?') {
542 sanitized[backslash_pos] = '/';
543 backslash_pos = sanitized.find_char('\\', backslash_pos + 1);
544 }
545 }
546 }
547 return simplify_path(sanitized);
548}
549
550bool Glob::has_magic(const String &pathname) {
551 return Glob::magic_check->search(pathname).is_valid();

Callers

nothing calls this directly

Calls 1

simplify_pathFunction · 0.85

Tested by

no test coverage detected