nodejs/test/parallel/test-fs-long-path.js

35 lines
815 B
JavaScript
Raw Normal View History

'use strict';
const common = require('../common');
const fs = require('fs');
const path = require('path');
const assert = require('assert');
2011-11-25 09:29:06 +01:00
if (!common.isWindows) {
common.skip('this test is Windows-specific.');
return;
}
2011-11-25 09:29:06 +01:00
// make a path that will be at least 260 chars long.
const fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1);
const fileName = path.join(common.tmpDir, 'x'.repeat(fileNameLen));
const fullPath = path.resolve(fileName);
2011-11-25 09:29:06 +01:00
common.refreshTmpDir();
2012-01-17 19:43:34 +01:00
console.log({
filenameLength: fileName.length,
fullPathLength: fullPath.length
});
2011-11-25 09:29:06 +01:00
fs.writeFile(fullPath, 'ok', common.mustCall(function(err) {
assert.ifError(err);
2011-11-25 09:29:06 +01:00
fs.stat(fullPath, common.mustCall(function(err, stats) {
assert.ifError(err);
}));
}));
2011-11-25 09:29:06 +01:00
process.on('exit', function() {
2013-02-28 09:18:12 -08:00
fs.unlinkSync(fullPath);
2011-11-25 09:29:06 +01:00
});