| 723 | } |
| 724 | |
| 725 | static bool ha_canonical_path(const char *input, char *output, size_t output_size) { |
| 726 | if (!input || !output || output_size == 0U || !cbm_hook_path_is_abs(input)) { |
| 727 | return false; |
| 728 | } |
| 729 | char resolved[4096]; |
| 730 | #ifdef _WIN32 |
| 731 | const char *source = _fullpath(resolved, input, sizeof(resolved)) ? resolved : input; |
| 732 | #else |
| 733 | const char *source = realpath(input, resolved) ? resolved : input; |
| 734 | #endif |
| 735 | int written = snprintf(output, output_size, "%s", source); |
| 736 | if (written < 0 || (size_t)written >= output_size) { |
| 737 | return false; |
| 738 | } |
| 739 | for (char *cursor = output; *cursor; cursor++) { |
| 740 | if (*cursor == '\\') { |
| 741 | *cursor = '/'; |
| 742 | } |
| 743 | } |
| 744 | size_t length = strlen(output); |
| 745 | while (length > 1U && output[length - 1U] == '/' && !(length == 3U && output[1] == ':')) { |
| 746 | output[--length] = '\0'; |
| 747 | } |
| 748 | return cbm_hook_path_is_abs(output); |
| 749 | } |
| 750 | |
| 751 | static bool ha_path_contains_mode(const char *root, const char *candidate, bool case_insensitive) { |
| 752 | if (!root || !candidate) { |
no test coverage detected