MCPcopy Index your code
hub / github.com/nodejs/node / addOrDeleteFileOrDirectory

Function addOrDeleteFileOrDirectory

test/fixtures/snapshot/typescript.js:115361–115394  ·  view source on GitHub ↗
(fileOrDirectory, fileOrDirectoryPath)

Source from the content-addressed store, hash-verified

115359 return host.realpath ? host.realpath(s) : s;
115360 }
115361 function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) {
115362 var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath);
115363 if (existingResult !== undefined) {
115364 // Just clear the cache for now
115365 // For now just clear the cache, since this could mean that multiple level entries might need to be re-evaluated
115366 clearCache();
115367 return undefined;
115368 }
115369 var parentResult = getCachedFileSystemEntriesForBaseDir(fileOrDirectoryPath);
115370 if (!parentResult) {
115371 return undefined;
115372 }
115373 // This was earlier a file (hence not in cached directory contents)
115374 // or we never cached the directory containing it
115375 if (!host.directoryExists) {
115376 // Since host doesnt support directory exists, clear the cache as otherwise it might not be same
115377 clearCache();
115378 return undefined;
115379 }
115380 var baseName = getBaseNameOfFileName(fileOrDirectory);
115381 var fsQueryResult = {
115382 fileExists: host.fileExists(fileOrDirectoryPath),
115383 directoryExists: host.directoryExists(fileOrDirectoryPath)
115384 };
115385 if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
115386 // Folder added or removed, clear the cache instead of updating the folder and its structure
115387 clearCache();
115388 }
115389 else {
115390 // No need to update the directory structure, just files
115391 updateFilesOfFileSystemEntry(parentResult, baseName, fsQueryResult.fileExists);
115392 }
115393 return fsQueryResult;
115394 }
115395 function addOrDeleteFile(fileName, filePath, eventKind) {
115396 if (eventKind === ts.FileWatcherEventKind.Changed) {
115397 return;

Callers

nothing calls this directly

Calls 6

clearCacheFunction · 0.85
getBaseNameOfFileNameFunction · 0.85
hasEntryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…