mirror of
https://github.com/nodejs/node.git
synced 2024-11-28 22:46:31 +01:00
3e1b1dd4a9
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
28 lines
648 B
JavaScript
28 lines
648 B
JavaScript
var assert = require('assert'),
|
|
common = require('../common'),
|
|
fs = require('fs'),
|
|
path = require('path'),
|
|
dirName = path.resolve(common.fixturesDir, 'test-readfile-unlink'),
|
|
fileName = path.resolve(dirName, 'test.bin');
|
|
|
|
var buf = new Buffer(512 * 1024);
|
|
buf.fill(42);
|
|
|
|
try {
|
|
fs.mkdirSync(dirName);
|
|
} catch (e) {
|
|
// Ignore if the directory already exists.
|
|
if (e.code != 'EEXIST') throw e;
|
|
}
|
|
|
|
fs.writeFileSync(fileName, buf);
|
|
|
|
fs.readFile(fileName, function(err, data) {
|
|
assert.ifError(err);
|
|
assert(data.length == buf.length);
|
|
assert.strictEqual(buf[0], 42);
|
|
|
|
fs.unlinkSync(fileName);
|
|
fs.rmdirSync(dirName);
|
|
});
|