()
| 320 | } |
| 321 | |
| 322 | function buildEntries(): Map<string, MockFsEntry> { |
| 323 | const inputs = createMockFilesystemEntries(); |
| 324 | const entries = new Map<string, MockFsEntry>(); |
| 325 | const ensureDir = (path: string) => { |
| 326 | const normalizedPath = normalizeMockPath(path, "/"); |
| 327 | if (entries.has(normalizedPath)) { |
| 328 | return; |
| 329 | } |
| 330 | const dir = getDirName(normalizedPath); |
| 331 | if (normalizedPath !== "/") { |
| 332 | ensureDir(dir); |
| 333 | } |
| 334 | entries.set(normalizedPath, { |
| 335 | path: normalizedPath, |
| 336 | dir: normalizedPath === "/" ? "/" : dir, |
| 337 | name: normalizedPath === "/" ? "/" : getBaseName(normalizedPath), |
| 338 | isdir: true, |
| 339 | mimetype: MockDirMimeType, |
| 340 | modtime: MockBaseModTime + entries.size * 60000, |
| 341 | mode: MockDirMode, |
| 342 | size: 0, |
| 343 | supportsmkdir: true, |
| 344 | }); |
| 345 | }; |
| 346 | for (const input of inputs) { |
| 347 | const normalizedPath = normalizeMockPath(input.path, "/"); |
| 348 | const isdir = input.isdir ?? false; |
| 349 | const dir = getDirName(normalizedPath); |
| 350 | if (normalizedPath !== "/") { |
| 351 | ensureDir(dir); |
| 352 | } |
| 353 | const content = input.content == null ? undefined : makeContentBytes(input.content); |
| 354 | entries.set(normalizedPath, { |
| 355 | path: normalizedPath, |
| 356 | dir: normalizedPath === "/" ? "/" : dir, |
| 357 | name: normalizedPath === "/" ? "/" : getBaseName(normalizedPath), |
| 358 | isdir, |
| 359 | mimetype: input.mimetype ?? getMimeType(normalizedPath, isdir), |
| 360 | modtime: MockBaseModTime + entries.size * 60000, |
| 361 | mode: isdir ? MockDirMode : MockFileMode, |
| 362 | size: content?.byteLength ?? 0, |
| 363 | readonly: input.readonly, |
| 364 | supportsmkdir: isdir, |
| 365 | content, |
| 366 | }); |
| 367 | } |
| 368 | return entries; |
| 369 | } |
| 370 | |
| 371 | function toFileInfo(entry: MockFsEntry): FileInfo { |
| 372 | return { |
no test coverage detected