| 666 | //========================================================================== |
| 667 | |
| 668 | void GetCRC(FileEntry *entry, TArray<FileEntry> &CRCCache) |
| 669 | { |
| 670 | for (auto &ce : CRCCache) |
| 671 | { |
| 672 | // File size, modification date snd name all must match exactly to pick an entry. |
| 673 | if (entry->FileLength == ce.FileLength && entry->FileTime == ce.FileTime && entry->FileName.Compare(ce.FileName) == 0) |
| 674 | { |
| 675 | entry->CRCValue = ce.CRCValue; |
| 676 | return; |
| 677 | } |
| 678 | } |
| 679 | FileReader f; |
| 680 | if (f.OpenFile(entry->FileName.GetChars())) |
| 681 | { |
| 682 | TArray<uint8_t> buffer(65536, 1); |
| 683 | uint32_t crcval = 0; |
| 684 | size_t b; |
| 685 | do |
| 686 | { |
| 687 | b = f.Read(buffer.Data(), buffer.Size()); |
| 688 | if (b > 0) crcval = AddCRC32(crcval, buffer.Data(), unsigned(b)); |
| 689 | } |
| 690 | while (b == buffer.Size()); |
| 691 | entry->CRCValue = crcval; |
| 692 | CRCCache.Push(*entry); |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | GrpInfo *IdentifyGroup(FileEntry *entry, TArray<GrpInfo *> &groups) |
| 697 | { |