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

Commit

Permalink
node: replace NODE_STAT_STRUCT with uv_statbuf_t
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Jun 21, 2012
1 parent ae7a3cd commit 09150b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
14 changes: 1 addition & 13 deletions src/node.h
Expand Up @@ -144,19 +144,7 @@ ssize_t DecodeWrite(char *buf,
v8::Handle<v8::Value>,
enum encoding encoding = BINARY);

// Use different stat structs & calls on windows and posix;
// on windows, _stati64 is utf-8 and big file aware.
#if __POSIX__
# define NODE_STAT stat
# define NODE_FSTAT fstat
# define NODE_STAT_STRUCT struct stat
#else // _WIN32
# define NODE_STAT _stati64
# define NODE_FSTAT _fstati64
# define NODE_STAT_STRUCT struct _stati64
#endif

v8::Local<v8::Object> BuildStatsObject(NODE_STAT_STRUCT *s);
v8::Local<v8::Object> BuildStatsObject(const uv_statbuf_t* s);


/**
Expand Down
16 changes: 8 additions & 8 deletions src/node_file.cc
Expand Up @@ -158,10 +158,7 @@ static void After(uv_fs_t *req) {
case UV_FS_STAT:
case UV_FS_LSTAT:
case UV_FS_FSTAT:
{
NODE_STAT_STRUCT *s = reinterpret_cast<NODE_STAT_STRUCT*>(req->ptr);
argv[1] = BuildStatsObject(s);
}
argv[1] = BuildStatsObject(static_cast<const uv_statbuf_t*>(req->ptr));
break;

case UV_FS_READLINK:
Expand Down Expand Up @@ -284,7 +281,7 @@ static Persistent<String> atime_symbol;
static Persistent<String> mtime_symbol;
static Persistent<String> ctime_symbol;

Local<Object> BuildStatsObject(NODE_STAT_STRUCT *s) {
Local<Object> BuildStatsObject(const uv_statbuf_t* s) {
HandleScope scope;

if (dev_symbol.IsEmpty()) {
Expand Down Expand Up @@ -362,7 +359,8 @@ static Handle<Value> Stat(const Arguments& args) {
ASYNC_CALL(stat, args[1], *path)
} else {
SYNC_CALL(stat, *path, *path)
return scope.Close(BuildStatsObject((NODE_STAT_STRUCT*)SYNC_REQ.ptr));
return scope.Close(
BuildStatsObject(static_cast<const uv_statbuf_t*>(SYNC_REQ.ptr)));
}
}

Expand All @@ -378,7 +376,8 @@ static Handle<Value> LStat(const Arguments& args) {
ASYNC_CALL(lstat, args[1], *path)
} else {
SYNC_CALL(lstat, *path, *path)
return scope.Close(BuildStatsObject((NODE_STAT_STRUCT*)SYNC_REQ.ptr));
return scope.Close(
BuildStatsObject(static_cast<const uv_statbuf_t*>(SYNC_REQ.ptr)));
}
}

Expand All @@ -395,7 +394,8 @@ static Handle<Value> FStat(const Arguments& args) {
ASYNC_CALL(fstat, args[1], fd)
} else {
SYNC_CALL(fstat, 0, fd)
return scope.Close(BuildStatsObject((NODE_STAT_STRUCT*)SYNC_REQ.ptr));
return scope.Close(
BuildStatsObject(static_cast<const uv_statbuf_t*>(SYNC_REQ.ptr)));
}
}

Expand Down

0 comments on commit 09150b0

Please sign in to comment.