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

Method RunFileDiff

Src/DiffWrapper.cpp:758–994  ·  view source on GitHub ↗

* @brief Runs diff-engine. */

Source from the content-addressed store, hash-verified

756 * @brief Runs diff-engine.
757 */
758bool CDiffWrapper::RunFileDiff()
759{
760 PathContext aFiles = m_files;
761 int file;
762 for (file = 0; file < m_files.GetSize(); file++)
763 aFiles[file] = paths::ToWindowsPath(aFiles[file]);
764
765 bool bRet = true;
766 String strFileTemp[3];
767 std::copy(m_files.begin(), m_files.end(), strFileTemp);
768
769 m_options.SetToDiffUtils();
770
771 if (m_bUseDiffList)
772 m_nDiffs = m_pDiffList->GetSize();
773
774 for (file = 0; file < aFiles.GetSize(); file++)
775 {
776 if (m_bPluginsEnabled)
777 {
778 // Do the preprocessing now, overwrite the temp files
779 // NOTE: FileTransform_UCS2ToUTF8() may create new temp
780 // files and return new names, those created temp files
781 // are deleted in end of function.
782
783 // this can only fail if the data can not be saved back (no more
784 // place on disk ???) What to do then ??
785 if (m_infoPrediffer && !m_infoPrediffer->Prediffing(file, strFileTemp[file], m_sToFindPrediffer, m_bPathsAreTemp, { strFileTemp[file] }))
786 {
787 // display a message box
788 String sError = strutils::format_string2(
789 _("Error prediffing '%1' with '%2'. Prediffing disabled."),
790 strFileTemp[file].c_str(),
791 m_infoPrediffer->GetPluginPipeline().c_str());
792 AppErrorMessageBox(sError);
793 // don't use any more this prediffer
794 m_infoPrediffer->ClearPluginPipeline();
795 }
796 }
797 }
798
799 struct change *script = nullptr;
800 struct change *script10 = nullptr;
801 struct change *script12 = nullptr;
802 struct change *script02 = nullptr;
803 DiffFileData diffdata, diffdata10, diffdata12, diffdata02;
804 int bin_flag = 0, bin_flag10 = 0, bin_flag12 = 0, bin_flag02 = 0;
805
806 if (aFiles.GetSize() == 2)
807 {
808 diffdata.SetDisplayFilepaths(aFiles[0], aFiles[1]); // store true names for diff utils patch file
809 // This opens & fstats both files (if it succeeds)
810 if (!diffdata.OpenFiles(strFileTemp[0], strFileTemp[1]))
811 {
812 return false;
813 }
814
815 // Compare the files, if no error was found.

Callers 3

RescanMethod · 0.80
CreatePatchMethod · 0.80
TESTFunction · 0.80

Calls 15

ToWindowsPathFunction · 0.85
GetTemporaryPathFunction · 0.85
ConcatPathFunction · 0.85
tfopen_sFunction · 0.85
print_normal_scriptFunction · 0.85
TFileClass · 0.85
ErrorFunction · 0.85
SetToDiffUtilsMethod · 0.80
PrediffingMethod · 0.80
ClearPluginPipelineMethod · 0.80
SetDisplayFilepathsMethod · 0.80
OpenFilesMethod · 0.80

Tested by 1

TESTFunction · 0.64