Skip to content

Commit

Permalink
Implement writeSync for buffers
Browse files Browse the repository at this point in the history
(Needs tests still)
  • Loading branch information
ry committed May 3, 2010
1 parent 3202bce commit ea37d98
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ static Handle<Value> 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
Expand Down Expand Up @@ -565,14 +565,12 @@ static Handle<Value> 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<char*>(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));
}
}

Expand Down

0 comments on commit ea37d98

Please sign in to comment.