27 ULARGE_INTEGER unified_ft = {0};
28 static const uint64 EpochShift = UINT64CONST(116444736000000000);
30 unified_ft.LowPart = ft->dwLowDateTime;
31 unified_ft.HighPart = ft->dwHighDateTime;
33 if (unified_ft.QuadPart < EpochShift)
36 unified_ft.QuadPart -= EpochShift;
37 unified_ft.QuadPart /= 10 * 1000 * 1000;
39 return unified_ft.QuadPart;
50 unsigned short uxmode = 0;
52 uxmode |= (
unsigned short) ((attr & FILE_ATTRIBUTE_DIRECTORY) ?
53 (_S_IFDIR) : (_S_IFREG));
55 uxmode |= (
unsigned short) ((attr & FILE_ATTRIBUTE_READONLY) ?
56 (_S_IREAD) : (_S_IREAD | _S_IWRITE));
70 BY_HANDLE_FILE_INFORMATION fiData;
72 memset(
buf, 0,
sizeof(*
buf));
78 if (!GetFileInformationByHandle(hFile, &fiData))
84 if (fiData.ftLastWriteTime.dwLowDateTime ||
85 fiData.ftLastWriteTime.dwHighDateTime)
88 if (fiData.ftLastAccessTime.dwLowDateTime ||
89 fiData.ftLastAccessTime.dwHighDateTime)
92 buf->st_atime =
buf->st_mtime;
94 if (fiData.ftCreationTime.dwLowDateTime ||
95 fiData.ftCreationTime.dwHighDateTime)
98 buf->st_ctime =
buf->st_mtime;
101 buf->st_nlink = fiData.nNumberOfLinks;
103 buf->st_size = ((((uint64) fiData.nFileSizeHigh) << 32) |
104 fiData.nFileSizeLow);
124 hFile = pgwin32_open_handle(
name, O_RDONLY,
true);
125 if (hFile == INVALID_HANDLE_VALUE)
136 memset(
buf, 0,
sizeof(*
buf));
149 if ((ret == 0 &&
S_ISDIR(
buf->st_mode)) || hFile == INVALID_HANDLE_VALUE)
162 if (errno == EACCES &&
169 else if (errno == EINVAL)
182 buf->st_mode &= ~S_IFDIR;
189 if (hFile != INVALID_HANDLE_VALUE)
229 if (errno == EACCES &&
239 errno = ENAMETOOLONG;
257 HANDLE hFile = (HANDLE) _get_osfhandle(fileno);
258 DWORD fileType = FILE_TYPE_UNKNOWN;
259 unsigned short st_mode;
289 case FILE_TYPE_REMOTE:
290 case FILE_TYPE_UNKNOWN:
296 memset(
buf, 0,
sizeof(*
buf));
297 buf->st_mode = st_mode;
298 buf->st_dev = fileno;
299 buf->st_rdev = fileno;
size_t strlcpy(char *dst, const char *src, size_t siz)
static pg_noinline void Size size
void _dosmaperr(unsigned long)
DWORD pgwin32_get_file_type(HANDLE hFile)
#define readlink(path, buf, size)
PGDLLIMPORT RtlGetLastNtStatus_t pg_RtlGetLastNtStatus
static __time64_t filetime_to_time(const FILETIME *ft)
static unsigned short fileattr_to_unixmode(int attr)
int _pgfstat64(int fileno, struct stat *buf)
int _pgstat64(const char *name, struct stat *buf)
static int fileinfo_to_stat(HANDLE hFile, struct stat *buf)
int _pglstat64(const char *name, struct stat *buf)