From ea37d98949dd4f09cf08c29713c383059dbb697a Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 3 May 2010 13:25:48 -0700 Subject: [PATCH] Implement writeSync for buffers (Needs tests still) --- src/node_file.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 0e48cb9..f9fd27c 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -451,7 +451,7 @@ static Handle Open(const Arguments& args) { #define GET_OFFSET(a) (a)->IsInt32() ? (a)->IntegerValue() : -1; -// write(fd, data, position, enc, callback) +// bytesWritten = write(fd, data, position, enc, callback) // Wrapper for write(2). // // 0 fd integer. file descriptor @@ -565,14 +565,12 @@ static Handle Write(const Arguments& args) { return Undefined(); } else { + written = pos < 0 ? write(fd, buf, len) : pwrite(fd, buf, len, pos); if (legacy) { - written = pos < 0 ? write(fd, buf, len) : pwrite(fd, buf, len, pos); delete [] reinterpret_cast(buf); - if (written < 0) return ThrowException(ErrnoException(errno)); - return scope.Close(Integer::New(written)); - } else { - assert(0 && "fs.writeSync() with buffers is not yet supported"); } + if (written < 0) return ThrowException(ErrnoException(errno)); + return scope.Close(Integer::New(written)); } } -- 2.7.4