static int CompareUpdateItems(const CRefItem *p1, const CRefItem *p2, void *param) { const CRefItem &a1 = *p1; const CRefItem &a2 = *p2; const CUpdateItem &u1 = *a1.UpdateItem; const CUpdateItem &u2 = *a2.UpdateItem; int n; if (u1.IsDir != u2.IsDir) return (u1.IsDir) ? 1 : -1; if (u1.IsDir) { if (u1.IsAnti != u2.IsAnti) return (u1.IsAnti ? 1 : -1); n = MyStringCompareNoCase(u1.Name, u2.Name); return -n; } bool sortByType = *(bool *)param; if (sortByType) { RINOZ_COMP(a1.ExtensionIndex, a2.ExtensionIndex); RINOZ(MyStringCompareNoCase(u1.Name + a1.ExtensionPos, u2.Name + a2.ExtensionPos)); RINOZ(MyStringCompareNoCase(u1.Name + a1.NamePos, u2.Name + a2.NamePos)); if (!u1.MTimeDefined && u2.MTimeDefined) return 1; if (u1.MTimeDefined && !u2.MTimeDefined) return -1; if (u1.MTimeDefined && u2.MTimeDefined) RINOZ_COMP(u1.MTime, u2.MTime); RINOZ_COMP(u1.Size, u2.Size); } return MyStringCompareNoCase(u1.Name, u2.Name); }
static int CompareCoders(const CCoderInfo &c1, const CCoderInfo &c2) { RINOZ(MyCompare(c1.NumInStreams, c2.NumInStreams)); RINOZ(MyCompare(c1.NumOutStreams, c2.NumOutStreams)); RINOZ(MyCompare(c1.MethodID, c2.MethodID)); return CompareBuffers(c1.Properties, c2.Properties); }
static int CompareUpdateItems(const CRefItem *p1, const CRefItem *p2, void *param) { const CRefItem &a1 = *p1; const CRefItem &a2 = *p2; const CUpdateItem &u1 = *a1.UpdateItem; const CUpdateItem &u2 = *a2.UpdateItem; int n; if (u1.IsDirectory != u2.IsDirectory) { if (u1.IsDirectory) return u1.IsAnti ? 1: -1; return u2.IsAnti ? -1: 1; } if (u1.IsDirectory) { if (u1.IsAnti != u2.IsAnti) return (u1.IsAnti ? 1 : -1); n = MyStringCompareNoCase(u1.Name, u2.Name); return (u1.IsAnti ? (-n) : n); } if (a1.SortByType) { RINOZ(MyStringCompareNoCase(u1.Name + a1.ExtensionPos, u2.Name + a2.ExtensionPos)); RINOZ(MyStringCompareNoCase(u1.Name + a1.NamePos, u2.Name + a2.NamePos)); if (u1.LastWriteTimeIsDefined && u2.LastWriteTimeIsDefined) RINOZ(CompareFileTime(&u1.LastWriteTime, &u2.LastWriteTime)); RINOZ(MyCompare(u1.Size, u2.Size)) }
static int CompareUpdateItems(const CRefItem *p1, const CRefItem *p2, void *param) { const CRefItem &a1 = *p1; const CRefItem &a2 = *p2; const CUpdateItem &u1 = *a1.UpdateItem; const CUpdateItem &u2 = *a2.UpdateItem; int n; if (u1.IsDirectory != u2.IsDirectory) return (u1.IsDirectory) ? 1 : -1; if (u1.IsDirectory) { if (u1.IsAnti != u2.IsAnti) return (u1.IsAnti ? 1 : -1); n = MyStringCompareNoCase(u1.Name, u2.Name); return -n; } bool sortByType = *(bool *)param; if (sortByType) { RINOZ(MyCompare(a1.ExtensionIndex, a2.ExtensionIndex)) RINOZ(MyStringCompareNoCase(u1.Name + a1.ExtensionPos, u2.Name + a2.ExtensionPos)); RINOZ(MyStringCompareNoCase(u1.Name + a1.NamePos, u2.Name + a2.NamePos)); if (u1.IsLastWriteTimeDefined && u2.IsLastWriteTimeDefined) RINOZ(CompareFileTime(&u1.LastWriteTime, &u2.LastWriteTime)); RINOZ(MyCompare(u1.Size, u2.Size)) } return MyStringCompareNoCase(u1.Name, u2.Name); }
static int CompareBuffers(const CByteBuffer &a1, const CByteBuffer &a2) { size_t c1 = a1.GetCapacity(); size_t c2 = a2.GetCapacity(); RINOZ(MyCompare(c1, c2)); for (size_t i = 0; i < c1; i++) RINOZ(MyCompare(a1[i], a2[i])); return 0; }
static int CompareCoders(const CCoderInfo &c1, const CCoderInfo &c2) { RINOZ(MyCompare(c1.NumInStreams, c2.NumInStreams)); RINOZ(MyCompare(c1.NumOutStreams, c2.NumOutStreams)); int s1 = c1.AltCoders.Size(); int s2 = c2.AltCoders.Size(); RINOZ(MyCompare(s1, s2)); for (int i = 0; i < s1; i++) RINOZ(CompareAltCoders(c1.AltCoders[i], c2.AltCoders[i])); return 0; }
static int CompareFolders(const CFolder &f1, const CFolder &f2) { int s1 = f1.Coders.Size(); int s2 = f2.Coders.Size(); RINOZ_COMP(s1, s2); int i; for (i = 0; i < s1; i++) RINOZ(CompareCoders(f1.Coders[i], f2.Coders[i])); s1 = f1.BindPairs.Size(); s2 = f2.BindPairs.Size(); RINOZ_COMP(s1, s2); for (i = 0; i < s1; i++) RINOZ(CompareBindPairs(f1.BindPairs[i], f2.BindPairs[i])); return 0; }
static int CompareFolderRefs(const int *p1, const int *p2, void *param) { int i1 = *p1; int i2 = *p2; const CArchiveDatabaseEx &db = *(const CArchiveDatabaseEx *)param; RINOZ(CompareFolders( db.Folders[i1], db.Folders[i2])); RINOZ(MyCompare( db.NumUnPackStreamsVector[i1], db.NumUnPackStreamsVector[i2])); if (db.NumUnPackStreamsVector[i1] == 0) return 0; return CompareFiles( db.Files[db.FolderStartFileIndex[i1]], db.Files[db.FolderStartFileIndex[i2]]); }
static int CompareMvItems(const CMvItem *p1, const CMvItem *p2, void *param) { const CMvDatabaseEx &mvDb = *(const CMvDatabaseEx *)param; const CDatabaseEx &db1 = mvDb.Volumes[p1->VolumeIndex]; const CDatabaseEx &db2 = mvDb.Volumes[p2->VolumeIndex]; const CItem &item1 = db1.Items[p1->ItemIndex]; const CItem &item2 = db2.Items[p2->ItemIndex];; bool isDir1 = item1.IsDir(); bool isDir2 = item2.IsDir(); if (isDir1 && !isDir2) return -1; if (isDir2 && !isDir1) return 1; int f1 = mvDb.GetFolderIndex(p1); int f2 = mvDb.GetFolderIndex(p2); RINOZ(MyCompare(f1, f2)); RINOZ(MyCompare(item1.Offset, item2.Offset)); RINOZ(MyCompare(item1.Size, item2.Size)); return CompareMvItems2(p1, p2); }
static int CompareFiles(const unsigned *p1, const unsigned *p2, void *param) { const CObjectVector<CItem> &items = *(const CObjectVector<CItem> *)param; const CItem &item1 = items[*p1]; const CItem &item2 = items[*p2]; bool isDir1 = item1.IsDir(); bool isDir2 = item2.IsDir(); if (isDir1 && !isDir2) return -1; if (isDir2) { if (!isDir1) return 1; } else { RINOZ(MyCompare(item1.Section, item2.Section)); RINOZ(MyCompare(item1.Offset, item2.Offset)); RINOZ(MyCompare(item1.Size, item2.Size)); } return MyCompare(*p1, *p2); }
static int CompareFolderRepacks(const CFolderRepack *p1, const CFolderRepack *p2, void *param) { RINOZ_COMP(p1->Group, p2->Group); int i1 = p1->FolderIndex; int i2 = p2->FolderIndex; const CArchiveDatabaseEx &db = *(const CArchiveDatabaseEx *)param; RINOZ(CompareFolders( db.Folders[i1], db.Folders[i2])); return MyCompare(i1, i2); /* RINOZ_COMP( db.NumUnpackStreamsVector[i1], db.NumUnpackStreamsVector[i2]); if (db.NumUnpackStreamsVector[i1] == 0) return 0; return CompareFiles( db.Files[db.FolderStartFileIndex[i1]], db.Files[db.FolderStartFileIndex[i2]]); */ }
static int CompareMvItems2(const CMvItem *p1, const CMvItem *p2) { RINOZ(MyCompare(p1->VolumeIndex, p2->VolumeIndex)); return MyCompare(p1->ItemIndex, p2->ItemIndex); }
static int CompareBindPairs(const CBindPair &b1, const CBindPair &b2) { RINOZ(MyCompare(b1.InIndex, b2.InIndex)); return MyCompare(b1.OutIndex, b2.OutIndex); }
static int CompareAltCoders(const CAltCoderInfo &a1, const CAltCoderInfo &a2) { RINOZ(CompareMethodIDs(a1.MethodID, a2.MethodID)); return CompareBuffers(a1.Properties, a2.Properties); }
static int CompareMethodIDs(const CMethodID &a1, const CMethodID &a2) { for (int i = 0; i < a1.IDSize && i < a2.IDSize; i++) RINOZ(MyCompare(a1.ID[i], a2.ID[i])); return MyCompare(a1.IDSize, a2.IDSize); }
static int CompareUpdateItems(const CRefItem *p1, const CRefItem *p2, void *param) { const CRefItem &a1 = *p1; const CRefItem &a2 = *p2; const CUpdateItem &u1 = *a1.UpdateItem; const CUpdateItem &u2 = *a2.UpdateItem; /* if (u1.IsAltStream != u2.IsAltStream) return u1.IsAltStream ? 1 : -1; */ // Actually there are no dirs that time. They were stored in other steps // So that code is unused? if (u1.IsDir != u2.IsDir) return u1.IsDir ? 1 : -1; if (u1.IsDir) { if (u1.IsAnti != u2.IsAnti) return (u1.IsAnti ? 1 : -1); int n = CompareFileNames(u1.Name, u2.Name); return -n; } // bool sortByType = *(bool *)param; const CSortParam *sortParam = (const CSortParam *)param; bool sortByType = sortParam->SortByType; if (sortByType) { RINOZ_COMP(a1.ExtensionIndex, a2.ExtensionIndex); RINOZ(CompareFileNames(u1.Name.Ptr(a1.ExtensionPos), u2.Name.Ptr(a2.ExtensionPos))); RINOZ(CompareFileNames(u1.Name.Ptr(a1.NamePos), u2.Name.Ptr(a2.NamePos))); if (!u1.MTimeDefined && u2.MTimeDefined) return 1; if (u1.MTimeDefined && !u2.MTimeDefined) return -1; if (u1.MTimeDefined && u2.MTimeDefined) RINOZ_COMP(u1.MTime, u2.MTime); RINOZ_COMP(u1.Size, u2.Size); } /* int par1 = a1.UpdateItem->ParentFolderIndex; int par2 = a2.UpdateItem->ParentFolderIndex; const CTreeFolder &tf1 = (*sortParam->TreeFolders)[par1]; const CTreeFolder &tf2 = (*sortParam->TreeFolders)[par2]; int b1 = tf1.SortIndex, e1 = tf1.SortIndexEnd; int b2 = tf2.SortIndex, e2 = tf2.SortIndexEnd; if (b1 < b2) { if (e1 <= b2) return -1; // p2 in p1 int par = par2; for (;;) { const CTreeFolder &tf = (*sortParam->TreeFolders)[par]; par = tf.Parent; if (par == par1) { RINOZ(CompareFileNames(u1.Name, tf.Name)); break; } } } else if (b2 < b1) { if (e2 <= b1) return 1; // p1 in p2 int par = par1; for (;;) { const CTreeFolder &tf = (*sortParam->TreeFolders)[par]; par = tf.Parent; if (par == par2) { RINOZ(CompareFileNames(tf.Name, u2.Name)); break; } } } */ // RINOZ_COMP(a1.UpdateItem->ParentSortIndex, a2.UpdateItem->ParentSortIndex); RINOK(CompareFileNames(u1.Name, u2.Name)); RINOZ_COMP(a1.UpdateItem->IndexInClient, a2.UpdateItem->IndexInClient); RINOZ_COMP(a1.UpdateItem->IndexInArchive, a2.UpdateItem->IndexInArchive); return 0; }