Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
windows: make uv_fs_stat use open + fstat to support long paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinkovsky committed Nov 25, 2011
1 parent 3a50f8f commit cfa4112
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/win/fs.c
Expand Up @@ -491,14 +491,36 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {

void fs__stat(uv_fs_t* req, const wchar_t* path) {
int result;
unsigned short mode;

result = _wstati64(path, &req->stat);
fs__open(req, path, _O_RDONLY, 0);
if (req->result == -1) {
return;
}

result = _fstati64(req->result, &req->stat);
if (result == -1) {
req->ptr = NULL;
} else {

/*
* VC CRT doesn't properly set S_IFDIR in _fstati64,
* so we set it here if path is a directory.
*/
if (GetFileAttributesW(path) & FILE_ATTRIBUTE_DIRECTORY) {
mode = req->stat.st_mode;
mode &= ~_S_IFMT;
mode |= _S_IFDIR;

req->stat.st_mode = mode;
assert((req->stat.st_mode & _S_IFMT) == _S_IFDIR);
}

req->ptr = &req->stat;
}

_close(req->result);

SET_REQ_RESULT(req, result);
}

Expand Down

0 comments on commit cfa4112

Please sign in to comment.