-
-
Notifications
You must be signed in to change notification settings - Fork 12
convertPath
xiao edited this page Nov 8, 2025
·
1 revision
converts paths between 8.3 name and long name. these functions require a filesystem or network I/O, so there are both a block and a non-block version.
callback:
fswin.convertPath(pathToConvert, callback, [isLong]);async:
var result = await fswin.convertPathAsync(pathToConvert, [isLong]);sync:
var result = fswin.convertPathSync(pathToConvert, [isLong]);-
pathToConvertis a string that specifies the path to convert. -
callbackis a function that takes only one argumentresult. -
isLongis a boolean value to determine the result will be a long or a short path. default value is false. -
resultis a string to indicate the converted path or null when failed.
var fswin = require('fswin');
var paths = ['C:\\PROGRA~1', 'C:\\program files\\Common Files', '\\\\mycomputer\\sharefolder\\somedir\\anotherdir', 'c:\\', '\\\\mycomputer\\sharefolder\\somedir', '\\\\mycomputer\\sharedfolder\\'];
var i;
//test the sync version
//note: if the path does not exist, this function will return an empty string.
for (i = 0; i < paths.length; i++) {
console.log('the long name of "' + paths[i] + '" is: "' + fswin.convertPathSync(paths[i], true) + '" and its short name is "' + fswin.convertPathSync(paths[i]) + '"');
}
//test the async version
//note: this function returns false before the async call if error occurs
for (i = 0; i < paths.length; i++) {
if (fswin.convertPath(paths[i], function (result) {
this.convertPath(result, function (result2) {
console.log('short name: "' + result + '" long name: "' + result2 + '"');
}, true);
})) {
console.log('the async call will be called');
} else {
console.log('there is an unexpected error, the async call will not be called.');
}
}