From: Tom Lane Date: Mon, 12 Oct 2020 15:13:02 +0000 (-0400) Subject: Minor cleanup for win32stat.c. X-Git-Tag: REL_14_BETA1~1514 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fcd11329db5bca9993207f099a642a7d1cd59ff8;p=thirdparty%2Fpostgresql.git Minor cleanup for win32stat.c. Use GetLastError(), rather than assuming that CreateFile() failure must map to ENOENT. Noted by Michael Paquier. Discussion: https://postgr.es/m/CAC+AXB0g44SbvSpC86o_1HWh8TAU2pZrMRW6tJT-dkijotx5Qg@mail.gmail.com --- diff --git a/src/port/win32stat.c b/src/port/win32stat.c index d4315c44f4d..9051c713e7b 100644 --- a/src/port/win32stat.c +++ b/src/port/win32stat.c @@ -204,8 +204,10 @@ _pgstat64(const char *name, struct stat *buf) NULL); if (hFile == INVALID_HANDLE_VALUE) { + DWORD err = GetLastError(); + CloseHandle(hFile); - errno = ENOENT; + _dosmaperr(err); return -1; }