ttsc
Version:
General-purpose TypeScript-Go compiler, runtime, plugin host, and LSP host.
34 lines • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseWindowsDirectoryCaseSensitivity = parseWindowsDirectoryCaseSensitivity;
/**
* Interpret fsutil's case-sensitivity query without assuming a display
* language.
*
* English messages identify the state directly. For every other locale, the
* volume-root query supplies the raw localized suffix for the ordinary disabled
* state. A target with that suffix is insensitive; a different successful
* message is the enabled state.
*/
function parseWindowsDirectoryCaseSensitivity(directoryOutput, volumeOutput, volumeRoot) {
const text = directoryOutput.toString("utf8");
if (/\bdisabled\b/iu.test(text))
return false;
if (/\benabled\b/iu.test(text))
return true;
if (volumeOutput === undefined)
return undefined;
const encodedRoot = Buffer.from(volumeRoot, "utf8");
const rootOffset = volumeOutput.lastIndexOf(encodedRoot);
if (rootOffset === -1)
return undefined;
const disabledSuffix = volumeOutput.subarray(rootOffset + encodedRoot.length);
if (disabledSuffix.length === 0 ||
directoryOutput.length < disabledSuffix.length) {
return undefined;
}
return !directoryOutput
.subarray(directoryOutput.length - disabledSuffix.length)
.equals(disabledSuffix);
}
//# sourceMappingURL=windowsDirectoryCaseSensitivity.js.map