Browse Source

fs.writeSync should return bytes written

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
458bbb4687
  1. 2
      lib/fs.js
  2. 3
      test/simple/test-fs-write-sync.js

2
lib/fs.js

@ -221,7 +221,7 @@ fs.writeSync = function (fd, buffer, offset, length, position) {
length = buffer.length; length = buffer.length;
} }
binding.write(fd, buffer, offset, length, position); return binding.write(fd, buffer, offset, length, position);
}; };
fs.rename = function (oldPath, newPath, callback) { fs.rename = function (oldPath, newPath, callback) {

3
test/simple/test-fs-write-sync.js

@ -11,7 +11,8 @@ var fd = fs.openSync(fn, 'w');
fs.writeSync(fd, foo); fs.writeSync(fd, foo);
bar = 'bár' 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); fs.closeSync(fd);
assert.equal(fs.readFileSync(fn), 'foobár'); assert.equal(fs.readFileSync(fn), 'foobár');

Loading…
Cancel
Save