| 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 | { |
nothing calls this directly
no test coverage detected