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

Method extractPboFile

apps/tools/Studio/StudioApp.cpp:255–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253static std::atomic<int> gExtractCounter{0};
254
255std::string StudioApp::extractPboFile(const std::string& pboPath, const std::string& pboFilename)
256{
257 try
258 {
259 QFBank bank;
260 std::string bankName = StripPboExtension(pboPath);
261 if (!bank.open(RString(bankName.c_str())))
262 return {};
263 bank.Lock();
264 if (bank.error())
265 return {};
266 Ref<IFileBuffer> data = bank.Read(pboFilename.c_str());
267 if (!data || data->GetSize() == 0)
268 return {};
269 auto tempDir = std::filesystem::temp_directory_path();
270 auto ext = std::filesystem::path(pboFilename).extension().string();
271 int id = gExtractCounter++;
272 std::string tmpPath = (tempDir / ("poseidon_xref_" + std::to_string(id) + ext)).string();
273 std::ofstream out(tmpPath, std::ios::binary);
274 if (!out)
275 return {};
276 out.write(static_cast<const char*>(data->GetData()), data->GetSize());
277 out.close();
278 return tmpPath;
279 }
280 catch (...)
281 {
282 return {};
283 }
284}
285
286std::string StudioApp::extractVirtualFile(const FileEntry& entry)
287{

Callers

nothing calls this directly

Calls 10

StripPboExtensionFunction · 0.70
RStringClass · 0.50
openMethod · 0.45
LockMethod · 0.45
errorMethod · 0.45
ReadMethod · 0.45
GetSizeMethod · 0.45
writeMethod · 0.45
GetDataMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected