15 #define Z_NULL nullptr
27 uint32_t rom_size = (filesize / 0x2000) * 0x2000;
29 if (rom_size < filesize)
30 result = filesize - rom_size;
34 if (filesize & 0x0FFF)
35 result = filesize & 0x0FFF;
46 tmpcrc = QString(
"%1").arg( crc, 0, 16 );
50 tmpcrc = tmpcrc.rightJustified(8,
'0');
56 static constexpr uint64_t
STATS_REQUIRED {ZIP_STAT_NAME|ZIP_STAT_INDEX|ZIP_STAT_SIZE};
62 std::array<char,32768> block {};
63 uint32_t crc =
crc32(0,
nullptr, 0);
68 LOG(VB_GENERAL, LOG_DEBUG,
69 QString(
"crcinfo : %1 : %2 :").arg(romname).arg(
GameType));
72 int err { ZIP_ER_OK };
73 zip_t *zf = zip_open(qPrintable(romname), 0, &err);
76 zip_int64_t numEntries = zip_get_num_entries(zf, 0);
77 for (
int index = 0; index < numEntries; index++)
79 zip_file_t *infile = zip_fopen_index(zf, index, 0);
83 zip_stat_init(&stats);
84 zip_stat_index(zf, index, 0, &stats);
91 zip_fread(infile, block.data(), offset);
95 while ((count = zip_fread(infile, block.data(), blocksize)) > 0)
97 crc =
crc32(crc, (Bytef *)block.data(), (uInt)count);
100 *key = QString(
"%1:%2").arg(crcRes, stats.name);
102 if (romDB->contains(*key))
116 if (f.open(QIODevice::ReadOnly))
121 f.read(block.data(), offset);
125 while ((count = f.read(block.data(), blocksize)) > 0)
127 crc =
crc32(crc, (Bytef *)block.data(), (uInt)count);
131 *key = QString(
"%1:").arg(crcRes);