Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 3195809

Browse files
author
Igor Zinkovsky
committed
update libuv to cfa4112950b1f897fda7
1 parent 232e8e1 commit 3195809

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

deps/uv/src/win/fs.c

+23-1
Original file line numberDiff line numberDiff line change
@@ -491,14 +491,36 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
491491

492492
void fs__stat(uv_fs_t* req, const wchar_t* path) {
493493
int result;
494+
unsigned short mode;
494495

495-
result = _wstati64(path, &req->stat);
496+
fs__open(req, path, _O_RDONLY, 0);
497+
if (req->result == -1) {
498+
return;
499+
}
500+
501+
result = _fstati64(req->result, &req->stat);
496502
if (result == -1) {
497503
req->ptr = NULL;
498504
} else {
505+
506+
/*
507+
* VC CRT doesn't properly set S_IFDIR in _fstati64,
508+
* so we set it here if path is a directory.
509+
*/
510+
if (GetFileAttributesW(path) & FILE_ATTRIBUTE_DIRECTORY) {
511+
mode = req->stat.st_mode;
512+
mode &= ~_S_IFMT;
513+
mode |= _S_IFDIR;
514+
515+
req->stat.st_mode = mode;
516+
assert((req->stat.st_mode & _S_IFMT) == _S_IFDIR);
517+
}
518+
499519
req->ptr = &req->stat;
500520
}
501521

522+
_close(req->result);
523+
502524
SET_REQ_RESULT(req, result);
503525
}
504526

0 commit comments

Comments
 (0)