X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Ffilethread.cpp;h=5d0d5834398a6abf1c04d888c3f0bb5b6772903b;hb=c436dad60e34fb9da720a89db917eb4cf4e3a624;hp=d4cccc2ea3fbf3a11692a8d5da470ecec96a0726;hpb=8cecfa4150ad7bc9d2a95f9753e2666456f98243;p=virtualjaguar diff --git a/src/gui/filethread.cpp b/src/gui/filethread.cpp index d4cccc2..5d0d583 100644 --- a/src/gui/filethread.cpp +++ b/src/gui/filethread.cpp @@ -1,24 +1,31 @@ // // filethread.cpp - File discovery thread // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software // -// JLH = James L. Hammons +// JLH = James Hammons // // Who When What // --- ---------- ------------------------------------------------------------- // JLH 01/28/2010 Created this file // JLH 02/16/2010 Moved RomIdentifier stuff to its own file +// JLH 03/02/2010 Added .ZIP file fishing +// JLH 06/28/2011 Cleanup in the file parsing/fishing code, to make it easier +// to follow the flow of the logic // #include "filethread.h" #include #include "crc32.h" +#include "file.h" #include "filedb.h" +//#include "memory.h" #include "settings.h" +#define VERBOSE_LOGGING + FileThread::FileThread(QObject * parent/*= 0*/): QThread(parent), abort(false) { } @@ -33,8 +40,9 @@ FileThread::~FileThread() wait(); } -void FileThread::Go(void) +void FileThread::Go(bool allowUnknown/*= false*/) { + allowUnknownSoftware = allowUnknown; QMutexLocker locker(&mutex); start(); } @@ -52,6 +60,7 @@ put that in the list. User picks from a graphical image of the cart. Ideally, the label will go into the archive along with the ROM image, but that's for the future... Maybe box art, screenshots will go as well... +The future is NOW! :-) */ // @@ -60,52 +69,128 @@ Maybe box art, screenshots will go as well... void FileThread::run(void) { QDir romDir(vjs.ROMPath); -// QDir romDir("../virtualjaguar/roms/rarities/"); QFileInfoList list = romDir.entryInfoList(); -/* -Another thing we'll probably have to do here is check for compressed files and -decompress/fish around in them to find what we need. :-P -*/ - for(int i=0; i 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); } // // Find a CRC in the ROM list (simple brute force algorithm). // If it's there, return the index, otherwise return $FFFFFFFF // -uint32 FileThread::FindCRCIndexInFileList(uint32 crc) +uint32_t FileThread::FindCRCIndexInFileList(uint32_t crc) { + // Instead of a simple brute-force search, we should probably do a binary + // partition search instead, since the CRCs are sorted numerically. +#warning "!!! Should do binary partition search here !!!" for(int i=0; romList[i].crc32!=0xFFFFFFFF; i++) { if (romList[i].crc32 == crc) @@ -114,4 +199,3 @@ uint32 FileThread::FindCRCIndexInFileList(uint32 crc) return 0xFFFFFFFF; } -