当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fileActions.validateFileName函数代码示例

本文整理汇总了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);
	});
开发者ID:jumpinjackie,项目名称:sqlopsstudio,代码行数:31,代码来源:explorerModel.test.ts

示例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);
	});
开发者ID:jinlongchen2018,项目名称:vscode,代码行数:20,代码来源:explorerModel.test.ts


注:本文中的vs/workbench/parts/files/electron-browser/fileActions.validateFileName函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。