MCPcopy Index your code
hub / github.com/microsoft/vscode-cpptools / info

Method info

Extension/src/Utility/Filesystem/filepath.ts:74–109  ·  view source on GitHub ↗
(name: string | undefined | Promise<string | undefined>, baseFolder?: string, executableExtensions: Set<string> = process.platform === 'win32' ? new Set(['.exe'/* ,'.cmd','.bat' */]) : new Set())

Source from the content-addressed store, hash-verified

72 }
73
74 static async info(name: string | undefined | Promise<string | undefined>, baseFolder?: string, executableExtensions: Set<string> = process.platform === 'win32' ? new Set(['.exe'/* ,'.cmd','.bat' */]) : new Set()): Promise<undefined | File | Folder> {
75 const [fullPath, stats] = await filepath.stats(name, baseFolder);
76 if (!stats) {
77 return undefined;
78 }
79 // create the entry
80 const entry = {
81 name: basename(fullPath),
82 fullPath,
83 isFolder: stats.isDirectory(),
84 isFile: stats.isFile(),
85 isLink: stats.isSymbolicLink()
86 } as File | Folder;
87
88 if (entry.isFile) {
89 entry.size = stats.size;
90
91 if (isWindows) {
92 const fp = fullPath.toLowerCase();
93 entry.extension = extname(fp);
94 entry.basename = basename(fp, entry.extension);
95 entry.isExecutable = executableExtensions.has(entry.extension);
96 return entry;
97 }
98 entry.extension = extname(fullPath);
99 entry.basename = basename(fullPath, entry.extension);
100 // eslint-disable-next-line no-bitwise
101 entry.isExecutable = !!(stats.mode & (constants.S_IXUSR | constants.S_IXGRP | constants.S_IXOTH));
102 return entry;
103 }
104 if (entry.isFolder) {
105 return entry;
106 }
107
108 fail(new Error(`Unexpected file type for ${fullPath}`));
109 }
110
111 static async isFile(name: any | string | undefined | Promise<string | undefined>, baseFolder?: string): Promise<undefined | string> {
112 const [fullName, stats] = await filepath.stats(name, baseFolder);

Callers 2

isExecutableMethod · 0.80
isExecutableMethod · 0.80

Calls 3

statsMethod · 0.80
hasMethod · 0.80
isFileMethod · 0.45

Tested by

no test coverage detected