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

Function ParseConflictFile

Src/ConflictFileParser.cpp:82–337  ·  view source on GitHub ↗

* @brief Parse a conflict file to separate files. * This function parses a conflict file to two different files which can be * opened into WinMerge's file compare. * @param [in] conflictFileName Full path to conflict file. * @param [in] workingCopyFileName Full path for user's modified file in * working copy/working folder. * @param [in] newRevisionFileName Full path for revision control fi

Source from the content-addressed store, hash-verified

80 * @return true if conflict file was successfully parsed, false otherwise.
81 */
82bool ParseConflictFile(const String& conflictFileName,
83 const String& workingCopyFileName, const String& newRevisionFileName, const String& baseRevisionFileName,
84 int iGuessEncodingType, bool &bNestedConflicts, bool &b3way)
85{
86 UniMemFile conflictFile;
87 UniStdioFile workingCopy;
88 UniStdioFile newRevision;
89 UniStdioFile baseRevision;
90 String line;
91 std::string::size_type pos;
92 int state;
93 int iNestingLevel = 0;
94 bool bResult = false;
95 String revision = _T("none");
96 bNestedConflicts = false;
97 b3way = false;
98
99 // open input file
100 bool success = conflictFile.OpenReadOnly(conflictFileName);
101 if (!success)
102 return false;
103
104 // Create output files
105 bool success2 = workingCopy.Open(workingCopyFileName, _T("wb"));
106 if (!success2)
107 return false;
108 bool success3 = newRevision.Open(newRevisionFileName, _T("wb"));
109 if (!success3)
110 return false;
111 bool success4 = baseRevision.Open(baseRevisionFileName, _T("wb"));
112 if (!success4)
113 return false;
114
115 // detect codepage of conflict file
116 FileTextEncoding encoding = codepage_detect::Guess(conflictFileName, iGuessEncodingType);
117
118 conflictFile.SetUnicoding(encoding.m_unicoding);
119 conflictFile.SetBom(encoding.m_bom);
120 conflictFile.SetCodepage(encoding.m_codepage);
121 workingCopy.SetUnicoding(encoding.m_unicoding);
122 workingCopy.SetBom(encoding.m_bom);
123 workingCopy.SetCodepage(encoding.m_codepage);
124 newRevision.SetUnicoding(encoding.m_unicoding);
125 newRevision.SetBom(encoding.m_bom);
126 newRevision.SetCodepage(encoding.m_codepage);
127 baseRevision.SetUnicoding(encoding.m_unicoding);
128 baseRevision.SetBom(encoding.m_bom);
129 baseRevision.SetCodepage(encoding.m_codepage);
130
131 state = 0;
132 bool linesToRead = true;
133 do
134 {
135 bool lossy;
136 String eol;
137 linesToRead = conflictFile.ReadString(line, eol, &lossy);
138 switch (state)
139 {

Callers 1

DoOpenConflictMethod · 0.85

Calls 13

GuessFunction · 0.85
OpenReadOnlyMethod · 0.80
SetBomMethod · 0.80
OpenMethod · 0.45
SetUnicodingMethod · 0.45
SetCodepageMethod · 0.45
ReadStringMethod · 0.45
findMethod · 0.45
WriteStringMethod · 0.45
resizeMethod · 0.45
emptyMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected