| 225 | } |
| 226 | |
| 227 | void ProcessFile(const fs::path& filePath, bool forceScan) |
| 228 | { |
| 229 | if (!fs::is_regular_file(filePath)) |
| 230 | { |
| 231 | std::wcout << L"[EmbedPDB:SKIP] Not a file: " << filePath << std::endl; |
| 232 | return; |
| 233 | } |
| 234 | |
| 235 | auto pdbPath = filePath.parent_path() / (filePath.stem().wstring() + L".pdb"); |
| 236 | |
| 237 | bool hasPDBOnDisk = fs::exists(pdbPath); |
| 238 | auto embedded = ExtractEmbeddedPDB(filePath, forceScan); |
| 239 | bool hasEmbedded = embedded.has_value(); |
| 240 | |
| 241 | if (hasPDBOnDisk && hasEmbedded) |
| 242 | { |
| 243 | std::wcout << L"[EmbedPDB:INFO] Already up to date: " << filePath << std::endl; |
| 244 | } |
| 245 | else if (hasPDBOnDisk) |
| 246 | { |
| 247 | EmbedPDB(filePath, pdbPath); |
| 248 | } |
| 249 | else if (hasEmbedded) |
| 250 | { |
| 251 | std::ofstream out(pdbPath, std::ios::binary); |
| 252 | if (out) |
| 253 | { |
| 254 | const auto& d = *embedded; |
| 255 | out.write(reinterpret_cast<const char*>(d.data()), d.size()); |
| 256 | std::wcout << L"[EmbedPDB:SUCCESS] Extracted: " << pdbPath << std::endl; |
| 257 | } |
| 258 | else |
| 259 | std::wcout << L"[EmbedPDB:ERROR] Failed to write: " << pdbPath << std::endl; |
| 260 | } |
| 261 | else |
| 262 | { |
| 263 | std::wcout << L"[EmbedPDB:INFO] No PDB found for: " << filePath << std::endl; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | int wmain(int argc, wchar_t* argv[]) |
| 268 | { |
no test coverage detected