| 802 | #endif |
| 803 | #include <windows.h> |
| 804 | mi_decl_nodiscard mi_decl_restrict char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) mi_attr_noexcept { |
| 805 | // todo: use GetFullPathNameW to allow longer file names |
| 806 | char buf[PATH_MAX]; |
| 807 | DWORD res = GetFullPathNameA(fname, PATH_MAX, (resolved_name == NULL ? buf : resolved_name), NULL); |
| 808 | if (res == 0) { |
| 809 | errno = GetLastError(); return NULL; |
| 810 | } |
| 811 | else if (res > PATH_MAX) { |
| 812 | errno = EINVAL; return NULL; |
| 813 | } |
| 814 | else if (resolved_name != NULL) { |
| 815 | return resolved_name; |
| 816 | } |
| 817 | else { |
| 818 | return mi_heap_strndup(heap, buf, PATH_MAX); |
| 819 | } |
| 820 | } |
| 821 | #else |
| 822 | /* |
| 823 | #include <unistd.h> // pathconf |
no test coverage detected