MCPcopy Create free account
hub / github.com/WinMerge/winmerge / LoadAndOpenProjectFile

Method LoadAndOpenProjectFile

Src/Merge.cpp:1500–1627  ·  view source on GitHub ↗

* @brief Read project and perform comparison specified * @param [in] sProject Full path to project file. * @return `true` if loading project file and starting compare succeeded. */

Source from the content-addressed store, hash-verified

1498 * @return `true` if loading project file and starting compare succeeded.
1499 */
1500bool CMergeApp::LoadAndOpenProjectFile(const String& sProject, const String& sReportFile)
1501{
1502 ProjectFile project;
1503 if (!LoadProjectFile(sProject, project))
1504 return false;
1505
1506 bool rtn = true;
1507 for (auto& projItem : project.Items())
1508 {
1509 std::unique_ptr<PrediffingInfo> pInfoPrediffer;
1510 std::unique_ptr<PackingInfo> pInfoUnpacker;
1511 PathContext tFiles;
1512 bool bDummy = false;
1513 projItem.GetPaths(tFiles, bDummy);
1514 for (int i = 0; i < tFiles.GetSize(); ++i)
1515 {
1516 tFiles[i] = env::ExpandEnvironmentVariables(tFiles[i]);
1517 if (!paths::IsPathAbsolute(tFiles[i]) && !paths::IsURL(tFiles[i]))
1518 {
1519 String sProjectDir = paths::GetParentPath(sProject);
1520 if (tFiles[i].substr(0, 1) == _T("\\"))
1521 {
1522 if (sProjectDir.length() > 1 && sProjectDir[1] == ':')
1523 tFiles[i] = paths::ConcatPath(sProjectDir.substr(0, 2), tFiles[i]);
1524 }
1525 else
1526 tFiles[i] = paths::ConcatPath(sProjectDir, tFiles[i]);
1527 }
1528 }
1529 bool bLeftReadOnly = projItem.GetLeftReadOnly();
1530 bool bMiddleReadOnly = projItem.GetMiddleReadOnly();
1531 bool bRightReadOnly = projItem.GetRightReadOnly();
1532 if (Options::Project::Get(GetOptionsMgr(), Options::Project::Operation::Open, Options::Project::Item::FileFilter) && projItem.HasFilter())
1533 {
1534 String filter = projItem.GetFilter();
1535 filter = strutils::trim_ws(filter);
1536 GetGlobalFileFilter()->SetMaskOrExpression(filter);
1537 }
1538 bool bRecursive = GetOptionsMgr()->GetBool(OPT_CMP_INCLUDE_SUBDIRS);
1539 if (Options::Project::Get(GetOptionsMgr(), Options::Project::Operation::Open, Options::Project::Item::IncludeSubfolders) && projItem.HasSubfolders())
1540 bRecursive = projItem.GetSubfolders() > 0;
1541 if (Options::Project::Get(GetOptionsMgr(), Options::Project::Operation::Open, Options::Project::Item::Plugin))
1542 {
1543 if (projItem.HasUnpacker())
1544 pInfoUnpacker.reset(new PackingInfo(projItem.GetUnpacker()));
1545 if (projItem.HasPrediffer())
1546 pInfoPrediffer.reset(new PrediffingInfo(projItem.GetPrediffer()));
1547 }
1548 int nID = 0;
1549 if (projItem.HasWindowType())
1550 nID = ID_MERGE_COMPARE_TEXT + projItem.GetWindowType() - 1;
1551 std::unique_ptr<CMainFrame::OpenTableFileParams> pOpenTableFileParams;
1552 if (nID == ID_MERGE_COMPARE_TABLE)
1553 {
1554 pOpenTableFileParams = std::make_unique<CMainFrame::OpenTableFileParams>();
1555 pOpenTableFileParams->m_tableDelimiter = projItem.GetTableDelimiter();
1556 pOpenTableFileParams->m_tableQuote = projItem.GetTableQuote();
1557 pOpenTableFileParams->m_tableAllowNewlinesInQuotes = projItem.GetTableAllowNewLinesInQuotes();

Callers 4

OnCompareMethod · 0.80
OnDropFilesMethod · 0.80
OnFileOpenProjectMethod · 0.80
TESTFunction · 0.80

Calls 15

IsPathAbsoluteFunction · 0.85
IsURLFunction · 0.85
GetParentPathFunction · 0.85
ConcatPathFunction · 0.85
GetFunction · 0.85
GetMainFrameFunction · 0.85
GetLeftReadOnlyMethod · 0.80
GetMiddleReadOnlyMethod · 0.80
GetRightReadOnlyMethod · 0.80
HasFilterMethod · 0.80
GetFilterMethod · 0.80

Tested by 1

TESTFunction · 0.64