| 150 | static std::mutex g_engineMutex; |
| 151 | |
| 152 | static 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 | |
| 190 | static std::atomic<uint64_t> g_tempFileCounter{0}; |
| 191 | |