joyent/node — Issue #2151: long filenames cause ENOENT on windows
Author: isaacs
Created: 2011-11-20 05:49:50+00:00
State: open
Labels: fs, windows

Anything that hits 260 characters will fail with ENOENT.

```javascript

var fs = require('fs');
var path = require('path');

// make a path that will be at least 260 chars long.
var cwd = process.cwd();
var fileNameLen = Math.max(260 - cwd.length - 1, 1);
var fileName = new Array(fileNameLen + 1).join('x');
var fullPath = path.resolve(fileName)

console.log({ filenameLength: fileName.length,
fullPathLength: fullPath.length });

fs.writeFileSync(path.resolve(fullPath), 'ok');
```

Result:

```
C:\Documents and Settings\Administrator\test>node t.js
{ filenameLength: 215, fullPathLength: 260 }

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: ENOENT, no such file or directory 'C:\Documents and Settings\Administrato
r\test\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
at Object.openSync (fs.js:228:18)
at Object.writeFileSync (fs.js:587:15)
at Object. (C:\Documents and Settings\Administrator\test\t.js:13:
4)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
```