-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
win,fs: use namespaced path in absolute symlinks
Use the namespaced (with the \\?\ prefix) paths for symlink targets when the path is absolute. This allows creation of symlinks to files with long filenames. Fixes: #27795 PR-URL: #33351 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
- Loading branch information
1 parent
d09f6d5
commit 3b46e7f
Showing
2 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const tmpdir = require('../common/tmpdir'); | ||
tmpdir.refresh(); | ||
const tmpDir = tmpdir.path; | ||
const longPath = path.join(...[tmpDir].concat(Array(30).fill('1234567890'))); | ||
fs.mkdirSync(longPath, { recursive: true }); | ||
|
||
// Test if we can have symlinks to files and folders with long filenames | ||
const targetDirtectory = path.join(longPath, 'target-directory'); | ||
fs.mkdirSync(targetDirtectory); | ||
const pathDirectory = path.join(tmpDir, 'new-directory'); | ||
fs.symlink(targetDirtectory, pathDirectory, 'dir', common.mustCall((err) => { | ||
assert.ifError(err); | ||
assert(fs.existsSync(pathDirectory)); | ||
})); | ||
|
||
const targetFile = path.join(longPath, 'target-file'); | ||
fs.writeFileSync(targetFile, 'data'); | ||
const pathFile = path.join(tmpDir, 'new-file'); | ||
fs.symlink(targetFile, pathFile, common.mustCall((err) => { | ||
assert.ifError(err); | ||
assert(fs.existsSync(pathFile)); | ||
})); |