Sha256: f74f5198b84dfbfe32fef87f71cefd9843b63bddbdb62e607c0ea87c57c4d6db

Contents?: true

Size: 912 Bytes

Versions: 3

Compression:

Stored size: 912 Bytes

Contents

common = require("../common");
assert = common.assert
var path = require('path');
var Buffer = require('buffer').Buffer;
var fs = require('fs');
var fn = path.join(common.fixturesDir, "write.txt");
var expected = "ümlaut.";
var found;

fs.open(fn, 'w', 0644, function (err, fd) {
  if (err) throw err;
  console.log('open done');
  fs.write(fd, '', 0, 'utf8', function(err, written) {
      assert.fail('zero length write should not go through to callback');
  });
  fs.write(fd, expected, 0, "utf8", function (err, written) {
    console.log('write done');
    if (err) throw err;
    assert.equal(Buffer.byteLength(expected), written);
    fs.closeSync(fd);
    found = fs.readFileSync(fn, 'utf8');
    console.log('expected: ' + expected.toJSON());
    console.log('found: ' + found.toJSON());
    fs.unlinkSync(fn);
  });
});

process.addListener("exit", function () {
  assert.equal(expected, found);
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rednode-0.1.2 ext/node/test/simple/test-fs-write.js
rednode-0.1.1 ext/node/test/simple/test-fs-write.js
rednode-0.1.0 ext/node/test/simple/test-fs-write.js