MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / createFolderForFile

Function createFolderForFile

src/shared/utils/fs.ts:479–499  ·  view source on GitHub ↗
(file?: string)

Source from the content-addressed store, hash-verified

477}
478
479export function createFolderForFile(file?: string): string | undefined {
480 try {
481 if (!file || !path.isAbsolute(file))
482 return undefined;
483
484 // Skip creation of paths with variables, we'll rely on them
485 // being created after resolving.
486 if (file?.includes("${")) {
487 return file;
488 }
489
490 const folder = path.dirname(file);
491 if (!fs.existsSync(folder))
492 mkDirRecursive(folder);
493
494 return file;
495 } catch {
496 console.warn(`Ignoring invalid file path ${file}`);
497 return undefined;
498 }
499}
500
501export function areSameFolder(folder1: string, folder2: string) {
502 // Trim any trailing path separators of either direction.

Callers 15

createTempTestFileFunction · 0.90
setupTestFilesFunction · 0.90
captureLogsFunction · 0.90
analyzerLogFileMethod · 0.90
dapLogFileMethod · 0.90
devToolsLogFileMethod · 0.90
mcpServerLogFileMethod · 0.90
extensionLogFileMethod · 0.90
flutterDaemonLogFileMethod · 0.90
toolingDaemonLogFileMethod · 0.90

Calls 2

mkDirRecursiveFunction · 0.85
warnMethod · 0.65

Tested by 1

setupTestFilesFunction · 0.72