Skip to content

Commit

Permalink
Fix treatment of long file paths in Windows
Browse files Browse the repository at this point in the history
3e5d171 (from November 2011) introduced this code to fix treatment
of long file paths in Windows. Then, one week later, this commit
fixed long file paths directly in Node's `fs` library:
nodejs/node-v0.x-archive@1f16a7b

So, the code currently in fstream actually /breaks/ long file
paths in Windows.

This fixes it, but keeps an additional mysterious line introduced
by that original commit that I don't understand.

Fixes npm#30. Thanks to @sdarnell for identifying the problem.
  • Loading branch information
avital committed Mar 24, 2015
1 parent a7b34f7 commit d11b9ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
9 changes: 1 addition & 8 deletions lib/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,8 @@ function Reader (props, currentStat) {

self._path = self.path = path.resolve(props.path)
if (process.platform === 'win32') {
// XXX What is this code for?

This comment has been minimized.

Copy link
@sdarnell

sdarnell Mar 24, 2015

I believe this line is trying to escape any question mark which would become invalid when converted to the UNC form. However, I think it should be removed as any escaping of this sort should be performed on the same place as the conversion to UNC.
I suspect it was a misguided hack to try to get things working, and IMO should not be done even in libuv.

self.path = self._path = self.path.replace(/\?/g, '_')
if (self._path.length >= 260) {
// how DOES one create files on the moon?
// if the path has spaces in it, then UNC will fail.
self._swallowErrors = true
// if (self._path.indexOf(" ") === -1) {
self._path = '\\\\?\\' + self.path.replace(/\//g, '\\')
// }
}
}
self.basename = props.basename = path.basename(self.path)
self.dirname = props.dirname = path.dirname(self.path)
Expand Down
5 changes: 1 addition & 4 deletions lib/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ function Writer (props, current) {

self._path = self.path = path.resolve(props.path)
if (process.platform === 'win32') {
// XXX What is this code for?
self.path = self._path = self.path.replace(/\?/g, '_')
if (self._path.length >= 260) {
self._swallowErrors = true
self._path = '\\\\?\\' + self.path.replace(/\//g, '\\')
}
}
self.basename = path.basename(props.path)
self.dirname = path.dirname(props.path)
Expand Down

0 comments on commit d11b9ec

Please sign in to comment.