| 522 | } |
| 523 | |
| 524 | String 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 | |
| 550 | bool Glob::has_magic(const String &pathname) { |
| 551 | return Glob::magic_check->search(pathname).is_valid(); |
nothing calls this directly
no test coverage detected