Stat a path, skipping symlinks. Returns 0 on success, -1 to skip. * On POSIX, lstat + S_ISLNK avoids following symlink cycles. On Windows * we use the UTF-8-safe wide stat (mirroring discover.c's wide_stat); * reparse points (junctions/symlinks) are detected separately by * pkgmap_is_reparse_point below before we descend. Mirrors discover.c's * safe_stat. */
| 1082 | * pkgmap_is_reparse_point below before we descend. Mirrors discover.c's |
| 1083 | * safe_stat. */ |
| 1084 | static int pkgmap_safe_stat(const char *abs_path, struct stat *st) { |
| 1085 | #ifdef _WIN32 |
| 1086 | wchar_t *wpath = cbm_path_to_wide(abs_path); |
| 1087 | if (!wpath) { |
| 1088 | return CBM_NOT_FOUND; |
| 1089 | } |
| 1090 | struct _stat64 wst; |
| 1091 | int ret = _wstat64(wpath, &wst); |
| 1092 | free(wpath); |
| 1093 | if (ret != 0) { |
| 1094 | return CBM_NOT_FOUND; |
| 1095 | } |
| 1096 | st->st_mode = wst.st_mode; |
| 1097 | st->st_size = wst.st_size; |
| 1098 | st->st_mtime = wst.st_mtime; |
| 1099 | return 0; |
| 1100 | #else |
| 1101 | if (lstat(abs_path, st) != 0) { |
| 1102 | return CBM_NOT_FOUND; |
| 1103 | } |
| 1104 | if (S_ISLNK(st->st_mode)) { |
| 1105 | return CBM_NOT_FOUND; |
| 1106 | } |
| 1107 | return 0; |
| 1108 | #endif |
| 1109 | } |
| 1110 | |
| 1111 | /* True if abs_path is a Windows reparse point (directory junction or |
| 1112 | * symlink). Following these is the documented cause of the historic CI |
no test coverage detected