diff --git a/src/node.h b/src/node.h index dd5a36a666..580a9c12ef 100644 --- a/src/node.h +++ b/src/node.h @@ -63,7 +63,19 @@ ssize_t DecodeWrite(char *buf, v8::Handle, enum encoding encoding = BINARY); -v8::Local BuildStatsObject(struct stat * s); +// 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 // __MINGW32__ +# define NODE_STAT _stati64 +# define NODE_FSTAT _fstati64 +# define NODE_STAT_STRUCT struct _stati64 +#endif + +v8::Local BuildStatsObject(NODE_STAT_STRUCT *s); /** diff --git a/src/node_file.cc b/src/node_file.cc index 71f3258e4e..9eb04892d1 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -26,7 +26,7 @@ /* HACK to use pread/pwrite from eio because MINGW32 doesn't have it /* /* TODO fixme */ -#if __MINGW32__ +#ifdef __MINGW32__ # define pread eio__pread # define pwrite eio__pwrite #endif @@ -109,7 +109,7 @@ static int After(eio_req *req) { case EIO_LSTAT: case EIO_FSTAT: { - struct stat *s = reinterpret_cast(req->ptr2); + NODE_STAT_STRUCT *s = reinterpret_cast(req->ptr2); argv[1] = BuildStatsObject(s); } break; @@ -207,7 +207,7 @@ static Persistent atime_symbol; static Persistent mtime_symbol; static Persistent ctime_symbol; -Local BuildStatsObject(struct stat * s) { +Local BuildStatsObject(NODE_STAT_STRUCT *s) { HandleScope scope; if (dev_symbol.IsEmpty()) { @@ -285,8 +285,8 @@ static Handle Stat(const Arguments& args) { if (args[1]->IsFunction()) { ASYNC_CALL(stat, args[1], *path) } else { - struct stat s; - int ret = stat(*path, &s); + NODE_STAT_STRUCT s; + int ret = NODE_STAT(*path, &s); if (ret != 0) return ThrowException(ErrnoException(errno, NULL, "", *path)); return scope.Close(BuildStatsObject(&s)); } @@ -305,7 +305,7 @@ static Handle LStat(const Arguments& args) { if (args[1]->IsFunction()) { ASYNC_CALL(lstat, args[1], *path) } else { - struct stat s; + NODE_STAT_STRUCT s; int ret = lstat(*path, &s); if (ret != 0) return ThrowException(ErrnoException(errno, NULL, "", *path)); return scope.Close(BuildStatsObject(&s)); @@ -325,8 +325,8 @@ static Handle FStat(const Arguments& args) { if (args[1]->IsFunction()) { ASYNC_CALL(fstat, args[1], fd) } else { - struct stat s; - int ret = fstat(fd, &s); + NODE_STAT_STRUCT s; + int ret = NODE_FSTAT(fd, &s); if (ret != 0) return ThrowException(ErrnoException(errno)); return scope.Close(BuildStatsObject(&s)); }