| 68 | } |
| 69 | |
| 70 | extern "C" int mywstat(const wchar_t *filename, struct _stat64 *buf) |
| 71 | { |
| 72 | if (buf == nullptr) |
| 73 | { |
| 74 | errno = EINVAL; |
| 75 | return -1; |
| 76 | } |
| 77 | if (wcspbrk(filename, L"*?") != nullptr) |
| 78 | { |
| 79 | errno = ENOENT; |
| 80 | return -1; |
| 81 | } |
| 82 | WIN32_FIND_DATAW ffd; |
| 83 | HANDLE hFindFile = FindFirstFileW(filename, &ffd); |
| 84 | if (hFindFile == INVALID_HANDLE_VALUE) |
| 85 | { |
| 86 | errno = ENOENT; |
| 87 | return -1; |
| 88 | } |
| 89 | FindClose(hFindFile); |
| 90 | memset(buf, 0, sizeof(*buf)); |
| 91 | set_statbuf(ffd, *buf); |
| 92 | return 0; |
| 93 | } |