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

Function ExtractPboEntry

apps/tools/Tools/commands/ScanCommand.cpp:152–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150static std::mutex g_engineMutex;
151
152static std::string ExtractPboEntry(const std::string& pboPath, const std::string& entryName)
153{
154 std::string bankName = pboPath;
155 if (bankName.size() >= 4)
156 {
157 std::string ext = bankName.substr(bankName.size() - 4);
158 for (auto& c : ext)
159 c = static_cast<char>(tolower(static_cast<unsigned char>(c)));
160 if (ext == ".pbo")
161 bankName = bankName.substr(0, bankName.size() - 4);
162 }
163
164 std::lock_guard<std::mutex> lock(g_engineMutex);
165 QFBank bank;
166 if (!bank.open(RString(bankName.c_str())))
167 return {};
168 bank.Lock();
169 if (bank.error())
170 {
171 bank.Unlock();
172 return {};
173 }
174
175 const auto& fi = bank.FindFileInfo(entryName.c_str());
176 if (QFBank::IsNull(fi))
177 {
178 bank.Unlock();
179 return {};
180 }
181
182 auto buf = bank.Read(entryName.c_str());
183 bank.Unlock();
184 if (!buf || buf->GetSize() <= 0)
185 return {};
186
187 return std::string(buf->GetData(), buf->GetSize());
188}
189
190static std::atomic<uint64_t> g_tempFileCounter{0};
191

Callers 1

AnalyzeItemFunction · 0.85

Calls 9

sizeMethod · 0.80
RStringClass · 0.50
openMethod · 0.45
LockMethod · 0.45
errorMethod · 0.45
UnlockMethod · 0.45
ReadMethod · 0.45
GetSizeMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected