You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
common.refreshTmpDir();
|
|
|
|
|
|
|
|
// test creating and reading hard link
|
|
|
|
const srcPath = path.join(common.fixturesDir, 'cycles', 'root.js');
|
|
|
|
const dstPath = path.join(common.tmpDir, 'link1.js');
|
|
|
|
|
|
|
|
const callback = function(err) {
|
|
|
|
if (err) throw err;
|
|
|
|
const srcContent = fs.readFileSync(srcPath, 'utf8');
|
|
|
|
const dstContent = fs.readFileSync(dstPath, 'utf8');
|
|
|
|
assert.strictEqual(srcContent, dstContent);
|
|
|
|
};
|
|
|
|
|
|
|
|
fs.link(srcPath, dstPath, common.mustCall(callback));
|
|
|
|
|
|
|
|
// test error outputs
|
|
|
|
|
|
|
|
assert.throws(
|
|
|
|
function() {
|
|
|
|
fs.link();
|
|
|
|
},
|
|
|
|
/src path/
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.throws(
|
|
|
|
function() {
|
|
|
|
fs.link('abc');
|
|
|
|
},
|
|
|
|
/dest path/
|
|
|
|
);
|