mirror of https://github.com/nodejs/node.git
Use unicode and bigfile aware stat/fstat
parent
1361e87e80
commit
f48c36f74f
14
src/node.h
14
src/node.h
|
@ -63,7 +63,19 @@ ssize_t DecodeWrite(char *buf,
|
|||
v8::Handle<v8::Value>,
|
||||
enum encoding encoding = BINARY);
|
||||
|
||||
v8::Local<v8::Object> 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<v8::Object> BuildStatsObject(NODE_STAT_STRUCT *s);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<struct stat*>(req->ptr2);
|
||||
NODE_STAT_STRUCT *s = reinterpret_cast<NODE_STAT_STRUCT*>(req->ptr2);
|
||||
argv[1] = BuildStatsObject(s);
|
||||
}
|
||||
break;
|
||||
|
@ -207,7 +207,7 @@ static Persistent<String> atime_symbol;
|
|||
static Persistent<String> mtime_symbol;
|
||||
static Persistent<String> ctime_symbol;
|
||||
|
||||
Local<Object> BuildStatsObject(struct stat * s) {
|
||||
Local<Object> BuildStatsObject(NODE_STAT_STRUCT *s) {
|
||||
HandleScope scope;
|
||||
|
||||
if (dev_symbol.IsEmpty()) {
|
||||
|
@ -285,8 +285,8 @@ static Handle<Value> 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<Value> 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<Value> 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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue