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

17 lines
350 B
JavaScript
Raw Normal View History

require('../common');
2010-06-11 05:59:06 +08:00
path = require('path'),
Buffer = require('buffer').Buffer
fs = require('fs')
fn = path.join(fixturesDir, 'write.txt');
2010-06-11 05:59:06 +08:00
foo = 'foo'
var fd = fs.openSync(fn, 'w');
2010-06-11 05:59:06 +08:00
fs.writeSync(fd, foo);
bar = 'bár'
fs.writeSync(fd, new Buffer(bar), 0, Buffer.byteLength(bar));
fs.closeSync(fd);
2010-06-11 05:59:06 +08:00
assert.equal(fs.readFileSync(fn), 'foobár');