MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Extract

Method Extract

apps/tools/Tools/commands/PboCommand.cpp:376–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374 std::string bankName = StripPboExtension(pboPath);
375 QFBank bank;
376 if (!bank.open(RString(bankName.c_str())))
377 {
378 std::cerr << "Error: Cannot open PBO: " << pboPath << std::endl;
379 return 1;
380 }
381 bank.Lock();
382
383 if (bank.error())
384 {
385 std::cerr << "Error: Failed to load PBO: " << pboPath << std::endl;
386 bank.Unlock();
387 return 1;
388 }
389 auto info = Poseidon::InspectPbo(pboPath);
390 if (!info.valid)
391 {
392 bank.Unlock();
393 std::cerr << "Error: Failed to inspect PBO: " << pboPath << std::endl;
394 return 1;
395 }
396 std::string outDir = outputDir.empty() ? GetDefaultOutputDir(pboPath) : outputDir;
397 outDir = NormalizePath(outDir);
398 std::string normalizedFilter = NormalizeBankPath(fileFilter);
399
400 int extracted = 0;
401 int skipped = 0;
402 for (const auto& e : info.entries)
403 {
404 if (!normalizedFilter.empty() && NormalizeBankPath(e.name).find(normalizedFilter) == std::string::npos)
405 {
406 skipped++;
407 continue;
408 }
409
410 Ref<IFileBuffer> data = bank.Read(e.name.c_str());
411 if (!data)
412 {
413 std::cerr << "Warning: Cannot read: " << e.name << std::endl;
414 continue;
415 }
416
417 std::string entryPath = NormalizePath(e.name);
418 std::string fullPath = outDir + "/" + entryPath;
419
420 auto lastSep = fullPath.find_last_of("/\\");
421 if (lastSep != std::string::npos)
422 {
423 std::string parentDir = fullPath.substr(0, lastSep);
424 if (!CreateDirectories(parentDir))
425 {
426 std::cerr << "Error: Cannot create directory: " << parentDir << std::endl;
427 continue;
428 }
429 }
430
431 FILE* outFile = fopen(fullPath.c_str(), "wb");
432 if (!outFile)
433 {

Callers

nothing calls this directly

Calls 14

InspectPboFunction · 0.85
SetFileTimestampFunction · 0.85
FormatSizeFunction · 0.85
statClass · 0.70
StripPboExtensionFunction · 0.70
RStringClass · 0.50
openMethod · 0.45
LockMethod · 0.45
errorMethod · 0.45
UnlockMethod · 0.45
emptyMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected