MCPcopy Create free account
hub / github.com/cloudflare/agents / extractArchive

Method extractArchive

packages/shell/src/memory.ts:332–354  ·  view source on GitHub ↗
(
    path: string,
    destination: string
  )

Source from the content-addressed store, hash-verified

330 }
331
332 async extractArchive(
333 path: string,
334 destination: string
335 ): Promise<StateArchiveExtractResult> {
336 const entries = extractTar(await this.readFileBytes(path));
337 for (const entry of entries) {
338 const destPath =
339 destination === "/" ? `/${entry.path}` : `${destination}/${entry.path}`;
340 if (entry.type === "directory") {
341 await this.mkdir(destPath, { recursive: true });
342 } else if (entry.bytes) {
343 await this.writeFileBytes(destPath, entry.bytes);
344 }
345 }
346 return {
347 destination,
348 entries: entries.map((entry) => ({
349 path: entry.path,
350 type: entry.type,
351 size: entry.bytes?.byteLength ?? 0
352 }))
353 };
354 }
355
356 async compressFile(
357 path: string,

Callers

nothing calls this directly

Calls 4

readFileBytesMethod · 0.95
mkdirMethod · 0.95
writeFileBytesMethod · 0.95
extractTarFunction · 0.90

Tested by

no test coverage detected