Skip to content

Commit

Permalink
Rename fModified to includeInUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
Fulgen301 committed Oct 13, 2024
1 parent 8b29199 commit 994055c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/C4Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,8 @@ bool C4UpdatePackage::MakeUpdate(const char *strFile1, const char *strFile2, con
}

// compare groups, create update
bool fModified = false;
bool fSuccess = MkUp(&Group1, &Group2, &UpGroup, &fModified);
bool includeInUpdate{false};
bool fSuccess = MkUp(&Group1, &Group2, &UpGroup, includeInUpdate);
// close (save) it
UpGroup.Close(false);
// error?
Expand All @@ -748,7 +748,7 @@ bool C4UpdatePackage::MakeUpdate(const char *strFile1, const char *strFile2, con
return true;
}

bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bool *fModified)
bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bool &includeInUpdate)
{
// (CAUTION: pGrp1 may be nullptr - that means that there is no counterpart for Grp2
// in the base group)
Expand All @@ -759,27 +759,27 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
pGrp1->GetOriginal() != pGrp2->GetOriginal() ||
!SEqual(pGrp1->GetMaker(), pGrp2->GetMaker()) ||
!SEqual(pGrp1->GetPassword(), pGrp2->GetPassword()))
*fModified = true;
includeInUpdate = true;
// set header
pUpGrp->SetHead(*pGrp2);
// compare entries
char strItemName[_MAX_PATH], strItemName2[_MAX_PATH];
std::string entryList;
strItemName[0] = strItemName2[0] = 0;
pGrp2->ResetSearch(); if (!*fModified) pGrp1->ResetSearch();
pGrp2->ResetSearch(); if (!includeInUpdate) pGrp1->ResetSearch();
int iChangedEntries = 0;
while (pGrp2->FindNextEntry("*", strItemName, nullptr, nullptr, !!strItemName[0]))
{
// add to entry list
if (!entryList.empty()) entryList += '|';
entryList += std::format("{}={}", strItemName, pGrp2->EntryTime(strItemName));
// no modification detected yet? then check order
if (!AllowMissingTarget && !*fModified)
if (!AllowMissingTarget && !includeInUpdate)
{
if (!pGrp1->FindNextEntry("*", strItemName2, nullptr, nullptr, !!strItemName2[0]))
*fModified = true;
includeInUpdate = true;
else if (!SEqual(strItemName, strItemName2))
*fModified = true;
includeInUpdate = true;
}

// TODO: write DeleteEntries.txt
Expand All @@ -805,18 +805,18 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
if (!UpdGroup.Open(strTempGroupName, true)) { delete pChildGrp1; WriteLog("Error: could not create temp group\n"); return false; }
}
// do nested MkUp-search
bool Modified = false;
bool fSuccess = MkUp(pChildGrp1, &ChildGrp2, &UpdGroup, &Modified);
bool childIncludeInUpdate{false};
bool fSuccess = MkUp(pChildGrp1, &ChildGrp2, &UpdGroup, childIncludeInUpdate);
// sort & close
extern const char **C4Group_SortList;
UpdGroup.SortByList(C4Group_SortList, ChildGrp2.GetName());
UpdGroup.Close(false);
// always add the entire group if mising targets are allowed
// otherwise check entry times
if (AllowMissingTarget || !pGrp1 || (pGrp1->EntryTime(strItemName) != pGrp2->EntryTime(strItemName)))
Modified = true;
childIncludeInUpdate = true;
// add group (if modified)
if (fSuccess && Modified)
if (fSuccess && childIncludeInUpdate)
{
if (strTempGroupName[0])
if (!pUpGrp->Move(strTempGroupName, strItemName))
Expand All @@ -828,7 +828,7 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
pUpGrp->SaveEntryCore(*pGrp2, strItemName);
pUpGrp->SetSavedEntryCore(strItemName);
// got a modification in a subgroup
*fModified = true;
includeInUpdate = true;
iChangedEntries++;
}
else
Expand Down Expand Up @@ -869,7 +869,7 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
// set entry core
pUpGrp->SetSavedEntryCore(strItemName);
// modified...
*fModified = true;
includeInUpdate = true;
fCopied = true;
}
iChangedEntries++;
Expand All @@ -887,7 +887,7 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
}

if (iChangedEntries > 0)
WriteLog("{}: {}/{} changed ({})\n", pGrp2->GetFullName().getData(), iChangedEntries, pGrp2->EntryCount(), *fModified ? "update" : "skip");
WriteLog("{}: {}/{} changed ({})\n", pGrp2->GetFullName().getData(), iChangedEntries, pGrp2->EntryCount(), includeInUpdate ? "update" : "skip");

// success
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/C4Update.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class C4UpdatePackage : public C4UpdatePackageCore
bool DoGrpUpdate(C4Group *pUpdateData, class C4GroupEx *pGrpTo);
static bool Optimize(C4Group *pGrpFrom, class C4GroupEx *pGrpTo, const char *strFileName);

bool MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGr, bool *fModified);
bool MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGr, bool &includeInUpdate);

CStdFile Log;

Expand Down

0 comments on commit 994055c

Please sign in to comment.