| 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 | |
| 258 | void ckpt_zip_dir(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) |
no test coverage detected