MCPcopy Create free account
hub / github.com/catboost/catboost / lstat

Function lstat

util/folder/lstat_win.c:7–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5 #include "lstat_win.h"
6
7int lstat(const char* fileName, stat_struct* fileStat) {
8 int len = strlen(fileName);
9 int convRes = MultiByteToWideChar(CP_UTF8, 0, fileName, len, 0, 0);
10 if (convRes == 0) {
11 return -1;
12 }
13 WCHAR* buf = malloc(sizeof(WCHAR) * (convRes + 1));
14 MultiByteToWideChar(CP_UTF8, 0, fileName, len, buf, convRes);
15 buf[convRes] = 0;
16
17 HANDLE findHandle;
18 WIN32_FIND_DATAW findBuf;
19 int result;
20 result = _wstat64(buf, fileStat);
21 if (result == 0) {
22 SetLastError(0);
23 findHandle = FindFirstFileW(buf, &findBuf);
24 if (findBuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT &&
25 (findBuf.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT || findBuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK))
26 {
27 fileStat->st_mode = fileStat->st_mode & ~_S_IFMT | _S_IFLNK;
28 }
29 FindClose(findHandle);
30 }
31 free(buf);
32 return result;
33}
34
35#endif //_win_

Callers 2

fts_statFunction · 0.70
GetTempFunction · 0.50

Calls 2

mallocFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected