| 800 | } |
| 801 | |
| 802 | static bool ha_canonical_path(const char *input, char *output, size_t output_size) { |
| 803 | if (!input || !output || output_size == 0U || !cbm_hook_path_is_abs(input)) { |
| 804 | return false; |
| 805 | } |
| 806 | char resolved[4096]; |
| 807 | #ifdef _WIN32 |
| 808 | const char *source = _fullpath(resolved, input, sizeof(resolved)) ? resolved : input; |
| 809 | #else |
| 810 | const char *source = realpath(input, resolved) ? resolved : input; |
| 811 | #endif |
| 812 | int written = snprintf(output, output_size, "%s", source); |
| 813 | if (written < 0 || (size_t)written >= output_size) { |
| 814 | return false; |
| 815 | } |
| 816 | for (char *cursor = output; *cursor; cursor++) { |
| 817 | if (*cursor == '\\') { |
| 818 | *cursor = '/'; |
| 819 | } |
| 820 | } |
| 821 | size_t length = strlen(output); |
| 822 | while (length > 1U && output[length - 1U] == '/' && !(length == 3U && output[1] == ':')) { |
| 823 | output[--length] = '\0'; |
| 824 | } |
| 825 | return cbm_hook_path_is_abs(output); |
| 826 | } |
| 827 | |
| 828 | static bool ha_path_contains_mode(const char *root, const char *candidate, bool case_insensitive) { |
| 829 | if (!root || !candidate) { |
no test coverage detected