@ -70,11 +70,15 @@ class FSReqWrap: public ReqWrap<uv_fs_t> {
void * operator new ( size_t size ) { return new char [ size ] ; }
void * operator new ( size_t size ) { return new char [ size ] ; }
void * operator new ( size_t size , char * storage ) { return storage ; }
void * operator new ( size_t size , char * storage ) { return storage ; }
FSReqWrap ( Environment * env , const char * syscall , char * data = nullptr )
FSReqWrap ( Environment * env ,
: ReqWrap < uv_fs_t > ( env , Object : : New ( env - > isolate ( ) ) ) ,
Local < Object > req ,
const char * syscall ,
char * data = nullptr )
: ReqWrap ( env , req , AsyncWrap : : PROVIDER_FSREQWRAP ) ,
syscall_ ( syscall ) ,
syscall_ ( syscall ) ,
data_ ( data ) ,
data_ ( data ) ,
dest_len_ ( 0 ) {
dest_len_ ( 0 ) {
Wrap < FSReqWrap > ( object ( ) , this ) ;
}
}
void ReleaseEarly ( ) {
void ReleaseEarly ( ) {
@ -97,6 +101,11 @@ class FSReqWrap: public ReqWrap<uv_fs_t> {
} ;
} ;
static void NewFSReqWrap ( const FunctionCallbackInfo < Value > & args ) {
CHECK ( args . IsConstructCall ( ) ) ;
}
# define ASSERT_OFFSET(a) \
# define ASSERT_OFFSET(a) \
if ( ! ( a ) - > IsUndefined ( ) & & ! ( a ) - > IsNull ( ) & & ! IsInt64 ( ( a ) - > NumberValue ( ) ) ) { \
if ( ! ( a ) - > IsUndefined ( ) & & ! ( a ) - > IsNull ( ) & & ! IsInt64 ( ( a ) - > NumberValue ( ) ) ) { \
return env - > ThrowTypeError ( " Not an integer " ) ; \
return env - > ThrowTypeError ( " Not an integer " ) ; \
@ -253,35 +262,35 @@ struct fs_req_wrap {
} ;
} ;
# define ASYNC_DEST_CALL(func, callback, dest_path, ...) \
# define ASYNC_DEST_CALL(func, req, dest_path, ...) \
Environment * env = Environment : : GetCurrent ( args ) ; \
Environment * env = Environment : : GetCurrent ( args ) ; \
FSReqWrap * req_wrap ; \
FSReqWrap * req_wrap ; \
char * dest_str = ( dest_path ) ; \
char * dest_str = ( dest_path ) ; \
int dest_len = dest_str = = nullptr ? 0 : strlen ( dest_str ) ; \
int dest_len = dest_str = = nullptr ? 0 : strlen ( dest_str ) ; \
char * storage = new char [ sizeof ( * req_wrap ) + dest_len ] ; \
char * storage = new char [ sizeof ( * req_wrap ) + dest_len ] ; \
req_wrap = new ( storage ) FSReqWrap ( env , # func ) ; \
CHECK ( req - > IsObject ( ) ) ; \
req_wrap = new ( storage ) FSReqWrap ( env , req . As < Object > ( ) , # func ) ; \
req_wrap - > dest_len ( dest_len ) ; \
req_wrap - > dest_len ( dest_len ) ; \
if ( dest_str ! = nullptr ) { \
if ( dest_str ! = nullptr ) { \
memcpy ( const_cast < char * > ( req_wrap - > dest ( ) ) , \
memcpy ( const_cast < char * > ( req_wrap - > dest ( ) ) , \
dest_str , \
dest_str , \
dest_len + 1 ) ; \
dest_len + 1 ) ; \
} \
} \
int err = uv_fs_ # # func ( env - > event_loop ( ) , \
int err = uv_fs_ # # func ( env - > event_loop ( ) , \
& req_wrap - > req_ , \
& req_wrap - > req_ , \
__VA_ARGS__ , \
__VA_ARGS__ , \
After ) ; \
After ) ; \
req_wrap - > object ( ) - > Set ( env - > oncomplete_string ( ) , callback ) ; \
req_wrap - > Dispatched ( ) ; \
req_wrap - > Dispatched ( ) ; \
if ( err < 0 ) { \
if ( err < 0 ) { \
uv_fs_t * req = & req_wrap - > req_ ; \
uv_fs_t * uv_ req = & req_wrap - > req_ ; \
req - > result = err ; \
uv_ req- > result = err ; \
req - > path = nullptr ; \
uv_ req- > path = nullptr ; \
After ( req ) ; \
After ( uv_ req) ; \
} \
} \
args . GetReturnValue ( ) . Set ( req_wrap - > persistent ( ) ) ;
args . GetReturnValue ( ) . Set ( req_wrap - > persistent ( ) ) ;
# define ASYNC_CALL(func, callback, ...) \
# define ASYNC_CALL(func, req, ...) \
ASYNC_DEST_CALL ( func , callback , nullptr , __VA_ARGS__ ) \
ASYNC_DEST_CALL ( func , req , nullptr , __VA_ARGS__ ) \
# define SYNC_DEST_CALL(func, path, dest, ...) \
# define SYNC_DEST_CALL(func, path, dest, ...) \
fs_req_wrap req_wrap ; \
fs_req_wrap req_wrap ; \
@ -317,7 +326,7 @@ static void Close(const FunctionCallbackInfo<Value>& args) {
int fd = args [ 0 ] - > Int32Value ( ) ;
int fd = args [ 0 ] - > Int32Value ( ) ;
if ( args [ 1 ] - > IsFunction ( ) ) {
if ( args [ 1 ] - > IsObject ( ) ) {
ASYNC_CALL ( close , args [ 1 ] , fd )
ASYNC_CALL ( close , args [ 1 ] , fd )
} else {
} else {
SYNC_CALL ( close , 0 , fd )
SYNC_CALL ( close , 0 , fd )
@ -432,7 +441,7 @@ static void Stat(const FunctionCallbackInfo<Value>& args) {
node : : Utf8Value path ( args [ 0 ] ) ;
node : : Utf8Value path ( args [ 0 ] ) ;
if ( args [ 1 ] - > IsFunction ( ) ) {
if ( args [ 1 ] - > IsObject ( ) ) {
ASYNC_CALL ( stat , args [ 1 ] , * path )
ASYNC_CALL ( stat , args [ 1 ] , * path )
} else {
} else {
SYNC_CALL ( stat , * path , * path )
SYNC_CALL ( stat , * path , * path )
@ -451,7 +460,7 @@ static void LStat(const FunctionCallbackInfo<Value>& args) {
node : : Utf8Value path ( args [ 0 ] ) ;
node : : Utf8Value path ( args [ 0 ] ) ;
if ( args [ 1 ] - > IsFunction ( ) ) {
if ( args [ 1 ] - > IsObject ( ) ) {
ASYNC_CALL ( lstat , args [ 1 ] , * path )
ASYNC_CALL ( lstat , args [ 1 ] , * path )
} else {
} else {
SYNC_CALL ( lstat , * path , * path )
SYNC_CALL ( lstat , * path , * path )
@ -469,7 +478,7 @@ static void FStat(const FunctionCallbackInfo<Value>& args) {
int fd = args [ 0 ] - > Int32Value ( ) ;
int fd = args [ 0 ] - > Int32Value ( ) ;
if ( args [ 1 ] - > IsFunction ( ) ) {
if ( args [ 1 ] - > IsObject ( ) ) {
ASYNC_CALL ( fstat , args [ 1 ] , fd )
ASYNC_CALL ( fstat , args [ 1 ] , fd )
} else {
} else {
SYNC_CALL ( fstat , 0 , fd )
SYNC_CALL ( fstat , 0 , fd )
@ -506,7 +515,7 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) {
}
}
}
}
if ( args [ 3 ] - > IsFunction ( ) ) {
if ( args [ 3 ] - > IsObject ( ) ) {
ASYNC_DEST_CALL ( symlink , args [ 3 ] , * path , * dest , * path , flags )
ASYNC_DEST_CALL ( symlink , args [ 3 ] , * path , * dest , * path , flags )
} else {
} else {
SYNC_DEST_CALL ( symlink , * dest , * path , * dest , * path , flags )
SYNC_DEST_CALL ( symlink , * dest , * path , * dest , * path , flags )
@ -529,7 +538,7 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
node : : Utf8Value orig_path ( args [ 0 ] ) ;
node : : Utf8Value orig_path ( args [ 0 ] ) ;
node : : Utf8Value new_path ( args [ 1 ] ) ;
node : : Utf8Value new_path ( args [ 1 ] ) ;
if ( args [ 2 ] - > IsFunction ( ) ) {
if ( args [ 2 ] - > IsObject ( ) ) {
ASYNC_DEST_CALL ( link , args [ 2 ] , * new_path , * orig_path , * new_path )
ASYNC_DEST_CALL ( link , args [ 2 ] , * new_path , * orig_path , * new_path )
} else {
} else {
SYNC_DEST_CALL ( link , * orig_path , * new_path , * orig_path , * new_path )
SYNC_DEST_CALL ( link , * orig_path , * new_path , * orig_path , * new_path )
@ -546,7 +555,7 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
node : : Utf8Value path ( args [ 0 ] ) ;
node : : Utf8Value path ( args [ 0 ] ) ;
if ( args [ 1 ] - > IsFunction ( ) ) {
if ( args [ 1 ] - > IsObject ( ) ) {
ASYNC_CALL ( readlink , args [ 1 ] , * path )
ASYNC_CALL ( readlink , args [ 1 ] , * path )
} else {
} else {
SYNC_CALL ( readlink , * path , * path )
SYNC_CALL ( readlink , * path , * path )
@ -572,7 +581,7 @@ static void Rename(const FunctionCallbackInfo<Value>& args) {
node : : Utf8Value old_path ( args [ 0 ] ) ;
node : : Utf8Value old_path ( args [ 0 ] ) ;
node : : Utf8Value new_path ( args [ 1 ] ) ;
node : : Utf8Value new_path ( args [ 1 ] ) ;
if ( args [ 2 ] - > IsFunction ( ) ) {
if ( args [ 2 ] - > IsObject ( ) ) {
ASYNC_DEST_CALL ( rename , args [ 2 ] , * new_path , * old_path , * new_path )
ASYNC_DEST_CALL ( rename , args [ 2 ] , * new_path , * old_path , * new_path )
} else {
} else {
SYNC_DEST_CALL ( rename , * old_path , * new_path , * old_path , * new_path )
SYNC_DEST_CALL ( rename , * old_path , * new_path , * old_path , * new_path )
@ -591,7 +600,7 @@ static void FTruncate(const FunctionCallbackInfo<Value>& args) {
ASSERT_TRUNCATE_LENGTH ( args [ 1 ] ) ;
ASSERT_TRUNCATE_LENGTH ( args [ 1 ] ) ;
int64_t len = GET_TRUNCATE_LENGTH ( args [ 1 ] ) ;
int64_t len = GET_TRUNCATE_LENGTH ( args [ 1 ] ) ;
if ( args [ 2 ] - > IsFunction ( ) ) {
if ( args [ 2 ] - > IsObject ( ) ) {
ASYNC_CALL ( ftruncate , args [ 2 ] , fd , len )
ASYNC_CALL ( ftruncate , args [ 2 ] , fd , len )
} else {
} else {
SYNC_CALL ( ftruncate , 0 , fd , len )
SYNC_CALL ( ftruncate , 0 , fd , len )
@ -607,7 +616,7 @@ static void Fdatasync(const FunctionCallbackInfo<Value>& args) {
int fd = args [ 0 ] - > Int32Value ( ) ;
int fd = args [ 0 ] - > Int32Value ( ) ;
if ( args [ 1 ] - > IsFunction ( ) ) {
if ( args [ 1 ] - > IsObject ( ) ) {
ASYNC_CALL ( fdatasync , args [ 1 ] , fd )
ASYNC_CALL ( fdatasync , args [ 1 ] , fd )
} else {
} else {
SYNC_CALL ( fdatasync , 0 , fd )
SYNC_CALL ( fdatasync , 0 , fd )
@ -623,7 +632,7 @@ static void Fsync(const FunctionCallbackInfo<Value>& args) {
int fd = args [ 0 ] - > Int32Value ( ) ;
int fd = args [ 0 ] - > Int32Value ( ) ;
if ( args [ 1 ] - > IsFunction ( ) ) {
if ( args [ 1 ] - > IsObject ( ) ) {
ASYNC_CALL ( fsync , args [ 1 ] , fd )
ASYNC_CALL ( fsync , args [ 1 ] , fd )
} else {
} else {
SYNC_CALL ( fsync , 0 , fd )
SYNC_CALL ( fsync , 0 , fd )
@ -640,7 +649,7 @@ static void Unlink(const FunctionCallbackInfo<Value>& args) {
node : : Utf8Value path ( args [ 0 ] ) ;
node : : Utf8Value path ( args [ 0 ] ) ;
if ( args [ 1 ] - > IsFunction ( ) ) {
if ( args [ 1 ] - > IsObject ( ) ) {
ASYNC_CALL ( unlink , args [ 1 ] , * path )
ASYNC_CALL ( unlink , args [ 1 ] , * path )
} else {
} else {
SYNC_CALL ( unlink , * path , * path )
SYNC_CALL ( unlink , * path , * path )
@ -657,7 +666,7 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
node : : Utf8Value path ( args [ 0 ] ) ;
node : : Utf8Value path ( args [ 0 ] ) ;
if ( args [ 1 ] - > IsFunction ( ) ) {
if ( args [ 1 ] - > IsObject ( ) ) {
ASYNC_CALL ( rmdir , args [ 1 ] , * path )
ASYNC_CALL ( rmdir , args [ 1 ] , * path )
} else {
} else {
SYNC_CALL ( rmdir , * path , * path )
SYNC_CALL ( rmdir , * path , * path )
@ -674,7 +683,7 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
node : : Utf8Value path ( args [ 0 ] ) ;
node : : Utf8Value path ( args [ 0 ] ) ;
int mode = static_cast < int > ( args [ 1 ] - > Int32Value ( ) ) ;
int mode = static_cast < int > ( args [ 1 ] - > Int32Value ( ) ) ;
if ( args [ 2 ] - > IsFunction ( ) ) {
if ( args [ 2 ] - > IsObject ( ) ) {
ASYNC_CALL ( mkdir , args [ 2 ] , * path , mode )
ASYNC_CALL ( mkdir , args [ 2 ] , * path , mode )
} else {
} else {
SYNC_CALL ( mkdir , * path , * path , mode )
SYNC_CALL ( mkdir , * path , * path , mode )
@ -691,7 +700,7 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
node : : Utf8Value path ( args [ 0 ] ) ;
node : : Utf8Value path ( args [ 0 ] ) ;
if ( args [ 1 ] - > IsFunction ( ) ) {
if ( args [ 1 ] - > IsObject ( ) ) {
ASYNC_CALL ( scandir , args [ 1 ] , * path , 0 /*flags*/ )
ASYNC_CALL ( scandir , args [ 1 ] , * path , 0 /*flags*/ )
} else {
} else {
SYNC_CALL ( scandir , * path , * path , 0 /*flags*/ )
SYNC_CALL ( scandir , * path , * path , 0 /*flags*/ )
@ -739,7 +748,7 @@ static void Open(const FunctionCallbackInfo<Value>& args) {
int flags = args [ 1 ] - > Int32Value ( ) ;
int flags = args [ 1 ] - > Int32Value ( ) ;
int mode = static_cast < int > ( args [ 2 ] - > Int32Value ( ) ) ;
int mode = static_cast < int > ( args [ 2 ] - > Int32Value ( ) ) ;
if ( args [ 3 ] - > IsFunction ( ) ) {
if ( args [ 3 ] - > IsObject ( ) ) {
ASYNC_CALL ( open , args [ 3 ] , * path , flags , mode )
ASYNC_CALL ( open , args [ 3 ] , * path , flags , mode )
} else {
} else {
SYNC_CALL ( open , * path , * path , flags , mode )
SYNC_CALL ( open , * path , * path , flags , mode )
@ -770,7 +779,7 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
size_t off = args [ 2 ] - > Uint32Value ( ) ;
size_t off = args [ 2 ] - > Uint32Value ( ) ;
size_t len = args [ 3 ] - > Uint32Value ( ) ;
size_t len = args [ 3 ] - > Uint32Value ( ) ;
int64_t pos = GET_OFFSET ( args [ 4 ] ) ;
int64_t pos = GET_OFFSET ( args [ 4 ] ) ;
Local < Value > cb = args [ 5 ] ;
Local < Value > req = args [ 5 ] ;
if ( off > buffer_length )
if ( off > buffer_length )
return env - > ThrowRangeError ( " offset out of bounds " ) ;
return env - > ThrowRangeError ( " offset out of bounds " ) ;
@ -785,8 +794,8 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
uv_buf_t uvbuf = uv_buf_init ( const_cast < char * > ( buf ) , len ) ;
uv_buf_t uvbuf = uv_buf_init ( const_cast < char * > ( buf ) , len ) ;
if ( cb - > IsFunction ( ) ) {
if ( req - > IsObject ( ) ) {
ASYNC_CALL ( write , cb , fd , & uvbuf , 1 , pos )
ASYNC_CALL ( write , req , fd , & uvbuf , 1 , pos )
return ;
return ;
}
}
@ -809,7 +818,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
if ( ! args [ 0 ] - > IsInt32 ( ) )
if ( ! args [ 0 ] - > IsInt32 ( ) )
return env - > ThrowTypeError ( " First argument must be file descriptor " ) ;
return env - > ThrowTypeError ( " First argument must be file descriptor " ) ;
Local < Value > cb ;
Local < Value > req ;
Local < Value > string = args [ 1 ] ;
Local < Value > string = args [ 1 ] ;
int fd = args [ 0 ] - > Int32Value ( ) ;
int fd = args [ 0 ] - > Int32Value ( ) ;
char * buf = nullptr ;
char * buf = nullptr ;
@ -831,18 +840,19 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
must_free = true ;
must_free = true ;
}
}
pos = GET_OFFSET ( args [ 2 ] ) ;
pos = GET_OFFSET ( args [ 2 ] ) ;
cb = args [ 4 ] ;
req = args [ 4 ] ;
uv_buf_t uvbuf = uv_buf_init ( const_cast < char * > ( buf ) , len ) ;
uv_buf_t uvbuf = uv_buf_init ( const_cast < char * > ( buf ) , len ) ;
if ( ! cb - > IsFunction ( ) ) {
if ( ! req - > IsObject ( ) ) {
SYNC_CALL ( write , nullptr , fd , & uvbuf , 1 , pos )
SYNC_CALL ( write , nullptr , fd , & uvbuf , 1 , pos )
if ( must_free )
if ( must_free )
delete [ ] buf ;
delete [ ] buf ;
return args . GetReturnValue ( ) . Set ( SYNC_RESULT ) ;
return args . GetReturnValue ( ) . Set ( SYNC_RESULT ) ;
}
}
FSReqWrap * req_wrap = new FSReqWrap ( env , " write " , must_free ? buf : nullptr ) ;
FSReqWrap * req_wrap =
new FSReqWrap ( env , req . As < Object > ( ) , " write " , must_free ? buf : nullptr ) ;
int err = uv_fs_write ( env - > event_loop ( ) ,
int err = uv_fs_write ( env - > event_loop ( ) ,
& req_wrap - > req_ ,
& req_wrap - > req_ ,
fd ,
fd ,
@ -850,13 +860,12 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
1 ,
1 ,
pos ,
pos ,
After ) ;
After ) ;
req_wrap - > object ( ) - > Set ( env - > oncomplete_string ( ) , cb ) ;
req_wrap - > Dispatched ( ) ;
req_wrap - > Dispatched ( ) ;
if ( err < 0 ) {
if ( err < 0 ) {
uv_fs_t * req = & req_wrap - > req_ ;
uv_fs_t * uv_ req = & req_wrap - > req_ ;
req - > result = err ;
uv_ req- > result = err ;
req - > path = nullptr ;
uv_ req- > path = nullptr ;
After ( req ) ;
After ( uv_ req) ;
}
}
return args . GetReturnValue ( ) . Set ( req_wrap - > persistent ( ) ) ;
return args . GetReturnValue ( ) . Set ( req_wrap - > persistent ( ) ) ;
@ -884,7 +893,7 @@ static void Read(const FunctionCallbackInfo<Value>& args) {
int fd = args [ 0 ] - > Int32Value ( ) ;
int fd = args [ 0 ] - > Int32Value ( ) ;
Local < Value > cb ;
Local < Value > req ;
size_t len ;
size_t len ;
int64_t pos ;
int64_t pos ;
@ -914,10 +923,10 @@ static void Read(const FunctionCallbackInfo<Value>& args) {
uv_buf_t uvbuf = uv_buf_init ( const_cast < char * > ( buf ) , len ) ;
uv_buf_t uvbuf = uv_buf_init ( const_cast < char * > ( buf ) , len ) ;
cb = args [ 5 ] ;
req = args [ 5 ] ;
if ( cb - > IsFunction ( ) ) {
if ( req - > IsObject ( ) ) {
ASYNC_CALL ( read , cb , fd , & uvbuf , 1 , pos ) ;
ASYNC_CALL ( read , req , fd , & uvbuf , 1 , pos ) ;
} else {
} else {
SYNC_CALL ( read , 0 , fd , & uvbuf , 1 , pos )
SYNC_CALL ( read , 0 , fd , & uvbuf , 1 , pos )
args . GetReturnValue ( ) . Set ( SYNC_RESULT ) ;
args . GetReturnValue ( ) . Set ( SYNC_RESULT ) ;
@ -937,7 +946,7 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) {
node : : Utf8Value path ( args [ 0 ] ) ;
node : : Utf8Value path ( args [ 0 ] ) ;
int mode = static_cast < int > ( args [ 1 ] - > Int32Value ( ) ) ;
int mode = static_cast < int > ( args [ 1 ] - > Int32Value ( ) ) ;
if ( args [ 2 ] - > IsFunction ( ) ) {
if ( args [ 2 ] - > IsObject ( ) ) {
ASYNC_CALL ( chmod , args [ 2 ] , * path , mode ) ;
ASYNC_CALL ( chmod , args [ 2 ] , * path , mode ) ;
} else {
} else {
SYNC_CALL ( chmod , * path , * path , mode ) ;
SYNC_CALL ( chmod , * path , * path , mode ) ;
@ -957,7 +966,7 @@ static void FChmod(const FunctionCallbackInfo<Value>& args) {
int fd = args [ 0 ] - > Int32Value ( ) ;
int fd = args [ 0 ] - > Int32Value ( ) ;
int mode = static_cast < int > ( args [ 1 ] - > Int32Value ( ) ) ;
int mode = static_cast < int > ( args [ 1 ] - > Int32Value ( ) ) ;
if ( args [ 2 ] - > IsFunction ( ) ) {
if ( args [ 2 ] - > IsObject ( ) ) {
ASYNC_CALL ( fchmod , args [ 2 ] , fd , mode ) ;
ASYNC_CALL ( fchmod , args [ 2 ] , fd , mode ) ;
} else {
} else {
SYNC_CALL ( fchmod , 0 , fd , mode ) ;
SYNC_CALL ( fchmod , 0 , fd , mode ) ;
@ -989,7 +998,7 @@ static void Chown(const FunctionCallbackInfo<Value>& args) {
uv_uid_t uid = static_cast < uv_uid_t > ( args [ 1 ] - > Uint32Value ( ) ) ;
uv_uid_t uid = static_cast < uv_uid_t > ( args [ 1 ] - > Uint32Value ( ) ) ;
uv_gid_t gid = static_cast < uv_gid_t > ( args [ 2 ] - > Uint32Value ( ) ) ;
uv_gid_t gid = static_cast < uv_gid_t > ( args [ 2 ] - > Uint32Value ( ) ) ;
if ( args [ 3 ] - > IsFunction ( ) ) {
if ( args [ 3 ] - > IsObject ( ) ) {
ASYNC_CALL ( chown , args [ 3 ] , * path , uid , gid ) ;
ASYNC_CALL ( chown , args [ 3 ] , * path , uid , gid ) ;
} else {
} else {
SYNC_CALL ( chown , * path , * path , uid , gid ) ;
SYNC_CALL ( chown , * path , * path , uid , gid ) ;
@ -1021,7 +1030,7 @@ static void FChown(const FunctionCallbackInfo<Value>& args) {
uv_uid_t uid = static_cast < uv_uid_t > ( args [ 1 ] - > Uint32Value ( ) ) ;
uv_uid_t uid = static_cast < uv_uid_t > ( args [ 1 ] - > Uint32Value ( ) ) ;
uv_gid_t gid = static_cast < uv_gid_t > ( args [ 2 ] - > Uint32Value ( ) ) ;
uv_gid_t gid = static_cast < uv_gid_t > ( args [ 2 ] - > Uint32Value ( ) ) ;
if ( args [ 3 ] - > IsFunction ( ) ) {
if ( args [ 3 ] - > IsObject ( ) ) {
ASYNC_CALL ( fchown , args [ 3 ] , fd , uid , gid ) ;
ASYNC_CALL ( fchown , args [ 3 ] , fd , uid , gid ) ;
} else {
} else {
SYNC_CALL ( fchown , 0 , fd , uid , gid ) ;
SYNC_CALL ( fchown , 0 , fd , uid , gid ) ;
@ -1050,7 +1059,7 @@ static void UTimes(const FunctionCallbackInfo<Value>& args) {
const double atime = static_cast < double > ( args [ 1 ] - > NumberValue ( ) ) ;
const double atime = static_cast < double > ( args [ 1 ] - > NumberValue ( ) ) ;
const double mtime = static_cast < double > ( args [ 2 ] - > NumberValue ( ) ) ;
const double mtime = static_cast < double > ( args [ 2 ] - > NumberValue ( ) ) ;
if ( args [ 3 ] - > IsFunction ( ) ) {
if ( args [ 3 ] - > IsObject ( ) ) {
ASYNC_CALL ( utime , args [ 3 ] , * path , atime , mtime ) ;
ASYNC_CALL ( utime , args [ 3 ] , * path , atime , mtime ) ;
} else {
} else {
SYNC_CALL ( utime , * path , * path , atime , mtime ) ;
SYNC_CALL ( utime , * path , * path , atime , mtime ) ;
@ -1078,7 +1087,7 @@ static void FUTimes(const FunctionCallbackInfo<Value>& args) {
const double atime = static_cast < double > ( args [ 1 ] - > NumberValue ( ) ) ;
const double atime = static_cast < double > ( args [ 1 ] - > NumberValue ( ) ) ;
const double mtime = static_cast < double > ( args [ 2 ] - > NumberValue ( ) ) ;
const double mtime = static_cast < double > ( args [ 2 ] - > NumberValue ( ) ) ;
if ( args [ 3 ] - > IsFunction ( ) ) {
if ( args [ 3 ] - > IsObject ( ) ) {
ASYNC_CALL ( futime , args [ 3 ] , fd , atime , mtime ) ;
ASYNC_CALL ( futime , args [ 3 ] , fd , atime , mtime ) ;
} else {
} else {
SYNC_CALL ( futime , 0 , fd , atime , mtime ) ;
SYNC_CALL ( futime , 0 , fd , atime , mtime ) ;
@ -1135,6 +1144,14 @@ void InitFs(Handle<Object> target,
env - > SetMethod ( target , " futimes " , FUTimes ) ;
env - > SetMethod ( target , " futimes " , FUTimes ) ;
StatWatcher : : Initialize ( env , target ) ;
StatWatcher : : Initialize ( env , target ) ;
// Create FunctionTemplate for FSReqWrap
Local < FunctionTemplate > fst =
FunctionTemplate : : New ( env - > isolate ( ) , NewFSReqWrap ) ;
fst - > InstanceTemplate ( ) - > SetInternalFieldCount ( 1 ) ;
fst - > SetClassName ( FIXED_ONE_BYTE_STRING ( env - > isolate ( ) , " FSReqWrap " ) ) ;
target - > Set ( FIXED_ONE_BYTE_STRING ( env - > isolate ( ) , " FSReqWrap " ) ,
fst - > GetFunction ( ) ) ;
}
}
} // end namespace node
} // end namespace node