mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
c46cbe0de4
This patch makes buffers the preferred input for fs.write() and fs.writeSync(). The old string interface is still supported by converting strings to buffers dynamically. This allows to remove the C++ code for string handling which is also part of this patch.
12 lines
319 B
JavaScript
12 lines
319 B
JavaScript
require('../common');
|
|
var path = require('path')
|
|
, Buffer = require('buffer').Buffer
|
|
, fs = require('fs')
|
|
, fn = path.join(fixturesDir, 'write.txt');
|
|
|
|
var fd = fs.openSync(fn, 'w');
|
|
fs.writeSync(fd, 'foo');
|
|
fs.writeSync(fd, new Buffer('bar'), 0, 3);
|
|
fs.closeSync(fd);
|
|
|
|
assert.equal(fs.readFileSync(fn), 'foobar'); |