MCPcopy Create free account
hub / github.com/modelcontextprotocol/mcpb / getAllFilesWithCount

Function getAllFilesWithCount

src/node/files.ts:120–162  ·  view source on GitHub ↗
(
  dirPath: string,
  baseDir: string = dirPath,
  fileList: Record<string, FileWithPermissions> = {},
  additionalPatterns: string[] = [],
  ignoredCount = 0,
)

Source from the content-addressed store, hash-verified

118}
119
120export function getAllFilesWithCount(
121 dirPath: string,
122 baseDir: string = dirPath,
123 fileList: Record<string, FileWithPermissions> = {},
124 additionalPatterns: string[] = [],
125 ignoredCount = 0,
126): GetAllFilesResult {
127 const files = readdirSync(dirPath);
128
129 const ignoreChecker = buildIgnoreChecker(additionalPatterns);
130
131 for (const file of files) {
132 const filePath = join(dirPath, file);
133 const relativePath = relative(baseDir, filePath);
134
135 if (ignoreChecker.ignores(relativePath)) {
136 ignoredCount++;
137 continue;
138 }
139
140 const stat = statSync(filePath);
141
142 if (stat.isDirectory()) {
143 const result = getAllFilesWithCount(
144 filePath,
145 baseDir,
146 fileList,
147 additionalPatterns,
148 ignoredCount,
149 );
150 ignoredCount = result.ignoredCount;
151 } else {
152 // Use forward slashes in zip file paths
153 const zipPath = relativePath.split(sep).join("/");
154 fileList[zipPath] = {
155 data: readFileSync(filePath),
156 mode: stat.mode,
157 };
158 }
159 }
160
161 return { files: fileList, ignoredCount };
162}

Callers 1

packExtensionFunction · 0.85

Calls 1

buildIgnoreCheckerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…