windows: include _stat struct into uv_fs_t

This commit is contained in:
Igor Zinkovsky 2011-09-01 11:54:43 -07:00
parent 836cc204b6
commit 22197ebf3f
3 changed files with 10 additions and 20 deletions

View File

@ -28,6 +28,7 @@
#include <mswsock.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <sys/stat.h>
#include "tree.h"
@ -246,6 +247,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
#define UV_FS_PRIVATE_FIELDS \
int flags; \
struct _stat stat; \
void* arg0; \
union { \
struct { \

View File

@ -234,17 +234,11 @@ done:
void fs__stat(uv_fs_t* req, const char* path) {
int result;
req->ptr = malloc(sizeof(struct _stat));
if (!req->ptr) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
}
result = _stat(path, (struct _stat*)req->ptr);
result = _stat(path, &req->stat);
if (result == -1) {
free(req->ptr);
req->ptr = NULL;
} else {
req->flags |= UV_FS_FREE_PTR;
req->ptr = &req->stat;
}
SET_REQ_RESULT(req, result);
@ -254,17 +248,11 @@ void fs__stat(uv_fs_t* req, const char* path) {
void fs__fstat(uv_fs_t* req, uv_file file) {
int result;
req->ptr = malloc(sizeof(struct _stat));
if (!req->ptr) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
}
result = _fstat(file, (struct _stat*)req->ptr);
result = _fstat(file, &req->stat);
if (result == -1) {
free(req->ptr);
req->ptr = NULL;
} else {
req->flags |= UV_FS_FREE_PTR;
req->ptr = &req->stat;
}
SET_REQ_RESULT(req, result);
@ -807,9 +795,10 @@ void uv_fs_req_cleanup(uv_fs_t* req) {
if (req->flags & UV_FS_FREE_PTR && req->ptr) {
free(req->ptr);
req->ptr = NULL;
}
req->ptr = NULL;
if (req->flags & UV_FS_ASYNC_QUEUED) {
uv_unref(loop);
}

View File

@ -486,10 +486,10 @@ TEST_IMPL(fs_async_dir) {
TEST_IMPL(fs_async_sendfile) {
int f, r;
/* Setup. */
struct stat s1, s2;
/* Setup. */
uv_init();
unlink("test_file");
unlink("test_file2");
@ -509,7 +509,6 @@ TEST_IMPL(fs_async_sendfile) {
ASSERT(r == 0);
/* Test starts here. */
uv_init();
loop = uv_default_loop();
r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL);