+
+ // Try to divine the file type by size & header
+ int fileType = ParseFileType(buffer, fileSize);
+
+ // Check for Alpine ROM w/Universal Header
+ bool foundUniversalHeader = HasUniversalHeader(buffer, fileSize);
+ uint32_t crc;
+
+//printf("FileThread: About to calc checksum on file with size %u... (buffer=%08X)\n", size, buffer);
+ if (foundUniversalHeader)
+ crc = crc32_calcCheckSum(buffer + 8192, fileSize - 8192);
+ else
+ crc = crc32_calcCheckSum(buffer, fileSize);
+
+ uint32_t index = FindCRCIndexInFileList(crc);
+ delete[] buffer;
+
+ // Here we filter out files that are *not* in the DB and of unknown type,
+ // and BIOS files. If desired, this can be overriden with a config option.
+ if ((index == 0xFFFFFFFF) && (fileType == JST_NONE))
+ {
+ // If we allow unknown software, we pass the (-1) index on, otherwise...
+ if (!allowUnknownSoftware)
+ return; // CRC wasn't found, so bail...
+ }
+ else if ((index != 0xFFFFFFFF) && romList[index].flags & FF_BIOS)
+ return;
+
+//Here's a little problem. When we create the image here and pass it off to FilePicker,
+//we can clobber this image before we have a chance to copy it out in the FilePicker function
+//because we can be back here before FilePicker can respond.
+// So now we create the image on the heap, problem solved. :-)
+ QImage * img = NULL;
+
+ // See if we can fish out a label. :-)
+ if (haveZIPFile)
+ {
+ uint32_t size = GetFileFromZIP(fileInfo.filePath().toAscii(), FT_LABEL, buffer);
+//printf("FT: Label size = %u bytes.\n", size);
+
+ if (size > 0)
+ {
+ QImage label;
+ bool successful = label.loadFromData(buffer, size);
+ img = new QImage;
+ *img = label.scaled(365, 168, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+//printf("FT: Label %s: %ux%u.\n", (successful ? "succeeded" : "did not succeed"), img->width(), img->height());
+ delete[] buffer;
+ }
+//printf("FileThread: Attempted to load image. Size: %u x %u...\n", img.width(), img.height());
+ }
+
+// emit FoundAFile2(index, fileInfo.canonicalFilePath(), img, fileSize);
+ emit FoundAFile3(index, fileInfo.canonicalFilePath(), img, fileSize, foundUniversalHeader, fileType, crc);