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

40 lines
876 B
JavaScript
Raw Normal View History

'use strict';
2011-12-05 06:37:18 +01:00
var common = require('../common');
2011-11-25 09:29:06 +01:00
var fs = require('fs');
var path = require('path');
var assert = require('assert');
if (!common.isWindows) {
console.log('1..0 # Skipped: this test is Windows-specific.');
return;
}
2011-11-25 09:29:06 +01:00
var successes = 0;
// make a path that will be at least 260 chars long.
2011-12-05 06:37:18 +01:00
var fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1);
var fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x'));
2011-11-25 09:29:06 +01:00
var fullPath = path.resolve(fileName);
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', function(err) {
if (err) throw err;
successes++;
fs.stat(fullPath, function(err, stats) {
if (err) throw err;
successes++;
});
});
process.on('exit', function() {
2013-02-28 09:18:12 -08:00
fs.unlinkSync(fullPath);
2011-11-25 09:29:06 +01:00
assert.equal(2, successes);
});