0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/simple/test-fs-write-sync.js
Felix Geisendörfer c46cbe0de4 Deprecate string interface for fs.write()
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.
2010-05-19 12:53:43 -07:00

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');