當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。