MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / unzipTo

Function unzipTo

common/script/zip_api.cpp:233–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231 }
232
233 int unzipTo(const char* zipPath, const char* outDir)
234 {
235 FILE* f = fopen(zipPath, "rb");
236 if (f == nullptr) {
237 return -1;
238 }
239 fseek(f, 0, SEEK_END);
240 const long len = ftell(f);
241 rewind(f);
242 if (len < 0) {
243 fclose(f);
244 return -1;
245 }
246 StdByteReader reader(f);
247 DirExtractSink sink(outDir);
248 std::string err;
249 ScriptConsole::get().beginIo("unzip", (long long)len);
250 const bool ok =
251 TransferProto::extractZip(reader, (uint64_t)len, sink, scriptCancelled, [](size_t n) { ScriptConsole::get().addIo((long long)n); }, err);
252 ScriptConsole::get().endIo();
253 fclose(f);
254 return ok ? 0 : -1;
255 }
256}
257
258void ckpt_zip_dir(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs)

Callers 1

ckpt_unzipFunction · 0.85

Calls 5

getFunction · 0.85
extractZipFunction · 0.85
beginIoMethod · 0.80
addIoMethod · 0.80
endIoMethod · 0.80

Tested by

no test coverage detected