本文整理汇总了TypeScript中vs/workbench/parts/files/electron-browser/fileActions.validateFileName函数的典型用法代码示例。如果您正苦于以下问题:TypeScript validateFileName函数的具体用法?TypeScript validateFileName怎么用?TypeScript validateFileName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validateFileName函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Validate Multi-Path File Names', function () {
const d = new Date().getTime();
const wsFolder = createStat('/', 'workspaceFolder', true, false, 8096, d);
assert(validateFileName(wsFolder, 'foo/bar') === null);
assert(validateFileName(wsFolder, 'foo\\bar') === null);
assert(validateFileName(wsFolder, 'all/slashes/are/same') === null);
assert(validateFileName(wsFolder, 'theres/one/different\\slash') === null);
assert(validateFileName(wsFolder, '/slashAtBeginning') !== null);
// validation should detect if user tries to add a child to a file
const fileInRoot = createStat('/fileInRoot', 'fileInRoot', false, false, 8096, d);
wsFolder.addChild(fileInRoot);
assert(validateFileName(wsFolder, 'fileInRoot/aChild') !== null);
wsFolder.removeChild(fileInRoot);
// attempting to add a child to a deeply nested file
const s1 = createStat('/path', 'path', true, false, 8096, d);
const s2 = createStat('/path/to', 'to', true, false, 8096, d);
const s3 = createStat('/path/to/stat', 'stat', true, false, 8096, d);
wsFolder.addChild(s1);
s1.addChild(s2);
s2.addChild(s3);
const fileDeeplyNested = createStat('/path/to/stat/fileNested', 'fileNested', false, false, 8096, d);
s3.addChild(fileDeeplyNested);
assert(validateFileName(wsFolder, '/path/to/stat/fileNested/aChild') !== null);
// detect if path already exists
assert(validateFileName(wsFolder, '/path/to/stat/fileNested') !== null);
assert(validateFileName(wsFolder, '/path/to/stat/') !== null);
});
示例2: test
test('Validate File Name (For Rename)', function () {
const d = new Date().getTime();
const s = createStat('/path/to/stat', 'sName', true, true, 8096, d);
const sChild = createStat('/path/to/stat/alles.klar', 'alles.klar', true, true, 8096, d);
s.addChild(sChild);
assert(validateFileName(s, 'alles.klar') !== null);
if (isLinux) {
assert(validateFileName(s, 'Alles.klar') === null);
assert(validateFileName(s, 'Alles.Klar') === null);
} else {
assert(validateFileName(s, 'Alles.klar') !== null);
assert(validateFileName(s, 'Alles.Klar') !== null);
}
assert(validateFileName(s, '.foo') === null);
assert(validateFileName(s, 'foo.bar') === null);
assert(validateFileName(s, 'foo') === null);
});