/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
util/folder/lstat_win.c
35 строк
1 KB
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
#include <util/system/defaults.h> #ifdef _win_ #include <util/system/winint.h> #include "lstat_win.h" int lstat(const char* fileName, stat_struct* fileStat) { int len = strlen(fileName); int convRes = MultiByteToWideChar(CP_UTF8, 0, fileName, len, 0, 0); if (convRes == 0) { return -1; } WCHAR* buf = malloc(sizeof(WCHAR) * (convRes + 1)); MultiByteToWideChar(CP_UTF8, 0, fileName, len, buf, convRes); buf[convRes] = 0; HANDLE findHandle; WIN32_FIND_DATAW findBuf; int result; result = _wstat64(buf, fileStat); if (result == 0) { SetLastError(0); findHandle = FindFirstFileW(buf, &findBuf); if (findBuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && (findBuf.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT || findBuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) { fileStat->st_mode = fileStat->st_mode & ~_S_IFMT | _S_IFLNK; } FindClose(findHandle); } free(buf); return result; } #endif //_win_