| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d09f6d5 commit 3b46e7f
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -272,10 +272,14 @@ function preprocessSymlinkDestination(path, type, linkPath) { | |||
| 272 | 272 | // A relative target is relative to the link's parent directory. | |
| 273 | 273 | path = pathModule.resolve(linkPath, '..', path); | |
| 274 | 274 | return pathModule.toNamespacedPath(path); | |
| 275 | - } else { | ||
| 276 | - // Windows symlinks don't tolerate forward slashes. | ||
| 277 | - return ('' + path).replace(/\//g, '\\'); | ||
| 278 | 275 | } | |
| 276 | + | ||
| 277 | + if (pathModule.isAbsolute(path)) { | ||
| 278 | + // If the path is absolute, use the \\?\-prefix to enable long filenames | ||
| 279 | + return pathModule.toNamespacedPath(path); | ||
| 280 | + } | ||
| 281 | + // Windows symlinks don't tolerate forward slashes. | ||
| 282 | + return ('' + path).replace(/\//g, '\\'); | ||
| 279 | 283 | } | |
| 280 | 284 | ||
| 281 | 285 | // Constructor for file stats. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const path = require('path'); | ||
| 6 | + const fs = require('fs'); | ||
| 7 | + | ||
| 8 | + const tmpdir = require('../common/tmpdir'); | ||
| 9 | + tmpdir.refresh(); | ||
| 10 | + const tmpDir = tmpdir.path; | ||
| 11 | + const longPath = path.join(...[tmpDir].concat(Array(30).fill('1234567890'))); | ||
| 12 | + fs.mkdirSync(longPath, { recursive: true }); | ||
| 13 | + | ||
| 14 | + // Test if we can have symlinks to files and folders with long filenames | ||
| 15 | + const targetDirtectory = path.join(longPath, 'target-directory'); | ||
| 16 | + fs.mkdirSync(targetDirtectory); | ||
| 17 | + const pathDirectory = path.join(tmpDir, 'new-directory'); | ||
| 18 | + fs.symlink(targetDirtectory, pathDirectory, 'dir', common.mustCall((err) => { | ||
| 19 | + assert.ifError(err); | ||
| 20 | + assert(fs.existsSync(pathDirectory)); | ||
| 21 | + })); | ||
| 22 | + | ||
| 23 | + const targetFile = path.join(longPath, 'target-file'); | ||
| 24 | + fs.writeFileSync(targetFile, 'data'); | ||
| 25 | + const pathFile = path.join(tmpDir, 'new-file'); | ||
| 26 | + fs.symlink(targetFile, pathFile, common.mustCall((err) => { | ||
| 27 | + assert.ifError(err); | ||
| 28 | + assert(fs.existsSync(pathFile)); | ||
| 29 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments