Skip to content

Commit

Permalink
fs.writeSync should return bytes written
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jul 17, 2010
1 parent 1662c37 commit 458bbb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fs.writeSync = function (fd, buffer, offset, length, position) {
length = buffer.length;
}

binding.write(fd, buffer, offset, length, position);
return binding.write(fd, buffer, offset, length, position);
};

fs.rename = function (oldPath, newPath, callback) {
Expand Down
3 changes: 2 additions & 1 deletion test/simple/test-fs-write-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var fd = fs.openSync(fn, 'w');
fs.writeSync(fd, foo);

bar = 'bár'
fs.writeSync(fd, new Buffer(bar), 0, Buffer.byteLength(bar));
written = fs.writeSync(fd, new Buffer(bar), 0, Buffer.byteLength(bar));
assert.ok(written > 3);
fs.closeSync(fd);

assert.equal(fs.readFileSync(fn), 'foobár');

0 comments on commit 458bbb4

Please sign in to comment.