| 1 |
'use strict'; |
| 2 |
|
| 3 |
var resolve = require('./resolve'); |
| 4 |
|
| 5 |
module.exports = function (path) { |
| 6 |
// Note: this will *probably* throw somewhere. |
| 7 |
if (typeof path !== 'string') return path; |
| 8 |
|
| 9 |
if (!path) { |
| 10 |
return ''; |
| 11 |
} |
| 12 |
|
| 13 |
var resolvedPath = resolve(path); |
| 14 |
|
| 15 |
if (/^[a-zA-Z]\:\\/.test(resolvedPath)) { |
| 16 |
// path is local filesystem path, which needs to be converted |
| 17 |
// to long UNC path. |
| 18 |
return '\\\\?\\' + resolvedPath; |
| 19 |
} |
| 20 |
if (/^\\\\[^?.]/.test(resolvedPath)) { |
| 21 |
// path is network UNC path, which needs to be converted |
| 22 |
// to long UNC path. |
| 23 |
return '\\\\?\\UNC\\' + resolvedPath.substring(2); |
| 24 |
} |
| 25 |
|
| 26 |
return path; |
| 27 |
}; |