MCPcopy Index your code
hub / github.com/codeaashu/claude-code / unzipFile

Function unzipFile

src/utils/dxt/zip.ts:113–141  ·  view source on GitHub ↗
(
  zipData: Buffer,
)

Source from the content-addressed store, hash-verified

111 * when this module is reached via the plugin loader chain.
112 */
113export async function unzipFile(
114 zipData: Buffer,
115): Promise<Record<string, Uint8Array>> {
116 const { unzipSync } = await import('fflate')
117 const compressedSize = zipData.length
118
119 const state: ZipValidationState = {
120 fileCount: 0,
121 totalUncompressedSize: 0,
122 compressedSize: compressedSize,
123 errors: [],
124 }
125
126 const result = unzipSync(new Uint8Array(zipData), {
127 filter: file => {
128 const validationResult = validateZipFile(file, state)
129 if (!validationResult.isValid) {
130 throw new Error(validationResult.error!)
131 }
132 return true
133 },
134 })
135
136 logForDebugging(
137 `Zip extraction completed: ${state.fileCount} files, ${Math.round(state.totalUncompressedSize / 1024)}KB uncompressed`,
138 )
139
140 return result
141}
142
143/**
144 * Parse Unix file modes from a zip's central directory.

Callers 4

readAndUnzipFileFunction · 0.85
extractZipToDirectoryFunction · 0.85
loadMcpbFileFunction · 0.85

Calls 2

validateZipFileFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected