#include "c.h"
#include "port/win32ntdll.h"
#include <windows.h>
Go to the source code of this file.
◆ _pgfstat64()
int _pgfstat64 |
( |
int |
fileno, |
|
|
struct stat * |
buf |
|
) |
| |
Definition at line 255 of file win32stat.c.
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;
DWORD pgwin32_get_file_type(HANDLE hFile)
static int fileinfo_to_stat(HANDLE hFile, struct stat *buf)
References buf, fileinfo_to_stat(), and pgwin32_get_file_type().
◆ _pglstat64()
int _pglstat64 |
( |
const char * |
name, |
|
|
struct stat * |
buf |
|
) |
| |
Definition at line 113 of file win32stat.c.
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)
static pg_noinline void Size size
#define readlink(path, buf, size)
PGDLLIMPORT RtlGetLastNtStatus_t pg_RtlGetLastNtStatus
References buf, fileinfo_to_stat(), MAXPGPATH, name, next, pg_RtlGetLastNtStatus, readlink, S_IFLNK, S_ISDIR, and size.
Referenced by _pgstat64().
◆ _pgstat64()
int _pgstat64 |
( |
const char * |
name, |
|
|
struct stat * |
buf |
|
) |
| |
Definition at line 198 of file win32stat.c.
229 if (errno == EACCES &&
239 errno = ENAMETOOLONG;
size_t strlcpy(char *dst, const char *src, size_t siz)
int _pglstat64(const char *name, struct stat *buf)
References _pglstat64(), buf, MAXPGPATH, name, next, pg_RtlGetLastNtStatus, readlink, S_ISLNK, size, and strlcpy().
◆ fileattr_to_unixmode()
static unsigned short fileattr_to_unixmode |
( |
int |
attr | ) |
|
|
static |
Definition at line 48 of file win32stat.c.
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));
Referenced by fileinfo_to_stat().
◆ fileinfo_to_stat()
static int fileinfo_to_stat |
( |
HANDLE |
hFile, |
|
|
struct stat * |
buf |
|
) |
| |
|
static |
Definition at line 68 of file win32stat.c.
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);
void _dosmaperr(unsigned long)
static __time64_t filetime_to_time(const FILETIME *ft)
static unsigned short fileattr_to_unixmode(int attr)
References _dosmaperr(), buf, fileattr_to_unixmode(), and filetime_to_time().
Referenced by _pgfstat64(), and _pglstat64().
◆ filetime_to_time()
static __time64_t filetime_to_time |
( |
const FILETIME * |
ft | ) |
|
|
static |
Definition at line 25 of file win32stat.c.
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;
Referenced by fileinfo_to_stat().