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) 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 CompareStreamsByPos(const CStreamInfo *p1, const CStreamInfo *p2, void * /* param */) { int res = MyCompare(p1->PartNumber, p2->PartNumber); if (res != 0) return res; return MyCompare(p1->Resource.Offset, p2->Resource.Offset); }
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; }
int CPropVariant::Compare(const CPropVariant &a) { if (vt != a.vt) return MyCompare(vt, a.vt); switch (vt) { case VT_EMPTY: return 0; // case VT_I1: return MyCompare(cVal, a.cVal); case VT_UI1: return MyCompare(bVal, a.bVal); case VT_I2: return MyCompare(iVal, a.iVal); case VT_UI2: return MyCompare(uiVal, a.uiVal); case VT_I4: return MyCompare(lVal, a.lVal); case VT_UI4: return MyCompare(ulVal, a.ulVal); // case VT_UINT: return MyCompare(uintVal, a.uintVal); case VT_I8: return MyCompare(hVal.QuadPart, a.hVal.QuadPart); case VT_UI8: return MyCompare(uhVal.QuadPart, a.uhVal.QuadPart); case VT_BOOL: return -MyCompare(boolVal, a.boolVal); #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) case VT_FILETIME: return 0; #else case VT_FILETIME: return ::CompareFileTime(&filetime, &a.filetime); #endif case VT_BSTR: return 0; // Not implemented // return MyCompare(aPropVarint.cVal); default: 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(MyCompare(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(MyCompare(s1, s2)); for (i = 0; i < s1; i++) RINOZ(CompareBindPairs(f1.BindPairs[i], f2.BindPairs[i])); return 0; }
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 CompareFolderRepacks(const CFolderRepack *p1, const CFolderRepack *p2, void * /* param */) { RINOZ_COMP(p1->Group, p2->Group); int i1 = p1->FolderIndex; int i2 = p2->FolderIndex; /* // In that version we don't want to parse folders here, so we don't compare folders // probably it must be improved in future const CDbEx &db = *(const CDbEx *)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 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); }
int CPropVariant::Compare(const CPropVariant &a) { if (vt != a.vt) return 0; // it's mean some bug switch (vt) { case VT_EMPTY: return 0; /* case VT_I1: return MyCompare(cVal, a.cVal); */ case VT_UI1: return MyCompare(bVal, a.bVal); case VT_I2: return MyCompare(iVal, a.iVal); case VT_UI2: return MyCompare(uiVal, a.uiVal); case VT_I4: return MyCompare(lVal, a.lVal); /* case VT_INT: return MyCompare(intVal, a.intVal); */ case VT_UI4: return MyCompare(ulVal, a.ulVal); /* case VT_UINT: return MyCompare(uintVal, a.uintVal); */ case VT_I8: return MyCompare(hVal.QuadPart, a.hVal.QuadPart); case VT_UI8: return MyCompare(uhVal.QuadPart, a.uhVal.QuadPart); case VT_BOOL: return -MyCompare(boolVal, a.boolVal); case VT_FILETIME: return ::CompareFileTime(&filetime, &a.filetime); case VT_BSTR: return 0; // Not implemented // return MyCompare(aPropVarint.cVal); default: return 0; } }
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); }
int CompareItems(void *const *a1, void *const *a2, void * /* param */) { const CItem &i1 = **((const CItem **)a1); const CItem &i2 = **((const CItem **)a2); if (i1.isDir() != i2.isDir()) return (i1.isDir()) ? 1 : -1; if (i1.isDir()) return -MyStringCompareNoCase(i1.Name, i2.Name); int res = MyCompare(i1.StreamIndex, i2.StreamIndex); if (res != 0) return res; return MyStringCompareNoCase(i1.Name, i2.Name); }
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 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_COMP(b1.InIndex, b2.InIndex); return MyCompare(b1.OutIndex, b2.OutIndex); }
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); }