| 459 | } |
| 460 | |
| 461 | bool ImportProject::importSln(std::istream &istr, const std::string &path, const std::vector<std::string> &fileFilters) |
| 462 | { |
| 463 | std::string line; |
| 464 | |
| 465 | if (!std::getline(istr,line)) { |
| 466 | errors.emplace_back("Visual Studio solution file is empty"); |
| 467 | return false; |
| 468 | } |
| 469 | |
| 470 | if (!startsWith(line, "Microsoft Visual Studio Solution File")) { |
| 471 | // Skip BOM |
| 472 | if (!std::getline(istr, line) || !startsWith(line, "Microsoft Visual Studio Solution File")) { |
| 473 | errors.emplace_back("Visual Studio solution file header not found"); |
| 474 | return false; |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | std::map<std::string,std::string,cppcheck::stricmp> variables; |
| 479 | variables["SolutionDir"] = path; |
| 480 | |
| 481 | bool found = false; |
| 482 | std::vector<SharedItemsProject> sharedItemsProjects; |
| 483 | while (std::getline(istr,line)) { |
| 484 | if (!startsWith(line,"Project(")) |
| 485 | continue; |
| 486 | const std::string::size_type pos = line.find(".vcxproj"); |
| 487 | if (pos == std::string::npos) |
| 488 | continue; |
| 489 | const std::string::size_type pos1 = line.rfind('\"',pos); |
| 490 | if (pos1 == std::string::npos) |
| 491 | continue; |
| 492 | std::string vcxproj(line.substr(pos1+1, pos-pos1+7)); |
| 493 | vcxproj = Path::toNativeSeparators(std::move(vcxproj)); |
| 494 | if (!Path::isAbsolute(vcxproj)) |
| 495 | vcxproj = path + vcxproj; |
| 496 | vcxproj = Path::fromNativeSeparators(std::move(vcxproj)); |
| 497 | if (!importVcxproj(vcxproj, variables, "", fileFilters, sharedItemsProjects)) { |
| 498 | errors.emplace_back("failed to load '" + vcxproj + "' from Visual Studio solution"); |
| 499 | return false; |
| 500 | } |
| 501 | found = true; |
| 502 | } |
| 503 | |
| 504 | if (!found) { |
| 505 | errors.emplace_back("no projects found in Visual Studio solution file"); |
| 506 | return false; |
| 507 | } |
| 508 | |
| 509 | return true; |
| 510 | } |
| 511 | |
| 512 | bool ImportProject::importSlnx(const std::string& filename, const std::vector<std::string>& fileFilters) |
| 513 | { |
nothing calls this directly
no test coverage detected