unix, windows: make uv_fs_t.statbuf public
Make the statbuf field public. This means you no longer have to use req->ptr - though that still works and will continue to work for the foreseeable future. Fixes #704.
This commit is contained in:
parent
fadfeaf6ec
commit
da71649991
@ -295,7 +295,6 @@ typedef struct {
|
|||||||
double atime; \
|
double atime; \
|
||||||
double mtime; \
|
double mtime; \
|
||||||
struct uv__work work_req; \
|
struct uv__work work_req; \
|
||||||
struct stat statbuf; \
|
|
||||||
|
|
||||||
#define UV_WORK_PRIVATE_FIELDS \
|
#define UV_WORK_PRIVATE_FIELDS \
|
||||||
struct uv__work work_req;
|
struct uv__work work_req;
|
||||||
|
|||||||
@ -555,7 +555,6 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
|||||||
size_t length; \
|
size_t length; \
|
||||||
int64_t offset; \
|
int64_t offset; \
|
||||||
}; \
|
}; \
|
||||||
struct _stati64 stat; \
|
|
||||||
struct { \
|
struct { \
|
||||||
double atime; \
|
double atime; \
|
||||||
double mtime; \
|
double mtime; \
|
||||||
|
|||||||
@ -1515,6 +1515,7 @@ struct uv_fs_s {
|
|||||||
void* ptr;
|
void* ptr;
|
||||||
const char* path;
|
const char* path;
|
||||||
uv_err_code errorno;
|
uv_err_code errorno;
|
||||||
|
uv_statbuf_t statbuf; /* Stores the result of uv_fs_stat and uv_fs_fstat. */
|
||||||
UV_FS_PRIVATE_FIELDS
|
UV_FS_PRIVATE_FIELDS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -158,7 +158,7 @@ static void poll_cb(uv_fs_t* req) {
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
statbuf = req->ptr;
|
statbuf = &req->statbuf;
|
||||||
|
|
||||||
if (ctx->busy_polling != 0)
|
if (ctx->busy_polling != 0)
|
||||||
if (ctx->busy_polling < 0 || !statbuf_eq(&ctx->statbuf, statbuf))
|
if (ctx->busy_polling < 0 || !statbuf_eq(&ctx->statbuf, statbuf))
|
||||||
|
|||||||
@ -889,7 +889,7 @@ INLINE static void fs__stat_impl(uv_fs_t* req, int do_lstat) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs__stat_handle(handle, &req->stat) != 0) {
|
if (fs__stat_handle(handle, &req->statbuf) != 0) {
|
||||||
DWORD error = GetLastError();
|
DWORD error = GetLastError();
|
||||||
if (do_lstat && error == ERROR_SYMLINK_NOT_SUPPORTED) {
|
if (do_lstat && error == ERROR_SYMLINK_NOT_SUPPORTED) {
|
||||||
/* We opened a reparse point but it was not a symlink. Try again. */
|
/* We opened a reparse point but it was not a symlink. Try again. */
|
||||||
@ -904,7 +904,7 @@ INLINE static void fs__stat_impl(uv_fs_t* req, int do_lstat) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->ptr = &req->stat;
|
req->ptr = &req->statbuf;
|
||||||
req->result = 0;
|
req->result = 0;
|
||||||
CloseHandle(handle);
|
CloseHandle(handle);
|
||||||
}
|
}
|
||||||
@ -935,12 +935,12 @@ static void fs__fstat(uv_fs_t* req) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs__stat_handle(handle, &req->stat) != 0) {
|
if (fs__stat_handle(handle, &req->statbuf) != 0) {
|
||||||
SET_REQ_WIN32_ERROR(req, GetLastError());
|
SET_REQ_WIN32_ERROR(req, GetLastError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->ptr = &req->stat;
|
req->ptr = &req->statbuf;
|
||||||
req->result = 0;
|
req->result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -107,13 +107,13 @@ static char test_buf[] = "test-buffer\n";
|
|||||||
static void check_permission(const char* filename, int mode) {
|
static void check_permission(const char* filename, int mode) {
|
||||||
int r;
|
int r;
|
||||||
uv_fs_t req;
|
uv_fs_t req;
|
||||||
struct stat* s;
|
uv_statbuf_t* s;
|
||||||
|
|
||||||
r = uv_fs_stat(uv_default_loop(), &req, filename, NULL);
|
r = uv_fs_stat(uv_default_loop(), &req, filename, NULL);
|
||||||
ASSERT(r == 0);
|
ASSERT(r == 0);
|
||||||
ASSERT(req.result == 0);
|
ASSERT(req.result == 0);
|
||||||
|
|
||||||
s = req.ptr;
|
s = &req.statbuf;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/*
|
/*
|
||||||
* On Windows, chmod can only modify S_IWUSR (_S_IWRITE) bit,
|
* On Windows, chmod can only modify S_IWUSR (_S_IWRITE) bit,
|
||||||
@ -543,7 +543,7 @@ TEST_IMPL(fs_file_loop) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void check_utime(const char* path, double atime, double mtime) {
|
static void check_utime(const char* path, double atime, double mtime) {
|
||||||
struct stat* s;
|
uv_statbuf_t* s;
|
||||||
uv_fs_t req;
|
uv_fs_t req;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -551,7 +551,7 @@ static void check_utime(const char* path, double atime, double mtime) {
|
|||||||
ASSERT(r == 0);
|
ASSERT(r == 0);
|
||||||
|
|
||||||
ASSERT(req.result == 0);
|
ASSERT(req.result == 0);
|
||||||
s = req.ptr;
|
s = &req.statbuf;
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_AIX)
|
#if defined(_WIN32) || defined(_AIX)
|
||||||
ASSERT(s->st_atime == atime);
|
ASSERT(s->st_atime == atime);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user