fs: fix existsSync for invalid symlink at win32
Fixes: https://github.com/nodejs/node/issues/30538
Background
https://github.com/nodejs/node/pull/18618 uses access
instead of stat
to implement fs.existsSync
. Unfortunately, seems the two approaches both have some limitations at Windows:
Expected behavior of existsSync
|
stat |
access |
|
---|---|---|---|
Invalid symlink | false |
||
File without privileges | true |
This PR adds a double check only at win32 platform to fix this issue.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines